Skip to content

Commit b9a2fb9

Browse files
committed
Drop evaluated and used feature names and importances attributes
- the evaluated features characterize the analysis process, not the model itself - the used features characterize the model, but: - they are easily accessible through the `model_report_` attribute - they are not expected by the Scikit-learn ecosystem.
1 parent 4539884 commit b9a2fb9

File tree

5 files changed

+0
-353
lines changed

5 files changed

+0
-353
lines changed

doc/samples/samples_sklearn.rst

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ Samples
6868
# Train the classifier
6969
khc.fit(X_train, y_train)
7070
71-
# Show the feature importance info
72-
print(f"Features evaluated: {khc.n_features_evaluated_}")
73-
print(f"Features selected : {khc.n_features_used_}")
74-
print("Top 3 used features")
75-
for i, feature in enumerate(khc.feature_used_names_[:3]):
76-
print(f"{feature} - Importance: {khc.feature_used_importances_[i][2]}")
77-
print("---")
78-
7971
# Predict the classes on the test dataset
8072
y_test_pred = khc.predict(X_test)
8173
print("Predicted classes (first 10):")
@@ -186,14 +178,6 @@ Samples
186178
# Train the classifier
187179
khc.fit(X_train, y_train)
188180
189-
# Show the feature importance info
190-
print(f"Features evaluated: {khc.n_features_evaluated_}")
191-
print(f"Features selected : {khc.n_features_used_}")
192-
print("Top 3 used features")
193-
for i, feature in enumerate(khc.feature_used_names_[:3]):
194-
print(f"{feature} - Importance: {khc.feature_used_importances_[i][2]}")
195-
print("---")
196-
197181
# Predict the classes on the test dataset
198182
y_test_pred = khc.predict(X_test)
199183
print("Predicted classes (first 10):")
@@ -307,14 +291,6 @@ Samples
307291
khc = KhiopsClassifier(n_trees=0)
308292
khc.fit(X_train, y_train)
309293
310-
# Show the feature importance info
311-
print(f"Features evaluated: {khc.n_features_evaluated_}")
312-
print(f"Features selected : {khc.n_features_used_}")
313-
print("Top 3 used features")
314-
for i, feature in enumerate(khc.feature_used_names_[:3]):
315-
print(f"{feature} - Importance: {khc.feature_used_importances_[i][2]}")
316-
print("---")
317-
318294
# Predict the class on the test dataset
319295
y_test_pred = khc.predict(X_test)
320296
print("Predicted classes (first 10):")
@@ -539,14 +515,6 @@ Samples
539515
# Train the regressor
540516
khr.fit(X_train, y_train)
541517
542-
# Show the feature importance info
543-
print(f"Features evaluated: {khr.n_features_evaluated_}")
544-
print(f"Features selected : {khr.n_features_used_}")
545-
print("Top 3 used features")
546-
for i, feature in enumerate(khr.feature_used_names_[:3]):
547-
print(f"{feature} - Importance: {khr.feature_used_importances_[i][2]}")
548-
print("---")
549-
550518
# Predict the values on the test dataset
551519
y_test_pred = khr.predict(X_test)
552520
print("Predicted values for 'age' (first 10):")
@@ -667,13 +635,6 @@ Samples
667635
khe = KhiopsEncoder(n_features=10)
668636
khe.fit(X, y)
669637
670-
# Show the feature importance info
671-
print(f"Features evaluated: {khe.n_features_evaluated_}")
672-
print("Top 3 evaluated features")
673-
for i, feature in enumerate(khe.feature_evaluated_names_[:3]):
674-
print(f"{feature} - Level: {khe.feature_evaluated_importances_[i]}")
675-
print("---")
676-
677638
# Transform the train dataset
678639
print("Encoded feature names:")
679640
print(khe.feature_names_out_)

khiops/samples/samples_sklearn.ipynb

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@
5454
"# Train the classifier\n",
5555
"khc.fit(X_train, y_train)\n",
5656
"\n",
57-
"# Show the feature importance info\n",
58-
"print(f\"Features evaluated: {khc.n_features_evaluated_}\")\n",
59-
"print(f\"Features selected : {khc.n_features_used_}\")\n",
60-
"print(\"Top 3 used features\")\n",
61-
"for i, feature in enumerate(khc.feature_used_names_[:3]):\n",
62-
" print(f\"{feature} - Importance: {khc.feature_used_importances_[i][2]}\")\n",
63-
"print(\"---\")\n",
64-
"\n",
6557
"# Predict the classes on the test dataset\n",
6658
"y_test_pred = khc.predict(X_test)\n",
6759
"print(\"Predicted classes (first 10):\")\n",
@@ -198,14 +190,6 @@
198190
"# Train the classifier\n",
199191
"khc.fit(X_train, y_train)\n",
200192
"\n",
201-
"# Show the feature importance info\n",
202-
"print(f\"Features evaluated: {khc.n_features_evaluated_}\")\n",
203-
"print(f\"Features selected : {khc.n_features_used_}\")\n",
204-
"print(\"Top 3 used features\")\n",
205-
"for i, feature in enumerate(khc.feature_used_names_[:3]):\n",
206-
" print(f\"{feature} - Importance: {khc.feature_used_importances_[i][2]}\")\n",
207-
"print(\"---\")\n",
208-
"\n",
209193
"# Predict the classes on the test dataset\n",
210194
"y_test_pred = khc.predict(X_test)\n",
211195
"print(\"Predicted classes (first 10):\")\n",
@@ -345,14 +329,6 @@
345329
"khc = KhiopsClassifier(n_trees=0)\n",
346330
"khc.fit(X_train, y_train)\n",
347331
"\n",
348-
"# Show the feature importance info\n",
349-
"print(f\"Features evaluated: {khc.n_features_evaluated_}\")\n",
350-
"print(f\"Features selected : {khc.n_features_used_}\")\n",
351-
"print(\"Top 3 used features\")\n",
352-
"for i, feature in enumerate(khc.feature_used_names_[:3]):\n",
353-
" print(f\"{feature} - Importance: {khc.feature_used_importances_[i][2]}\")\n",
354-
"print(\"---\")\n",
355-
"\n",
356332
"# Predict the class on the test dataset\n",
357333
"y_test_pred = khc.predict(X_test)\n",
358334
"print(\"Predicted classes (first 10):\")\n",
@@ -629,14 +605,6 @@
629605
"# Train the regressor\n",
630606
"khr.fit(X_train, y_train)\n",
631607
"\n",
632-
"# Show the feature importance info\n",
633-
"print(f\"Features evaluated: {khr.n_features_evaluated_}\")\n",
634-
"print(f\"Features selected : {khr.n_features_used_}\")\n",
635-
"print(\"Top 3 used features\")\n",
636-
"for i, feature in enumerate(khr.feature_used_names_[:3]):\n",
637-
" print(f\"{feature} - Importance: {khr.feature_used_importances_[i][2]}\")\n",
638-
"print(\"---\")\n",
639-
"\n",
640608
"# Predict the values on the test dataset\n",
641609
"y_test_pred = khr.predict(X_test)\n",
642610
"print(\"Predicted values for 'age' (first 10):\")\n",
@@ -796,13 +764,6 @@
796764
"khe = KhiopsEncoder(n_features=10)\n",
797765
"khe.fit(X, y)\n",
798766
"\n",
799-
"# Show the feature importance info\n",
800-
"print(f\"Features evaluated: {khe.n_features_evaluated_}\")\n",
801-
"print(\"Top 3 evaluated features\")\n",
802-
"for i, feature in enumerate(khe.feature_evaluated_names_[:3]):\n",
803-
" print(f\"{feature} - Level: {khe.feature_evaluated_importances_[i]}\")\n",
804-
"print(\"---\")\n",
805-
"\n",
806767
"# Transform the train dataset\n",
807768
"print(\"Encoded feature names:\")\n",
808769
"print(khe.feature_names_out_)\n",

khiops/samples/samples_sklearn.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ def khiops_classifier():
5757
# Train the classifier
5858
khc.fit(X_train, y_train)
5959

60-
# Show the feature importance info
61-
print(f"Features evaluated: {khc.n_features_evaluated_}")
62-
print(f"Features selected : {khc.n_features_used_}")
63-
print("Top 3 used features")
64-
for i, feature in enumerate(khc.feature_used_names_[:3]):
65-
print(f"{feature} - Importance: {khc.feature_used_importances_[i][2]}")
66-
print("---")
67-
6860
# Predict the classes on the test dataset
6961
y_test_pred = khc.predict(X_test)
7062
print("Predicted classes (first 10):")
@@ -181,14 +173,6 @@ def khiops_classifier_text():
181173
# Train the classifier
182174
khc.fit(X_train, y_train)
183175

184-
# Show the feature importance info
185-
print(f"Features evaluated: {khc.n_features_evaluated_}")
186-
print(f"Features selected : {khc.n_features_used_}")
187-
print("Top 3 used features")
188-
for i, feature in enumerate(khc.feature_used_names_[:3]):
189-
print(f"{feature} - Importance: {khc.feature_used_importances_[i][2]}")
190-
print("---")
191-
192176
# Predict the classes on the test dataset
193177
y_test_pred = khc.predict(X_test)
194178
print("Predicted classes (first 10):")
@@ -310,14 +294,6 @@ def khiops_classifier_multitable_snowflake():
310294
khc = KhiopsClassifier(n_trees=0)
311295
khc.fit(X_train, y_train)
312296

313-
# Show the feature importance info
314-
print(f"Features evaluated: {khc.n_features_evaluated_}")
315-
print(f"Features selected : {khc.n_features_used_}")
316-
print("Top 3 used features")
317-
for i, feature in enumerate(khc.feature_used_names_[:3]):
318-
print(f"{feature} - Importance: {khc.feature_used_importances_[i][2]}")
319-
print("---")
320-
321297
# Predict the class on the test dataset
322298
y_test_pred = khc.predict(X_test)
323299
print("Predicted classes (first 10):")
@@ -550,14 +526,6 @@ def khiops_regressor():
550526
# Train the regressor
551527
khr.fit(X_train, y_train)
552528

553-
# Show the feature importance info
554-
print(f"Features evaluated: {khr.n_features_evaluated_}")
555-
print(f"Features selected : {khr.n_features_used_}")
556-
print("Top 3 used features")
557-
for i, feature in enumerate(khr.feature_used_names_[:3]):
558-
print(f"{feature} - Importance: {khr.feature_used_importances_[i][2]}")
559-
print("---")
560-
561529
# Predict the values on the test dataset
562530
y_test_pred = khr.predict(X_test)
563531
print("Predicted values for 'age' (first 10):")
@@ -696,13 +664,6 @@ def khiops_encoder_multitable_snowflake():
696664
khe = KhiopsEncoder(n_features=10)
697665
khe.fit(X, y)
698666

699-
# Show the feature importance info
700-
print(f"Features evaluated: {khe.n_features_evaluated_}")
701-
print("Top 3 evaluated features")
702-
for i, feature in enumerate(khe.feature_evaluated_names_[:3]):
703-
print(f"{feature} - Level: {khe.feature_evaluated_importances_[i]}")
704-
print("---")
705-
706667
# Transform the train dataset
707668
print("Encoded feature names:")
708669
print(khe.feature_names_out_)

0 commit comments

Comments
 (0)