<jupyter_start><jupyter_text>Logistic Regression<jupyter_code>logreg = LogisticRegression()
logreg.fit(X_train, Y_train)
#Y_pred = logreg.predict(X_test)
acc_log = round(logreg.score(X_validate, Y_validate) * 100, 2)
print acc_log
print round(logreg.score(X_train, Y_train) * 100, 2)
#print cross_val_score(logreg, X_validate, Y_validate)
# Perceptron

perceptron = Perceptron()
perceptron.fit(X_train, Y_train)
#Y_pred = perceptron.predict(X_test)
acc_perceptron = round(perceptron.score(X_validate, Y_validate) * 100, 2)
print acc_perceptron
print round(perceptron.score(X_train, Y_train) * 100, 2)
#print cross_val_score(perceptron, X_validate, Y_validate)
# Stochastic Gradient Descent

sgd = SGDClassifier()
sgd.fit(X_train, Y_train)
#Y_pred = sgd.predict(X_test)
acc_sgd = round(sgd.score(X_validate, Y_validate) * 100, 2)
print acc_sgd
print round(sgd.score(X_train, Y_train) * 100, 2)

#print cross_val_score(sgd, X_validate, Y_validate)
# Gaussian Naive Bayes

gaussian = GaussianNB()
gaussian.fit(X_train, Y_train)
#Y_pred = gaussian.predict(X_test)
acc_gaussian = round(gaussian.score(X_validate, Y_validate) * 100, 2)
print acc_gaussian
print round(gaussian.score(X_train, Y_train) * 100, 2)
#print cross_val_score(gaussian, X_validate, Y_validate)
# Random Forest (slow)
random_forest = RandomForestClassifier(n_estimators=100)
random_forest.fit(X_train, Y_train)
#Y_pred = random_forest.predict(X_test)
random_forest.score(X_train, Y_train)
acc_random_forest = round(random_forest.score(X_validate, Y_validate) * 100, 2)
print acc_random_forest
print round(random_forest.score(X_train, Y_train) * 100, 2)

#print cross_val_score(random_forest, X_validate, Y_validate)
# 1-nn
knn = KNeighborsClassifier(n_neighbors = 1)
knn.fit(X_train, Y_train)
#Y_pred = knn.predict(X_test)
acc_knn = round(knn.score(X_validate, Y_validate) * 100, 2)
print acc_knn
print round(knn.score(X_train, Y_train) * 100, 2)

#print cross_val_score(knn, X_validate, Y_validate)
# 2-nn
knn = KNeighborsClassifier(n_neighbors = 2)
knn.fit(X_train, Y_train)
#Y_pred = knn.predict(X_test)
acc_knn = round(knn.score(X_validate, Y_validate) * 100, 2)
print acc_knn
print round(knn.score(X_train, Y_train) * 100, 2)

# 3-nn
knn = KNeighborsClassifier(n_neighbors = 3)
knn.fit(X_train, Y_train)
#Y_pred = knn.predict(X_test)
acc_knn = round(knn.score(X_validate, Y_validate) * 100, 2)
print acc_knn
print round(knn.score(X_train, Y_train) * 100, 2)
# Stochastic Gradient Descent
sgd = SGDClassifier()
sgd.fit(X_train, Y_train)
#Y_pred = sgd.predict(X_test)
acc_sgd = round(sgd.score(X_validate, Y_validate) * 100, 2)
print acc_sgd
print round(sgd.score(X_train, Y_train) * 100, 2)
#print cross_val_score(sgd, X_validate, Y_validate)
# Support Vector Machines
svc = SVC()
svc.fit(X_train, Y_train)
#Y_pred = svc.predict(X_test)
acc_svc = round(svc.score(X_validate, Y_validate) * 100, 2)
print acc_svc
print round(svc.score(X_train, Y_train) * 100, 2)<jupyter_output>87.04
88.2
{'fraction_non_alphanumeric': 0.12077131258457374, 'fraction_numerical': 0.03247631935047361, 'mean_word_length': 7.472779369627507, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '128315', 'license': 'MIT', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1226, 'n_words': 234, 'path': 'week6/predict-sub2-onehot-head5000.ipynb', 'repo_name': 'rve/DM-Lab', 'size': '2956'}