# introduction to scikit-learn

from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
import pandas as pd

iris = load_iris()
iris_data = iris.data
iris_label = iris.target
iris_df = pd.DataFrame(data=iris_data, columns=iris.feature_names)
iris_df['label'] = iris.target
iris_df.head(5)

X_train, X_test, y_train, y_test = train_test_split(iris_data, iris_label, test_size=0.2, random_state=11)

dt_clf = DecisionTreeClassifier(random_state=11)
dt_clf.fit(X_train, y_train)
pred = dt_clf.predict(X_test)

# computing the accuracy of this prediction model
from sklearn.metrics import accuracy_score
print('accuracy of this prediction: {0:.4f}'.format(accuracy_score(y_test, pred)))

a20dd77036fd789aa42c1ab382abff9f5a536bdc
<mask token>

<mask token>
iris_df.head(5)
<mask token>
dt_clf.fit(X_train, y_train)
<mask token>
print('accuracy of this prediction: {0:.4f}'.format(accuracy_score(y_test,
    pred)))

<mask token>
iris = load_iris()
iris_data = iris.data
iris_label = iris.target
iris_df = pd.DataFrame(data=iris_data, columns=iris.feature_names)
iris_df['label'] = iris.target
iris_df.head(5)
X_train, X_test, y_train, y_test = train_test_split(iris_data, iris_label,
    test_size=0.2, random_state=11)
dt_clf = DecisionTreeClassifier(random_state=11)
dt_clf.fit(X_train, y_train)
pred = dt_clf.predict(X_test)
<mask token>
print('accuracy of this prediction: {0:.4f}'.format(accuracy_score(y_test,
    pred)))

from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
import pandas as pd
iris = load_iris()
iris_data = iris.data
iris_label = iris.target
iris_df = pd.DataFrame(data=iris_data, columns=iris.feature_names)
iris_df['label'] = iris.target
iris_df.head(5)
X_train, X_test, y_train, y_test = train_test_split(iris_data, iris_label,
    test_size=0.2, random_state=11)
dt_clf = DecisionTreeClassifier(random_state=11)
dt_clf.fit(X_train, y_train)
pred = dt_clf.predict(X_test)
from sklearn.metrics import accuracy_score
print('accuracy of this prediction: {0:.4f}'.format(accuracy_score(y_test,
    pred)))

# introduction to scikit-learn

from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
import pandas as pd

iris = load_iris()
iris_data = iris.data
iris_label = iris.target
iris_df = pd.DataFrame(data=iris_data, columns=iris.feature_names)
iris_df['label'] = iris.target
iris_df.head(5)

X_train, X_test, y_train, y_test = train_test_split(iris_data, iris_label, test_size=0.2, random_state=11)

dt_clf = DecisionTreeClassifier(random_state=11)
dt_clf.fit(X_train, y_train)
pred = dt_clf.predict(X_test)

# computing the accuracy of this prediction model
from sklearn.metrics import accuracy_score
print('accuracy of this prediction: {0:.4f}'.format(accuracy_score(y_test, pred)))
