|
54 | 54 | "# Train the classifier\n", |
55 | 55 | "khc.fit(X_train, y_train)\n", |
56 | 56 | "\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", |
65 | 57 | "# Predict the classes on the test dataset\n", |
66 | 58 | "y_test_pred = khc.predict(X_test)\n", |
67 | 59 | "print(\"Predicted classes (first 10):\")\n", |
|
198 | 190 | "# Train the classifier\n", |
199 | 191 | "khc.fit(X_train, y_train)\n", |
200 | 192 | "\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", |
209 | 193 | "# Predict the classes on the test dataset\n", |
210 | 194 | "y_test_pred = khc.predict(X_test)\n", |
211 | 195 | "print(\"Predicted classes (first 10):\")\n", |
|
345 | 329 | "khc = KhiopsClassifier(n_trees=0)\n", |
346 | 330 | "khc.fit(X_train, y_train)\n", |
347 | 331 | "\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", |
356 | 332 | "# Predict the class on the test dataset\n", |
357 | 333 | "y_test_pred = khc.predict(X_test)\n", |
358 | 334 | "print(\"Predicted classes (first 10):\")\n", |
|
629 | 605 | "# Train the regressor\n", |
630 | 606 | "khr.fit(X_train, y_train)\n", |
631 | 607 | "\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", |
640 | 608 | "# Predict the values on the test dataset\n", |
641 | 609 | "y_test_pred = khr.predict(X_test)\n", |
642 | 610 | "print(\"Predicted values for 'age' (first 10):\")\n", |
|
796 | 764 | "khe = KhiopsEncoder(n_features=10)\n", |
797 | 765 | "khe.fit(X, y)\n", |
798 | 766 | "\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", |
806 | 767 | "# Transform the train dataset\n", |
807 | 768 | "print(\"Encoded feature names:\")\n", |
808 | 769 | "print(khe.feature_names_out_)\n", |
|
0 commit comments