Skip to content

Add Python implementation using numpy and scipy#2

Draft
Copilot wants to merge 3 commits into
masterfrom
copilot/rewrite-matlab-code-in-python
Draft

Add Python implementation using numpy and scipy#2
Copilot wants to merge 3 commits into
masterfrom
copilot/rewrite-matlab-code-in-python

Conversation

Copilot AI commented Jan 9, 2026

Copy link
Copy Markdown

Rewrites the MATLAB ALPUD algorithm in Python while preserving the original MATLAB files for backward compatibility.

Implementation

  • alpud.py: Core module with two functions using scipy.stats.gaussian_kde (equivalent to MATLAB's ksdensity)

    • compute_informativeness_with_known_prior() - implements equation 8 with known prior P
    • compute_informativeness_with_unknown_prior() - computes expected value over uniform prior distribution
    • Added epsilon to denominator to prevent division by zero
  • Package configuration: setup.py, requirements.txt (numpy>=1.19.0, scipy>=1.5.0)

  • Testing: test_alpud.py validates 1D and 2D data, example.py demonstrates usage

  • Documentation: Updated README with Python installation and usage

Usage

import numpy as np
from alpud import compute_informativeness_with_known_prior

positive_data = np.array([1.0, 1.2, 1.1, 1.3, 1.15])
unlabeled_data = np.array([0.5, 2.0, 1.5, 0.8, 2.5])
query_samples = np.array([0.9, 1.0, 1.5, 2.0])

informativeness = compute_informativeness_with_known_prior(
    positive_data, unlabeled_data, P=0.3, query_samples=query_samples
)
Original prompt

This section details on the original issue you should resolve

<issue_title>Rewrite in Python</issue_title>
<issue_description>Rewrite the original MATLAB code in Python, using numpy and possibly scipy and scikit-learn as dependencies. </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Rewrite original MATLAB code in Python Add Python implementation using numpy and scipy Jan 9, 2026
Copilot AI requested a review from aghasemi January 9, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rewrite in Python

2 participants