<jupyter_start><jupyter_text>**Task-2**: Apply algorithm on digits dataset - One hot encoding of features and train test division 65% - 35%<jupyter_code>from sklearn import datasets
from sklearn.tree import DecisionTreeClassifier
import pandas as pd
import numpy as np
#Load dataset
digits = datasets.load_digits()
print(digits)
print(digits.data.shape)
print(digits.target.shape)
#import the necessary module
from sklearn.model_selection import train_test_split

X=digits.data
Y=digits.target
#split data set into train and test sets
X_train, X_test, y_train, y_test = train_test_split( 
    X, Y, test_size = 0.35, random_state = 46)
#Create a Decision Tree Classifier (using Gini)
clf_gini = DecisionTreeClassifier(criterion = "gini",
            random_state = 46,max_depth=7, min_samples_leaf=46)

clf_gini.fit(X_train, y_train)
# Predict the classes of test data
y_pred = clf_gini.predict(X_test)
print("Predicted values:")
print(y_pred)
# Model Accuracy
from sklearn import metrics
print("Confusion Matrix: ",
        metrics.confusion_matrix(y_test, y_pred))
print ("Accuracy : ",
    metrics.accuracy_score(y_test,y_pred)*100)
print("Report : ",
    metrics.classification_report(y_test, y_pred))<jupyter_output>Confusion Matrix:  [[42  0  0  0  0  0  0  0  0  2]
 [ 0 37  1  1  8  0  6  3  1  9]
 [ 1 20 37  5  1  0  5  1  2  1]
 [ 0  7  0 49  0  0  0  4  1  5]
 [ 4  3  1  0 36  0  8  9  1  0]
 [ 4  5  0  0  1 43  2  2  0 12]
 [ 0  3  0  0  0  0 49  0  0  0]
 [ 0  0  7  0  1  0  0 55  1  3]
 [ 0  8  2  5  0  0  0  4 26 12]
 [ 0  0  1  4  0  0  0  7  1 60]]
Accuracy :  68.99841017488076
Report :                precision    recall  f1-score   support

           0       0.82      0.95      0.88        44
           1       0.45      0.56      0.50        66
           2       0.76      0.51      0.61        73
           3       0.77      0.74      0.75        66
           4       0.77      0.58      0.66        62
           5       1.00      0.62      0.77        69
           6       0.70      0.94      0.80        52
           7       0.65      0.82      0.72        67
           8       0.79      0.46      0.58        57
           9       0.58      0.82      0.68        73

    accuracy  [...]
StarcoderdataJupyterStructuredCleanDedup