Skip to content

Commit

Permalink
Release
Browse files Browse the repository at this point in the history
  • Loading branch information
kingychiu committed Jul 9, 2023
1 parent a654df0 commit f7bc8f6
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 12 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ beartype = "^0.14.1"
### Tree Models with `feature_importances_` Attribute

```python
# Import the function
# import the package
import target_permutation_importances as tpi

# Prepare a dataset
Expand Down Expand Up @@ -163,7 +163,7 @@ Running 2 actual runs and 10 random runs
### Linear Models with `coef_` Attribute

```python
# Import the function
# import the package
import target_permutation_importances as tpi

# Prepare a dataset
Expand Down Expand Up @@ -214,7 +214,7 @@ Outputs:
### With `sklearn.multioutput`

```python
# Import the function
# import the package
import target_permutation_importances as tpi

# Prepare a dataset
Expand Down Expand Up @@ -328,11 +328,12 @@ Read the followings for details:
`TargetPermutationImportancesWrapper` follows scikit-learn interfaces and support scikit-learn feature selection method such as `SelectFromModel`:

```python
# Import the function
# Import the package
import target_permutation_importances as tpi

# Prepare a dataset
import pandas as pd
import numpy as np
from sklearn.datasets import load_breast_cancer

# Models
Expand Down Expand Up @@ -372,9 +373,26 @@ selector = SelectFromModel(
).fit(Xpd, data.target)
selected_x = selector.transform(Xpd)
print(selected_x.shape)
print(selector.get_feature_names_out())
```
Fork above code from [Kaggle](https://www.kaggle.com/code/kingychiu/target-permutation-importances-basic-usage/notebook).

Outputs:
```
Running 2 actual runs and 10 random runs
100%|██████████| 2/2 [00:01<00:00, 1.80it/s]
100%|██████████| 10/10 [00:06<00:00, 1.55it/s]
feature importance
22 worst perimeter 0.151953
27 worst concave points 0.124407
20 worst radius 0.119090
7 mean concave points 0.098747
23 worst area 0.096943
(569, 5)
['mean concave points' 'worst radius' 'worst perimeter' 'worst area'
'worst concave points']
```

---

## Feature Selection Examples
Expand Down
26 changes: 22 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ beartype = "^0.14.1"
### Tree Models with `feature_importances_` Attribute

```python
# Import the function
# import the package
import target_permutation_importances as tpi

# Prepare a dataset
Expand Down Expand Up @@ -163,7 +163,7 @@ Running 2 actual runs and 10 random runs
### Linear Models with `coef_` Attribute

```python
# Import the function
# import the package
import target_permutation_importances as tpi

# Prepare a dataset
Expand Down Expand Up @@ -214,7 +214,7 @@ Outputs:
### With `sklearn.multioutput`

```python
# Import the function
# import the package
import target_permutation_importances as tpi

# Prepare a dataset
Expand Down Expand Up @@ -328,11 +328,12 @@ Read the followings for details:
`TargetPermutationImportancesWrapper` follows scikit-learn interfaces and support scikit-learn feature selection method such as `SelectFromModel`:

```python
# Import the function
# Import the package
import target_permutation_importances as tpi

# Prepare a dataset
import pandas as pd
import numpy as np
from sklearn.datasets import load_breast_cancer

# Models
Expand Down Expand Up @@ -372,9 +373,26 @@ selector = SelectFromModel(
).fit(Xpd, data.target)
selected_x = selector.transform(Xpd)
print(selected_x.shape)
print(selector.get_feature_names_out())
```
Fork above code from [Kaggle](https://www.kaggle.com/code/kingychiu/target-permutation-importances-basic-usage/notebook).

Outputs:
```
Running 2 actual runs and 10 random runs
100%|██████████| 2/2 [00:01<00:00, 1.80it/s]
100%|██████████| 10/10 [00:06<00:00, 1.55it/s]
feature importance
22 worst perimeter 0.151953
27 worst concave points 0.124407
20 worst radius 0.119090
7 mean concave points 0.098747
23 worst area 0.096943
(569, 5)
['mean concave points' 'worst radius' 'worst perimeter' 'worst area'
'worst concave points']
```

---

## Feature Selection Examples
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "target-permutation-importances"
version = "1.0.19a1"
version = "1.0.19"
description = "Compute (Target) Permutation Importances of a machine learning model"
authors = [{name = "Anthony Chiu", email = "kingychiu@gmail.com"}]
maintainers = [{name = "Anthony Chiu", email = "kingychiu@gmail.com"}]
Expand All @@ -25,7 +25,7 @@ classifiers = [

[tool.poetry]
name = "target-permutation-importances"
version = "1.0.19a1"
version = "1.0.19"
description = "Compute (Target) Permutation Importances of a machine learning model"
authors = ["Anthony Chiu <kingychiu@gmail.com>"]
maintainers = ["Anthony Chiu <kingychiu@gmail.com>"]
Expand Down
2 changes: 1 addition & 1 deletion target_permutation_importances/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def compute(
Example:
```python
# Import the function
# import the package
import target_permutation_importances as tpi
# Prepare a dataset
Expand Down
4 changes: 3 additions & 1 deletion target_permutation_importances/sklearn_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ def __init__(
Example:
```python
# Import the function
# Import the package
import target_permutation_importances as tpi
# Prepare a dataset
import pandas as pd
import numpy as np
from sklearn.datasets import load_breast_cancer
# Models
Expand Down Expand Up @@ -85,6 +86,7 @@ def __init__(
).fit(Xpd, data.target)
selected_x = selector.transform(Xpd)
print(selected_x.shape)
print(selector.get_feature_names_out())
```
"""
self.model_cls = model_cls
Expand Down

0 comments on commit f7bc8f6

Please sign in to comment.