Skip to content

Commit

Permalink
Provide a usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
m-martin-j committed Sep 21, 2022
1 parent fbb8dd4 commit 4f1a5f6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ journal = {Proceedings, Twentieth International Conference on Machine Learning}

Data for testing is taken from the [UCI Machine Learning Repository](http://archive.ics.uci.edu/ml)

## Example

```py
from fcbf import fcbf, data


dataset = data.lung_cancer
X = dataset[dataset.columns[1:]]
y = dataset[dataset.columns[0]].astype(int)
print(X)
print(y)

relevant_features, irrelevant_features, correlations = fcbf(X, y, su_threshold=0.1, base=2)
print('relevant_features:', relevant_features, '(count:', len(relevant_features), ')')
print('irrelevant_features:', irrelevant_features, '(count:', len(irrelevant_features), ')')
print('correlations:', correlations)
```

## Setup
Using pip, execute the following

Expand Down
17 changes: 17 additions & 0 deletions fcbf/fcbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,20 @@ def fcbf(X: pd.DataFrame, y: pd.Series,
irrelevant_feature_names = [f_name for (f_name, _) in S_ord_removed + S_removed]

return relevant_feature_names_sorted, irrelevant_feature_names, correlation_values


if __name__ == '__main__':

from fcbf import data


dataset = data.lung_cancer
X = dataset[dataset.columns[1:]]
y = dataset[dataset.columns[0]].astype(int)
print(X)
print(y)

relevant_features, irrelevant_features, correlations = fcbf(X, y, su_threshold=0.1, base=2)
print('relevant_features:', relevant_features, '(count:', len(relevant_features), ')')
print('irrelevant_features:', irrelevant_features, '(count:', len(irrelevant_features), ')')
print('correlations:', correlations)

0 comments on commit 4f1a5f6

Please sign in to comment.