Skip to content

Commit 8f69afe

Browse files
committed
DOC add readme examples
1 parent 9b37462 commit 8f69afe

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

README.rst

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,27 @@ Or via conda-forge:
5757
Getting Started
5858
---------------
5959
>>> from fastcan import FastCan
60-
>>> X = [[1, 0], [0, 1]]
61-
>>> y = [1, 0]
62-
>>> FastCan(verbose=0).fit(X, y).get_support()
63-
array([ True, False])
60+
>>> X = [[ 0.87, -1.34, 0.31 ],
61+
... [-2.79, -0.02, -0.85 ],
62+
... [-1.34, -0.48, -2.55 ],
63+
... [ 1.92, 1.48, 0.65 ]]
64+
>>> y = [0, 1, 0, 1]
65+
>>> selector = FastCan(n_features_to_select=2, verbose=0).fit(X, y)
66+
>>> selector.get_support()
67+
array([ True, True, False])
68+
>>> selector.get_support(indices=True) # Sorted indices
69+
array([0, 1])
70+
>>> selector.indices_ # Indices in selection order
71+
array([1, 0], dtype=int32)
72+
>>> selector.scores_ # Scores for selected features in selection order
73+
array([0.64276838, 0.09498243])
74+
>>> # Here Feature 2 must be included
75+
>>> selector = FastCan(n_features_to_select=2, indices_include=[2], verbose=0).fit(X, y)
76+
>>> # We can find the feature which is useful when working with Feature 2
77+
>>> selector.indices_
78+
array([2, 1], dtype=int32)
79+
>>> selector.scores_
80+
array([0.16632562, 0.50544788])
6481

6582

6683
Citation

fastcan/_fastcan.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,10 @@ class FastCan(SelectorMixin, BaseEstimator):
7777
Examples
7878
--------
7979
>>> from fastcan import FastCan
80-
>>> X = [[ 0.87, -1.34, 0.31 ],
81-
... [-2.79, -0.02, -0.85 ],
82-
... [-1.34, -0.48, -2.55 ],
83-
... [ 1.92, 1.48, 0.65 ]]
84-
>>> y = [0, 1, 0, 1]
85-
>>> selector = FastCan(n_features_to_select=2, verbose=0).fit(X, y)
86-
>>> selector.get_support()
87-
array([ True, True, False])
80+
>>> X = [[1, 0], [0, 1]]
81+
>>> y = [1, 0]
82+
>>> FastCan(verbose=0).fit(X, y).get_support()
83+
array([ True, False])
8884
"""
8985

9086
_parameter_constraints: dict = {

pixi.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)