MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / main

Function main

machine_learning/xgboost_classifier.py:43–72  ·  view source on GitHub ↗

Url for the algorithm: https://xgboost.readthedocs.io/en/stable/ Iris type dataset is used to demonstrate algorithm.

()

Source from the content-addressed store, hash-verified

41
42
43def 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
75if __name__ == "__main__":

Callers 1

Calls 3

xgboostFunction · 0.90
showMethod · 0.80
data_handlingFunction · 0.70

Tested by

no test coverage detected