Commit f2c9faea by Paktalin

First spam detector exercise

parent 22bda9aa
Showing with 23 additions and 0 deletions
from sklearn.naive_bayes import MultinomialNB
from sklearn.ensemble import AdaBoostClassifier
import pandas as pd
import numpy as np
data = pd.read_csv('./spambase/spambase.data').values
np.random.shuffle(data)
X = data[:, :48]
Y = data[:, -1]
X_train = X[:-100,]
X_test = X[-100:,]
Y_train = Y[:-100,]
Y_test = Y[-100:,]
model = MultinomialNB()
model.fit(X_train, Y_train)
print("Classification rate:", model.score(X_test, Y_test))
ada_model = AdaBoostClassifier()
ada_model.fit(X_train, Y_train)
print("Classification rate with Ada", ada_model.score(X_test, Y_test))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment