<jupyter_start><jupyter_text>Decision Tree Classifier<jupyter_code>dt_model = DecisionTreeClassifier(criterion = 'gini' )
dt_model.fit(X_train, train_labels)
from sklearn import tree

train_char_label = ['No', 'Yes']
HR_Tree_File = open('d:\hr_tree.dot','w')
dot_data = tree.export_graphviz(dt_model, out_file=HR_Tree_File, feature_names = list(X_train), class_names = list(train_char_label))

HR_Tree_File.close()
from sklearn.model_selection import GridSearchCV

param_grid = {
    'max_depth': [7, 8, 9, 10],
    'min_samples_leaf': [15, 20, 25],
    'min_samples_split': [45, 60, 75]
}

dt_model = DecisionTreeClassifier()

grid_search = GridSearchCV(estimator = dt_model, param_grid = param_grid, cv = 3)
grid_search.fit(X_train, train_labels)
grid_search.best_params_
best_grid = grid_search.best_estimator_
ytrain_predict = best_grid.predict(X_train)
ytest_predict = best_grid.predict(X_test)
from sklearn.metrics import classification_report
print(classification_report(train_labels,ytrain_predict))
print(classification_report(test_labels,ytest_predict))<jupyter_output><empty_output><jupyter_text>Random Forest Classifier<jupyter_code>from sklearn.model_selection import GridSearchCV

param_grid = {
    'max_depth': [7, 8],
    'max_features': [11, 12, 13],
    'min_samples_leaf': [20, 25],
    'min_samples_split': [60, 75],
    'n_estimators': [101, 301]
}

rfcl = RandomForestClassifier()

grid_search = GridSearchCV(estimator = rfcl, param_grid = param_grid, cv = 3)


grid_search.fit(X_train, train_labels)
grid_search.best_params_
best_grid = grid_search.best_estimator_
ytrain_predict = best_grid.predict(X_train)
ytest_predict = best_grid.predict(X_test)
print(classification_report(train_labels,ytrain_predict))
print(classification_report(test_labels,ytest_predict))<jupyter_output><empty_output><jupyter_text>MLP Classifier (Artificial Neural Network)<jupyter_code>from sklearn.preprocessing import StandardScaler 
sc = StandardScaler() 
X_trains = sc.fit_transform(X_train) 
X_tests = sc.transform (X_test)
param_grid = {
    'hidden_layer_sizes': [(100,100,100)],
    'activation': ['logistic', 'relu'],
    'solver': ['sgd', 'adam'],
    'tol': [0.1,0.01],
    'max_iter' : [10000]
}

rfcl = MLPClassifier()

grid_search = GridSearchCV(estimator = rfcl, param_grid = param_grid, cv = 3)
grid_search.fit(X_trains, train_labels)
grid_search.best_params_
best_grid = grid_search.best_estimator_
ytrain_predict = best_grid.predict(X_trains)
ytest_predict = best_grid.predict(X_tests)
print(classification_report(train_labels,ytrain_predict))
print(classification_report(test_labels,ytest_predict))<jupyter_output>precision    recall  f1-score   support

           0       0.95      0.98      0.96       729
           1       0.87      0.75      0.81       153

    accuracy                           0.94       882
   macro avg       0.91      0.86      0.88       882
weighted avg       0.94      0.94      0.94       882
{'fraction_non_alphanumeric': 0.10964019008825526, 'fraction_numerical': 0.04005431093007468, 'mean_word_length': 4.965587044534413, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '211457', 'license': 'MIT', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1051, 'n_words': 183, 'path': 'M4 Data Mining/W4 Artificial Nural Network/End to End Case Study.ipynb', 'repo_name': 'fborrasumh/greatlearning-pgp-dsba', 'size': '2946'}