Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lazy-programmer-courses
/
nlp
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f2c9faea
authored
Nov 29, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First spam detector exercise
parent
22bda9aa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
naive_bayes.py
naive_bayes.py
View file @
f2c9faea
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment