|
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", |
57 | 65 | "# Predict the classes on the test dataset\n", |
58 | 66 | "y_test_pred = khc.predict(X_test)\n", |
59 | 67 | "print(\"Predicted classes (first 10):\")\n", |
|
298 | 306 | "khc = KhiopsClassifier(n_trees=0)\n", |
299 | 307 | "khc.fit(X, y)\n", |
300 | 308 | "\n", |
| 309 | + "# Show the feature importance info\n", |
| 310 | + "print(f\"Features evaluated: {khc.n_features_evaluated_}\")\n", |
| 311 | + "print(f\"Features selected : {khc.n_features_used_}\")\n", |
| 312 | + "print(\"Top 3 used features\")\n", |
| 313 | + "for i, feature in enumerate(khc.feature_used_names_[:3]):\n", |
| 314 | + " print(f\"{feature} - Importance: {khc.feature_used_importances_[i][2]}\")\n", |
| 315 | + "print(\"---\")\n", |
| 316 | + "\n", |
301 | 317 | "# Predict the class on the test dataset\n", |
302 | 318 | "y_pred = khc.predict(X)\n", |
303 | 319 | "print(\"Predicted classes (first 10):\")\n", |
|
484 | 500 | "# Train the regressor\n", |
485 | 501 | "khr.fit(X_train, y_train)\n", |
486 | 502 | "\n", |
| 503 | + "# Show the feature importance info\n", |
| 504 | + "print(f\"Features evaluated: {khr.n_features_evaluated_}\")\n", |
| 505 | + "print(f\"Features selected : {khr.n_features_used_}\")\n", |
| 506 | + "print(\"Top 3 used features\")\n", |
| 507 | + "for i, feature in enumerate(khr.feature_used_names_[:3]):\n", |
| 508 | + " print(f\"{feature} - Importance: {khr.feature_used_importances_[i][2]}\")\n", |
| 509 | + "print(\"---\")\n", |
| 510 | + "\n", |
487 | 511 | "# Predict the values on the test dataset\n", |
488 | 512 | "y_test_pred = khr.predict(X_test)\n", |
489 | 513 | "print(\"Predicted values for 'age' (first 10):\")\n", |
|
664 | 688 | "khe = KhiopsEncoder(n_features=10)\n", |
665 | 689 | "khe.fit(X, y)\n", |
666 | 690 | "\n", |
| 691 | + "# Show the feature importance info\n", |
| 692 | + "print(f\"Features evaluated: {khe.n_features_evaluated_}\")\n", |
| 693 | + "print(\"Top 3 evaluated features\")\n", |
| 694 | + "for i, feature in enumerate(khe.feature_evaluated_names_[:3]):\n", |
| 695 | + " print(f\"{feature} - Level: {khe.feature_evaluated_importances_[i][0]}\")\n", |
| 696 | + "print(\"---\")\n", |
| 697 | + "\n", |
667 | 698 | "# Transform the train dataset\n", |
668 | 699 | "print(\"Encoded feature names:\")\n", |
669 | 700 | "print(khe.feature_names_out_)\n", |
|
0 commit comments