diff --git a/1.py b/1.py new file mode 100644 index 0000000..eecf7d7 --- /dev/null +++ b/1.py @@ -0,0 +1,25 @@ +from sklearn.datasets import load_iris +from sklearn.tree import DecisionTreeClassifier +from sklearn.model_selection import train_test_split +from sklearn import metrics + +# Load the Iris dataset (or you can use your own dataset) +iris = load_iris() +X = iris.data +y = iris.target + +# Split the dataset into training and testing sets +X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) + +# Create an instance of the DecisionTreeClassifier +clf = DecisionTreeClassifier() + +# Train the decision tree classifier +clf.fit(X_train, y_train) + +# Make predictions on the testing set +y_pred = clf.predict(X_test) + +# Evaluate the accuracy of the model +accuracy = metrics.accuracy_score(y_test, y_pred) +print("Accuracy:", accuracy) \ No newline at end of file