<jupyter_start><jupyter_text>Multilayer Perceptron<jupyter_code>mlpc = MLPClassifier(solver='lbfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1)
mlpc.fit(data_train_pca, labels_train)
mlpc_pred = mlpc.predict(data_test_pca)
mlpc_proba = mlpc.predict_proba(data_test_pca)
unique_elements, counts_elements = np.unique(mlpc_pred, return_counts=True)
print("Frequency of unique values of the said array:")
print(np.asarray((unique_elements, counts_elements)))
mlpc_accuracy = accuracy_score(labels_test, mlpc_pred)
mlpc_precision = precision_score(labels_test, mlpc_pred, average='macro')
mlpc_recall = recall_score(labels_test, mlpc_pred, average='macro')
mlpc_f1 = f1_score(labels_test, mlpc_pred, average='macro')
mlpc_cm = confusion_matrix(labels_test, mlpc_pred)

print("Accuracy is {}%".format(mlpc_accuracy * 100))
print("Precision is {}%".format(mlpc_precision * 100))
print("Recall is {}%".format(mlpc_recall * 100))
print("F-1 is {}%".format(mlpc_f1 * 100))
print(mlpc_cm)
p, r, t = precision_recall_curve(labels_train, mlpc.predict_proba(data_train_pca)[:,1])
plt.plot(t,r[1:])
plt.plot(t,p[1:])
mlpcp_accuracy = accuracy_score(labels_test, mlpc_proba[:,1] > 0.19)
mlpcp_precision = precision_score(labels_test, mlpc_proba[:,1] > 0.19, average='macro')
mlpcp_recall = recall_score(labels_test, mlpc_proba[:,1] > 0.19, average='macro')
mlpcp_f1 = f1_score(labels_test, mlpc_proba[:,1] > 0.19, average='macro')
mlpcp_cm = confusion_matrix(labels_test, mlpc_proba[:,1] > 0.19)

print("Accuracy is {}%".format(mlpcp_accuracy * 100))
print("Precision is {}%".format(mlpcp_precision * 100))
print("Recall is {}%".format(mlpcp_recall * 100))
print("F-1 is {}%".format(mlpcp_f1 * 100))
print(mlpcp_cm)<jupyter_output>Accuracy is 83.64622486316188%
Precision is 63.91167414314777%
Recall is 63.05678030400398%
F-1 is 63.4577661448174%
[[79225  7723]
 [ 8680  4673]]<jupyter_text>Random Forest Classifier<jupyter_code>rfc = RandomForestClassifier(n_estimators=100, max_depth=5, random_state=0)
rfc.fit(data_train_pca, labels_train)
rfc_pred = rfc.predict(data_test_pca)
rfc_proba = rfc.predict_proba(data_test_pca)
unique_elements, counts_elements = np.unique(rfc_pred, return_counts=True)
print("Frequency of unique values of the said array:")
print(np.asarray((unique_elements, counts_elements)))
rfc_accuracy = accuracy_score(labels_test, rfc_pred)
rfc_precision = precision_score(labels_test, rfc_pred, average='macro')
rfc_recall = recall_score(labels_test, rfc_pred, average='macro')
rfc_f1 = f1_score(labels_test, rfc_pred, average='macro')
rfc_cm = confusion_matrix(labels_test, rfc_pred)

print("Accuracy is {}%".format(rfc_accuracy * 100))
print("Precision is {}%".format(rfc_precision * 100))
print("Recall is {}%".format(rfc_recall * 100))
print("F-1 is {}%".format(rfc_f1 * 100))
print(rfc_cm)
p, r, t = precision_recall_curve(labels_train, rfc.predict_proba(data_train_pca)[:,1])
plt.plot(t,r[1:])
plt.plot(t,p[1:])
rfcp_accuracy = accuracy_score(labels_test, rfc_proba[:,1] > 0.18)
rfcp_precision = precision_score(labels_test, rfc_proba[:,1] > 0.18, average='macro')
rfcp_recall = recall_score(labels_test, rfc_proba[:,1] > 0.18, average='macro')
rfcp_f1 = f1_score(labels_test, rfc_proba[:,1] > 0.18, average='macro')
rfcp_cm = confusion_matrix(labels_test, rfc_proba[:,1] > 0.18)

print("Accuracy is {}%".format(rfcp_accuracy * 100))
print("Precision is {}%".format(rfcp_precision * 100))
print("Recall is {}%".format(rfcp_recall * 100))
print("F-1 is {}%".format(rfcp_f1 * 100))
print(rfcp_cm)<jupyter_output>Accuracy is 82.97025951884827%
Precision is 63.25464169097397%
Recall is 63.418044763189464%
F-1 is 63.335327300201016%
[[78310  8638]
 [ 8443  4910]]<jupyter_text>Logistic Regression<jupyter_code>lrc = LogisticRegression(solver='lbfgs')
lrc.fit(data_train_pca, labels_train)
lrc_pred = lrc.predict(data_test_pca)
lrc_proba = lrc.predict_proba(data_test_pca)
unique_elements, counts_elements = np.unique(lrc_pred, return_counts=True)
print("Frequency of unique values of the said array:")
print(np.asarray((unique_elements, counts_elements)))
lrc_accuracy = accuracy_score(labels_test, lrc_pred)
lrc_precision = precision_score(labels_test, lrc_pred, average='macro')
lrc_recall = recall_score(labels_test, lrc_pred, average='macro')
lrc_f1 = f1_score(labels_test, lrc_pred, average='macro')
lrc_cm = confusion_matrix(labels_test, lrc_pred)

print("Accuracy is {}%".format(lrc_accuracy * 100))
print("Precision is {}%".format(lrc_precision * 100))
print("Recall is {}%".format(lrc_recall * 100))
print("F-1 is {}%".format(lrc_f1 * 100))
print(lrc_cm)
p, r, t = precision_recall_curve(labels_train, lrc.predict_proba(data_train_pca)[:,1])
plt.plot(t,r[1:])
plt.plot(t,p[1:])
lrcp_accuracy = accuracy_score(labels_test, lrc_proba[:,1] > 0.25)
lrcp_precision = precision_score(labels_test, lrc_proba[:,1] > 0.25, average='macro')
lrcp_recall = recall_score(labels_test, lrc_proba[:,1] > 0.25, average='macro')
lrcp_f1 = f1_score(labels_test, lrc_proba[:,1] > 0.25, average='macro')
lrcp_cm = confusion_matrix(labels_test, lrc_proba[:,1] > 0.25)

print("Accuracy is {}%".format(lrcp_accuracy * 100))
print("Precision is {}%".format(lrcp_precision * 100))
print("Recall is {}%".format(lrcp_recall * 100))
print("F-1 is {}%".format(lrcp_f1 * 100))
print(lrcp_cm)<jupyter_output>Accuracy is 83.9572885614301%
Precision is 64.27362362179683%
Recall is 62.91608641228058%
F-1 is 63.529886395260846%
[[79638  7310]
 [ 8781  4572]]
{'fraction_non_alphanumeric': 0.1532258064516129, 'fraction_numerical': 0.07734604105571848, 'mean_word_length': 8.88586956521739, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 25, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '292152', 'license': 'MIT', 'n_tokens_mistral': 2527, 'n_tokens_neox': 2212, 'n_words': 365, 'path': 'Work_Phase2.ipynb', 'repo_name': 'EBarbara/analise-eleicoes', 'size': '5456'}