<jupyter_start><jupyter_text>Preparing Data* Train data set has the pixel information of the images and the label of what digit it is.* Split the training set as x and y with labels* Normalize the data to make the models train faster<jupyter_code>train = pd.read_csv("train.csv")
test = pd.read_csv("test.csv")

train.head()
x = train.copy()
x = x.drop(columns=["label"])
y = train["label"]
x.head()
x = x / 255.0

x.iloc[0].max()<jupyter_output><empty_output><jupyter_text>KNeighbours Classifier<jupyter_code>train_x,val_x,train_y,val_y = train_test_split(x,y,random_state=32)

model = KNeighborsClassifier (n_neighbors=5,weights = 'distance')
model.fit(train_x,train_y)
preds = model.predict(val_x)
score = accuracy_score(preds,val_y)*100
print('Error: ',score)<jupyter_output>Error:  96.5904761904762<jupyter_text>Multinomial Naive Bayes<jupyter_code>nb = MultinomialNB()
nb.fit(train_x,train_y)
preds = nb.predict(val_x)
score = accuracy_score(preds,val_y)* 100
print('Error: ', score)<jupyter_output>Error:  82.77142857142857<jupyter_text>Gaussian Naive Bayes<jupyter_code>gnb = GaussianNB()
gnb.fit(train_x,train_y)
preds = gnb.predict(val_x)
score = accuracy_score(preds,val_y)* 100
print('Error: ', score)<jupyter_output>Error:  56.57142857142857<jupyter_text>Bernoulli Naive Bayes<jupyter_code>bnb = BernoulliNB()
bnb.fit(train_x,train_y)
preds = bnb.predict(val_x)
score = accuracy_score(preds,val_y)* 100
print('Error: ', score)<jupyter_output>Error:  83.4095238095238<jupyter_text>XGBoost Classifier<jupyter_code>xgboost = XGBClassifier()
xgboost.fit(train_x,train_y)
preds = xgboost.predict(val_x)
score = accuracy_score(preds,val_y)*100
print('Error: ',score)
submission = pd.read_csv('sample_submission.csv')

test = test / 255.0 

predictions = xgboost.predict(test)
submission['Label'] = predictions
submission.to_csv('submission.csv',index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.133051742344245, 'fraction_numerical': 0.046990496304118265, 'mean_word_length': 8.522613065326633, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '503638', 'license': 'MIT', 'n_tokens_mistral': 825, 'n_tokens_neox': 754, 'n_words': 123, 'path': 'Digit Classifier/SimpleClassification/Digit Classifier.ipynb', 'repo_name': 'therrshan/Kaggle-Solutions', 'size': '1894'}