<jupyter_start><jupyter_text>Baseline Model<jupyter_code>rf_model = RandomForestClassifier(n_estimators=1000, random_state=123).fit(X_otrain, y_otrain)
filename = './models/models_new/baseline_model_rf.sav'
pickle.dump(rf_model, open(filename, 'wb'))
model = pickle.load(open(filename, 'rb'))
y_pred = model.predict(X_test)
class_count(y_test, y_pred)
cm_plot(y_test, y_pred)
pr_auc(X_test, y_test, 5)
# do grid search cv
tic = time.clock()
rfc = RandomForestClassifier(random_state=123)
param_grid = { 
    'n_estimators': [200, 500, 1000],
    'max_features': ['auto', 'sqrt', 'log2'],
    'max_depth' : [4,5,6,7,8],
    'criterion' :['gini', 'entropy']
}
CV_rfc = GridSearchCV(estimator=rfc, param_grid=param_grid, cv=5)
CV_rfc.fit(X_train, y_train)
print(CV_rfc.best_params_)
toc = time.clock()
duration = toc - tic
print(duration)
rf_model = RandomForestClassifier(n_estimators=1000, random_state=123).fit(X_otrain, y_otrain)
filename = './models/models_new/baseline_model_rf_tuned.sav'
pickle.dump(rf_model, open(filename, 'wb'))
model = pickle.load(open(filename, 'rb'))
y_pred = model.predict(X_test)
class_count(y_test, y_pred)
cm_plot(y_test, y_pred)
pr_auc(X_test, y_test, 5)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15378289473684212, 'fraction_numerical': 0.029605263157894735, 'mean_word_length': 7.883211678832117, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '595444', 'license': 'MIT', 'n_tokens_mistral': 539, 'n_tokens_neox': 501, 'n_words': 78, 'path': 'Final Model Training.ipynb', 'repo_name': 'gracengu/multinomial_classification', 'size': '1216'}