alt_dataset #1

Closed
s474137 wants to merge 7 commits from alt_dataset into tree_increase
Showing only changes of commit 6126010db1 - Show all commits

25
1.py Normal file
View File

@ -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)