<jupyter_start><jupyter_text>Try also with my own logistic regressor. This will require the data be shaped differently (n x m rather than m x n for the X matrix).<jupyter_code># Arguments are learning_rate, number of iterations, and how often prints scores during training
clf2 = LogRegression(0.05, 3000, verbose=100)

X_train_r = X_train.T
X_train_r.shape
y_train_r = y_train.reshape(1, -1)
y_train_r.shape
y_test_r = y_test.reshape(1, -1)
X_test_r = X_test.T

clf2.fit(X_train_r, y_train_r)
y_hat2 = clf2.predict(X_test_r)
accuracy_score(y_test.flatten(), y_hat2[0])
cm = ConfusionMatrix(y_test.flatten(), y_hat2[0])
cm.get_confusion_matrix()
cm.get_metrics()
import matplotlib.pyplot as plt
plt.plot(clf2.train_losses, label='train losses')
# plt.plot(clf2.train_accuracy, label='train accuracy')
plt.legend();

from sklearn.neighbors import KNeighborsClassifier
clf3 = KNeighborsClassifier()
clf3.fit(X_train, y_train)
train_accuracy = clf3.score(X_train, y_train)
test_accuracy = clf3.score(X_test, y_test)
print(f'Training {train_accuracy * 100}% Test {test_accuracy * 100}')
y_hat = clf3.predict(X_test)
cm = ConfusionMatrix(y_test, y_hat)
cm.get_confusion_matrix()
cm.get_metrics()
clf3.predict_proba([X_train[23]])
import basilica
!pip install basilica<jupyter_output>Requirement already satisfied: basilica in c:\users\a\.virtualenvs\twitoff-2mnxmoqr\lib\site-packages (0.2.8)
Requirement already satisfied: requests in c:\users\a\.virtualenvs\twitoff-2mnxmoqr\lib\site-packages (from basilica) (2.24.0)
Requirement already satisfied: six in c:\users\a\.virtualenvs\twitoff-2mnxmoqr\lib\site-packages (from basilica) (1.15.0)
Requirement already satisfied: Pillow in c:\users\a\.virtualenvs\twitoff-2mnxmoqr\lib\site-packages (from basilica) (7.2.0)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\a\.virtualenvs\twitoff-2mnxmoqr\lib\site-packages (from requests->basilica) (1.25.10)
Requirement already satisfied: idna<3,>=2.5 in c:\users\a\.virtualenvs\twitoff-2mnxmoqr\lib\site-packages (from requests->basilica) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\a\.virtualenvs\twitoff-2mnxmoqr\lib\site-packages (from requests->basilica) (2020.6.20)
Requirement already satisfied: chardet<4,>=3.0.2 in c:\user[...]
{'fraction_non_alphanumeric': 0.1340341655716163, 'fraction_numerical': 0.04555409548839247, 'mean_word_length': 6.1152647975077885, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '229492', 'license': 'MIT', 'n_tokens_mistral': 961, 'n_tokens_neox': 897, 'n_words': 177, 'path': 'model_test.ipynb', 'repo_name': 'karencfisher/twitoff', 'size': '2283'}