Skip to content

Commit b09cf43

Browse files
MatthewSZhangagriyakhetarpal
authored andcommitted
Add fastcan (#374)
Co-authored-by: Agriya Khetarpal <[email protected]>
1 parent c29266d commit b09cf43

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

packages/fastcan/meta.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package:
2+
name: fastcan
3+
version: 0.4.1
4+
top-level:
5+
- fastcan
6+
source:
7+
url: https://files.pythonhosted.org/packages/source/f/fastcan/fastcan-0.4.1.tar.gz
8+
sha256: a4d3b285671920ed413462a4a3536794f494cd4373501a68f6820e1ecb151fbe
9+
requirements:
10+
run:
11+
- scikit-learn
12+
test:
13+
imports:
14+
- fastcan
15+
about:
16+
home: https://github.com/scikit-learn-contrib/fastcan
17+
PyPI: https://pypi.org/project/fastcan
18+
summary: A fast canonical-correlation-based greedy search algorithm
19+
license: MIT
20+
extra:
21+
recipe-maintainers:
22+
- MatthewSZhang

packages/fastcan/test_fastcan.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import pytest
2+
from pytest_pyodide import run_in_pyodide
3+
4+
5+
@pytest.mark.driver_timeout(60)
6+
@run_in_pyodide(packages=["fastcan"])
7+
def test_fastcan(selenium):
8+
from fastcan import FastCan
9+
from sklearn.datasets import make_classification
10+
from sklearn.linear_model import LinearRegression
11+
n_samples = 200
12+
n_features = 20
13+
n_classes = 8
14+
n_informative = 5
15+
16+
X, y = make_classification(
17+
n_samples=n_samples,
18+
n_features=n_features,
19+
n_informative=n_informative,
20+
n_redundant=0,
21+
n_repeated=0,
22+
n_classes=n_classes,
23+
n_clusters_per_class=1,
24+
flip_y=0.0,
25+
class_sep=10,
26+
shuffle=False,
27+
random_state=0,
28+
)
29+
30+
reg = LinearRegression().fit(X[:, :n_informative], y)
31+
gtruth_ssc = reg.score(X[:, :n_informative], y)
32+
33+
correlation_filter = FastCan(
34+
n_features_to_select=n_informative,
35+
)
36+
correlation_filter.fit(X, y)
37+
ssc = correlation_filter.scores_.sum()
38+
assert abs(ssc - gtruth_ssc) < 1e-5

0 commit comments

Comments
 (0)