Url for the algorithm: https://xgboost.readthedocs.io/en/stable/ Iris type dataset is used to demonstrate algorithm.
()
| 41 | |
| 42 | |
| 43 | def main() -> None: |
| 44 | """ |
| 45 | Url for the algorithm: |
| 46 | https://xgboost.readthedocs.io/en/stable/ |
| 47 | Iris type dataset is used to demonstrate algorithm. |
| 48 | """ |
| 49 | |
| 50 | # Load Iris dataset |
| 51 | iris = load_iris() |
| 52 | features, targets = data_handling(iris) |
| 53 | x_train, x_test, y_train, y_test = train_test_split( |
| 54 | features, targets, test_size=0.25 |
| 55 | ) |
| 56 | |
| 57 | names = iris["target_names"] |
| 58 | |
| 59 | # Create an XGBoost Classifier from the training data |
| 60 | xgboost_classifier = xgboost(x_train, y_train) |
| 61 | |
| 62 | # Display the confusion matrix of the classifier with both training and test sets |
| 63 | ConfusionMatrixDisplay.from_estimator( |
| 64 | xgboost_classifier, |
| 65 | x_test, |
| 66 | y_test, |
| 67 | display_labels=names, |
| 68 | cmap="Blues", |
| 69 | normalize="true", |
| 70 | ) |
| 71 | plt.title("Normalized Confusion Matrix - IRIS Dataset") |
| 72 | plt.show() |
| 73 | |
| 74 | |
| 75 | if __name__ == "__main__": |
no test coverage detected