Skip to content

Commit

Permalink
Merge pull request #224 from KhiopsML/dev
Browse files Browse the repository at this point in the history
Release 10.2.2.4
  • Loading branch information
folmos-at-orange authored Aug 5, 2024
2 parents 7da3e71 + 5c93842 commit 427c1d8
Show file tree
Hide file tree
Showing 6 changed files with 569 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
- Example: 10.2.1.4 is the 5th version that supports khiops 10.2.1.
- Internals: Changes in *Internals* sections are unlikely to be of interest for data scientists.

## 10.2.2.4 - 2024-08-05

## Added
- (`sklearn`) Sklearn's attributes for supervised estimators.

## 10.2.2.3 - 2024-08-02

### Fixed
Expand Down
31 changes: 31 additions & 0 deletions doc/samples/samples_sklearn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ Samples
# Train the classifier
khc.fit(X_train, y_train)
# Show the feature importance info
print(f"Features evaluated: {khc.n_features_evaluated_}")
print(f"Features selected : {khc.n_features_used_}")
print("Top 3 used features")
for i, feature in enumerate(khc.feature_used_names_[:3]):
print(f"{feature} - Importance: {khc.feature_used_importances_[i][2]}")
print("---")
# Predict the classes on the test dataset
y_test_pred = khc.predict(X_test)
print("Predicted classes (first 10):")
Expand Down Expand Up @@ -273,6 +281,14 @@ Samples
khc = KhiopsClassifier(n_trees=0)
khc.fit(X, y)
# Show the feature importance info
print(f"Features evaluated: {khc.n_features_evaluated_}")
print(f"Features selected : {khc.n_features_used_}")
print("Top 3 used features")
for i, feature in enumerate(khc.feature_used_names_[:3]):
print(f"{feature} - Importance: {khc.feature_used_importances_[i][2]}")
print("---")
# Predict the class on the test dataset
y_pred = khc.predict(X)
print("Predicted classes (first 10):")
Expand Down Expand Up @@ -420,6 +436,14 @@ Samples
# Train the regressor
khr.fit(X_train, y_train)
# Show the feature importance info
print(f"Features evaluated: {khr.n_features_evaluated_}")
print(f"Features selected : {khr.n_features_used_}")
print("Top 3 used features")
for i, feature in enumerate(khr.feature_used_names_[:3]):
print(f"{feature} - Importance: {khr.feature_used_importances_[i][2]}")
print("---")
# Predict the values on the test dataset
y_test_pred = khr.predict(X_test)
print("Predicted values for 'age' (first 10):")
Expand Down Expand Up @@ -561,6 +585,13 @@ Samples
khe = KhiopsEncoder(n_features=10)
khe.fit(X, y)
# Show the feature importance info
print(f"Features evaluated: {khe.n_features_evaluated_}")
print("Top 3 evaluated features")
for i, feature in enumerate(khe.feature_evaluated_names_[:3]):
print(f"{feature} - Level: {khe.feature_evaluated_importances_[i][0]}")
print("---")
# Transform the train dataset
print("Encoded feature names:")
print(khe.feature_names_out_)
Expand Down
31 changes: 31 additions & 0 deletions khiops/samples/samples_sklearn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
"# Train the classifier\n",
"khc.fit(X_train, y_train)\n",
"\n",
"# Show the feature importance info\n",
"print(f\"Features evaluated: {khc.n_features_evaluated_}\")\n",
"print(f\"Features selected : {khc.n_features_used_}\")\n",
"print(\"Top 3 used features\")\n",
"for i, feature in enumerate(khc.feature_used_names_[:3]):\n",
" print(f\"{feature} - Importance: {khc.feature_used_importances_[i][2]}\")\n",
"print(\"---\")\n",
"\n",
"# Predict the classes on the test dataset\n",
"y_test_pred = khc.predict(X_test)\n",
"print(\"Predicted classes (first 10):\")\n",
Expand Down Expand Up @@ -298,6 +306,14 @@
"khc = KhiopsClassifier(n_trees=0)\n",
"khc.fit(X, y)\n",
"\n",
"# Show the feature importance info\n",
"print(f\"Features evaluated: {khc.n_features_evaluated_}\")\n",
"print(f\"Features selected : {khc.n_features_used_}\")\n",
"print(\"Top 3 used features\")\n",
"for i, feature in enumerate(khc.feature_used_names_[:3]):\n",
" print(f\"{feature} - Importance: {khc.feature_used_importances_[i][2]}\")\n",
"print(\"---\")\n",
"\n",
"# Predict the class on the test dataset\n",
"y_pred = khc.predict(X)\n",
"print(\"Predicted classes (first 10):\")\n",
Expand Down Expand Up @@ -484,6 +500,14 @@
"# Train the regressor\n",
"khr.fit(X_train, y_train)\n",
"\n",
"# Show the feature importance info\n",
"print(f\"Features evaluated: {khr.n_features_evaluated_}\")\n",
"print(f\"Features selected : {khr.n_features_used_}\")\n",
"print(\"Top 3 used features\")\n",
"for i, feature in enumerate(khr.feature_used_names_[:3]):\n",
" print(f\"{feature} - Importance: {khr.feature_used_importances_[i][2]}\")\n",
"print(\"---\")\n",
"\n",
"# Predict the values on the test dataset\n",
"y_test_pred = khr.predict(X_test)\n",
"print(\"Predicted values for 'age' (first 10):\")\n",
Expand Down Expand Up @@ -664,6 +688,13 @@
"khe = KhiopsEncoder(n_features=10)\n",
"khe.fit(X, y)\n",
"\n",
"# Show the feature importance info\n",
"print(f\"Features evaluated: {khe.n_features_evaluated_}\")\n",
"print(\"Top 3 evaluated features\")\n",
"for i, feature in enumerate(khe.feature_evaluated_names_[:3]):\n",
" print(f\"{feature} - Level: {khe.feature_evaluated_importances_[i][0]}\")\n",
"print(\"---\")\n",
"\n",
"# Transform the train dataset\n",
"print(\"Encoded feature names:\")\n",
"print(khe.feature_names_out_)\n",
Expand Down
31 changes: 31 additions & 0 deletions khiops/samples/samples_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ def khiops_classifier():
# Train the classifier
khc.fit(X_train, y_train)

# Show the feature importance info
print(f"Features evaluated: {khc.n_features_evaluated_}")
print(f"Features selected : {khc.n_features_used_}")
print("Top 3 used features")
for i, feature in enumerate(khc.feature_used_names_[:3]):
print(f"{feature} - Importance: {khc.feature_used_importances_[i][2]}")
print("---")

# Predict the classes on the test dataset
y_test_pred = khc.predict(X_test)
print("Predicted classes (first 10):")
Expand Down Expand Up @@ -273,6 +281,14 @@ def khiops_classifier_multitable_snowflake():
khc = KhiopsClassifier(n_trees=0)
khc.fit(X, y)

# Show the feature importance info
print(f"Features evaluated: {khc.n_features_evaluated_}")
print(f"Features selected : {khc.n_features_used_}")
print("Top 3 used features")
for i, feature in enumerate(khc.feature_used_names_[:3]):
print(f"{feature} - Importance: {khc.feature_used_importances_[i][2]}")
print("---")

# Predict the class on the test dataset
y_pred = khc.predict(X)
print("Predicted classes (first 10):")
Expand Down Expand Up @@ -423,6 +439,14 @@ def khiops_regressor():
# Train the regressor
khr.fit(X_train, y_train)

# Show the feature importance info
print(f"Features evaluated: {khr.n_features_evaluated_}")
print(f"Features selected : {khr.n_features_used_}")
print("Top 3 used features")
for i, feature in enumerate(khr.feature_used_names_[:3]):
print(f"{feature} - Importance: {khr.feature_used_importances_[i][2]}")
print("---")

# Predict the values on the test dataset
y_test_pred = khr.predict(X_test)
print("Predicted values for 'age' (first 10):")
Expand Down Expand Up @@ -581,6 +605,13 @@ def khiops_encoder_multitable_snowflake():
khe = KhiopsEncoder(n_features=10)
khe.fit(X, y)

# Show the feature importance info
print(f"Features evaluated: {khe.n_features_evaluated_}")
print("Top 3 evaluated features")
for i, feature in enumerate(khe.feature_evaluated_names_[:3]):
print(f"{feature} - Level: {khe.feature_evaluated_importances_[i][0]}")
print("---")

# Transform the train dataset
print("Encoded feature names:")
print(khe.feature_names_out_)
Expand Down
Loading

0 comments on commit 427c1d8

Please sign in to comment.