<jupyter_start><jupyter_text>Kernel SVM-Polynomial:<jupyter_code>from sklearn.svm import SVC 
model = SVC(C=1,kernel='poly')
model.fit(x_train,y_train)
from sklearn.metrics import classification_report, accuracy_score, confusion_matrix
predictions = model.predict(x_test)
print("\nTesting Accuracy = ", accuracy_score(y_true=y_test, y_pred=predictions))
print(classification_report(y_test,predictions))
print(confusion_matrix(y_test,predictions))<jupyter_output>[[ 962    0    0    1    0    3    4    0   10    0]
 [   0 1122    3    0    2    1    4    0    3    0]
 [   6    0  977    4    2    0    2    6   35    0]
 [   0    0    0  972    0    4    2    5   21    6]
 [   0    0    2    0  952    0    7    2    5   14]
 [   2    1    2    4    2  862    7    1    9    2]
 [   4    3    1    0   10    7  920    0   13    0]
 [   1    9   11    2   13    0    0  956   10   26]
 [   1    0    3    7    4    7    2    2  944    4]
 [   3    4    1   12   27    3    0    3   12  944]]<jupyter_text>Kernel SVM-Polynomial with PCA<jupyter_code>x_train_PCA = x_train
x_test_PCA = x_test
## Applying PCA on the Dataset
from sklearn.decomposition import PCA
pca = PCA(n_components=0.97)        # Should lie between 0.95 to 0.99
x_train_PCA = pca.fit_transform(x_train_PCA)  
x_test_PCA = pca.transform(x_test_PCA)
model_PCA = SVC(C=1,kernel='poly')
model_PCA.fit(x_train_PCA,y_train)
predictions_PCA = model_PCA.predict(x_test_PCA)
print("\nTesting Accuracy = ", accuracy_score(y_true=y_test, y_pred=predictions_PCA))
print(classification_report(y_test,predictions_PCA))
print(confusion_matrix(y_test,predictions_PCA))<jupyter_output>[[ 963    0    0    1    0    3    4    0    9    0]
 [   0 1122    3    0    2    1    4    0    3    0]
 [   3    0  982    3    2    1    2    7   32    0]
 [   0    0    1  972    0    4    2    5   20    6]
 [   0    0    3    0  954    0    7    2    4   12]
 [   2    1    2    5    2  862    7    1    8    2]
 [   4    2    1    0   10    7  921    0   13    0]
 [   1    9   12    2   11    0    0  960    7   26]
 [   1    0    3    7    4    7    2    2  944    4]
 [   2    4    1   12   26    4    0    4   12  944]]<jupyter_text>Kernel SVM-Polynomial with LDA<jupyter_code>x_train_LDA = x_train
x_test_LDA = x_test
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
lda = LDA(n_components=9)
x_train_LDA = lda.fit_transform(x_train_LDA,y_train)  
x_test_LDA = lda.transform(x_test_LDA)
model_LDA = SVC(C=1,kernel='poly')
model_LDA.fit(x_train_LDA,y_train)
predictions_LDA = model_LDA.predict(x_test_LDA)
print("\nTesting Accuracy = ", accuracy_score(y_true=y_test, y_pred=predictions_LDA))
print(classification_report(y_test,predictions_LDA))
print(confusion_matrix(y_test,predictions_LDA))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08044333214158027, 'fraction_numerical': 0.09974973185555953, 'mean_word_length': 2.115812917594655, 'pattern_counts': {'":': 0, '<': 11, '<?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': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '438549', 'license': 'MIT', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1151, 'n_words': 289, 'path': 'SVM_MNIST/SVM_Polynomial_MNIST.ipynb', 'repo_name': 'AmoghavarshaP/Project2-SVM-DigitRecognition-TransferLearning', 'size': '2797'}