A small example package
Project description
CafsPy
A covering Array Feature Selection Library. Aditioanlly, in order to use this librabry is recomended to intstall it over a new python virtual enviroment without any pre-intsalled library to avoid conflicts.
Instruction to install:
First, install from pip.
pip install cafspy
Once installed, look at the follow mini tutorial, in order to use CafsPy accordingly. There are 2 Covering Array algorithms available.
from cafspy import ICAFS
from cafspy import CAFS
Then, in order to use ICAFS, we need to set up the datasets that you want to generate features subsets. For this sample , we will use Non-plus/ plus algarrobo available in this project. Is important to remark that the X dataset must containts string header and numerics values. The same must be taken into account for y.
df_algarrobo = pd.read_csv('data/algarrobo.csv')
unique_names_algarrobo = df_algarrobo['Labels'].unique()
algarrobo_x = df_algarrobo.loc[:, 'R':'REDVI']
y_algarrobo = df_algarrobo['Labels'].replace(to_replace=unique_names_algarrobo, value=[0, 1]).to_frame()
X_algarrobo = (algarrobo_x-algarrobo_x.min())/(algarrobo_x.max()-algarrobo_x.min())
Once the data is prepared, is important to define the classfication algorithm from sklearn that you want to work with. For this little sample, we will wotk with kNN .
from sklearn.neighbors import KNeighborsClassifier
lr_algo = KNeighborsClassifier(n_neighbors=3)
Secondly, we need to definte the interaction t. Remember that this represent the interaction between any interaction, this means that it will generate all subsets of size t btween any feature available. Hence, the complexity will increase. for that reason on the following papaer a deep anaylisis was done to get the best interaction level. This sample will work on t=2, and number of iteration T=10. The print_logs will show the best features selected at each iteration.
scores_list,feature_list = ICAFS(X_algarrobo,y_algarrobo,t=2,T=10,lr=lr_algo,print_logs=True)
for this sample, this shows the best feature selected during 10 iterations
best f1 score= 0.7351370100315423, iteration:1, numbers features selected =9,best features selected=NGRDI, NDVI, RVI, DVI, EVI, REVI, NDRE, RERVI, REDVI
best f1 score= 0.7216630322908072, iteration:2, numbers features selected =6,best features selected=NGRDI, NDVI, RVI, EVI, NDRE, REDVI
best f1 score= 0.717571263976013, iteration:3, numbers features selected =4,best features selected=NGRDI, NDVI, RVI, NDRE
best f1 score= 0.7092041147580356, iteration:4, numbers features selected =3,best features selected=NGRDI, NDVI, RVI
best f1 score= 0.7092041147580356, iteration:5, numbers features selected =3,best features selected=NGRDI, NDVI, RVI
best f1 score= 0.7092041147580356, iteration:6, numbers features selected =3,best features selected=NGRDI, NDVI, RVI
best f1 score= 0.7092041147580356, iteration:7, numbers features selected =3,best features selected=NGRDI, NDVI, RVI
best f1 score= 0.7092041147580356, iteration:8, numbers features selected =3,best features selected=NGRDI, NDVI, RVI
best f1 score= 0.7092041147580356, iteration:9, numbers features selected =3,best features selected=NGRDI, NDVI, RVI
best f1 score= 0.7092041147580356, iteration:10, numbers features selected =3,best features selected=NGRDI, NDVI, RVI
Another important parameter is the shuffle and seed, when acitvated and configured, different result will be gotten.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cafspy-0.0.1.tar.gz.
File metadata
- Download URL: cafspy-0.0.1.tar.gz
- Upload date:
- Size: 6.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecc41173415f565b6e53d931129d9ea43d2647abfe59fb08c6b87d7a5264d41c
|
|
| MD5 |
0760450739aaabda8f2845de395a3333
|
|
| BLAKE2b-256 |
822c37658040d9ffc6982816eaa7c66f6000637a34e46550cf6877f6d6bca6e7
|
Provenance
The following attestation bundles were made for cafspy-0.0.1.tar.gz:
Publisher:
publish-to-pypi.yml on SalvadorRomo/CafsPy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cafspy-0.0.1.tar.gz -
Subject digest:
ecc41173415f565b6e53d931129d9ea43d2647abfe59fb08c6b87d7a5264d41c - Sigstore transparency entry: 369267975
- Sigstore integration time:
-
Permalink:
SalvadorRomo/CafsPy@ec9d6fc80b953e144294c923901c3eba85fbf25c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/SalvadorRomo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@ec9d6fc80b953e144294c923901c3eba85fbf25c -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cafspy-0.0.1-py3-none-any.whl.
File metadata
- Download URL: cafspy-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d26aaea027b9dd3f9072cb90ae2fd878d166a1679969d591fc9a0e5d9e2ec9df
|
|
| MD5 |
b048760fabc694cf293e79e4dd90e3f4
|
|
| BLAKE2b-256 |
e305f88bc9d901dc3a9c660abd73988cb427c879ad1bbf4890f3e9094e9383a9
|
Provenance
The following attestation bundles were made for cafspy-0.0.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on SalvadorRomo/CafsPy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cafspy-0.0.1-py3-none-any.whl -
Subject digest:
d26aaea027b9dd3f9072cb90ae2fd878d166a1679969d591fc9a0e5d9e2ec9df - Sigstore transparency entry: 369268013
- Sigstore integration time:
-
Permalink:
SalvadorRomo/CafsPy@ec9d6fc80b953e144294c923901c3eba85fbf25c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/SalvadorRomo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@ec9d6fc80b953e144294c923901c3eba85fbf25c -
Trigger Event:
workflow_dispatch
-
Statement type: