<jupyter_start><jupyter_text>Test Data<jupyter_code># Import the needed  modules...

import json
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import MultinomialNB
from sklearn.svm import SVC
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, confusion_matrix
# Get the data from data1.json...

data = json.load(open("data1.json", "rb"))
# Convert Dictionary into Data Frame...

import pandas as pd
df = pd.DataFrame.from_dict(data) 
df
# Here we take data into x and target values into y...

x=df.drop(labels=["Prediction","Email No."],axis=1)
y=df['Prediction']
# We print first five rows of our final data....

x.head()
# We print first five values of our target data...

y.head()
# Here we divide our 30% data into testing...

x_train, x_test, y_train, y_test=train_test_split(x,y,test_size=0.3,shuffle=True,stratify=y)
# Size of train data and test data is...

x_train.shape, x_test.shape<jupyter_output><empty_output><jupyter_text>Naive Bayes Approach<jupyter_code># Most effective approach for text classification problem is naive bayes appraoch...

nb = MultinomialNB()
# Here we fit our data to test whether the mail is spam or not...

nb.fit(x_train,y_train)
# Here we predict the result of our testing...

y_pred = nb.predict(x_test)
# Here we knows how many mails are classified true positive or true negative ...

confusion_matrix(y_test,y_pred)
# Here we get the accuracy score of our model...

accuracy_score(y_test,y_pred)<jupyter_output><empty_output><jupyter_text>Support Vector Machine<jupyter_code># Simply want to create the object of support vector macine...

svm = SVC()
# Here we fit our data to test whether the mail is spam or not...

svm.fit(x_train, y_train)
# Here we predict the result of our testing...

y_pred1 = svm.predict(x_test)
# Here we knows how many mails are classified true positive or true negative ...

confusion_matrix(y_test,y_pred1)
# Here we get the accuracy score of our model...

accuracy_score(y_test,y_pred1)<jupyter_output><empty_output><jupyter_text>Random Forest Classifier<jupyter_code># Simply want to create the object of random forest classifier...

rfc = RandomForestClassifier(n_estimators = 100, criterion='gini')
# Here we fit our data to test whether the mail is spam or not...

rfc.fit(x_train, y_train)
# Here we predict the result of our testing...

y_pred2 = rfc.predict(x_test)
# Here we knows how many mails are classified true positive or true negative ...

confusion_matrix(y_test, y_pred2)
# Here we get the accuracy score of our model...

accuracy_score(y_test, y_pred2)
# Out of all these approach Random Forest Classifier gives more correct information of email classification...<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0916606757728253, 'fraction_numerical': 0.005751258087706686, 'mean_word_length': 4.883720930232558, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '281993', 'license': 'MIT', 'n_tokens_mistral': 914, 'n_tokens_neox': 891, 'n_words': 320, 'path': 'Test Data.ipynb', 'repo_name': 'Mukul-12/CapstoneProject-EmailClassification', 'size': '2782'}