<jupyter_start><jupyter_text>GINI<jupyter_code>clf_gini = DecisionTreeClassifier(criterion = "gini", random_state = 100, max_depth=3, min_samples_leaf=5)
clf_gini.fit(X_train, y_train)
#with open("./gini.dot", 'w') as gini_dot_file :
    #tree.export_graphviz(clf_gini, out_file = gini_dot_file)
    
graph_gini = Source( tree.export_graphviz(clf_gini, out_file=None))
gini_png = graph_gini.pipe(format='png')
with open('gini.png','wb') as f:
    f.write(gini_png)
plt.figure(figsize=(25,10))
img=mpimg.imread('gini.png')
imgplot = plt.imshow(img)
plt.show()
y_pred_gini = clf_gini.predict(X_test)
gini_acc = accuracy_score(y_test,y_pred_gini)
print('Prediction accuracy with gini is {}'.format(gini_acc))<jupyter_output>Prediction accuracy with gini is 0.7340425531914894<jupyter_text>Information Gain<jupyter_code>clf_entropy = DecisionTreeClassifier(criterion = "entropy", random_state = 100,
 max_depth=3, min_samples_leaf=5)
clf_entropy.fit(X_train, y_train)
#with open("./entropy.dot", 'w') as entropy_dot_file :
    #tree.export_graphviz(clf_entropy, out_file = entropy_dot_file)

graph_entropy = Source( tree.export_graphviz(clf_entropy, out_file=None))
entropy_png = graph_entropy.pipe(format='png')
with open('entropy.png','wb') as f:
    f.write(entropy_png)
plt.figure(figsize=(25,10))
img=mpimg.imread('entropy.png')
imgplot = plt.imshow(img)
plt.show()
y_pred_entropy = clf_entropy.predict(X_test)
entropy_acc = accuracy_score(y_test,y_pred_entropy)
print('Prediction accuracy with information gain is {}'.format(entropy_acc))<jupyter_output>Prediction accuracy with information gain is 0.7074468085106383
{'fraction_non_alphanumeric': 0.13218035824583077, 'fraction_numerical': 0.03211859172328598, 'mean_word_length': 8.257142857142858, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '66120', 'license': 'MIT', 'n_tokens_mistral': 685, 'n_tokens_neox': 648, 'n_words': 98, 'path': '2_DecisionTree/Scikit_DecisionTree.ipynb', 'repo_name': 'ts-huyao/AI-Club', 'size': '1619'}