Commit 80fc0e8c authored by Sathvick Reddy N's avatar Sathvick Reddy N
Browse files

Upload New File

parent 6e36b9de
%% Cell type:code id: tags:
``` python
from nltk.classify import ClassifierI
from statistics import mode
```
%% Cell type:code id: tags:
``` python
```
%% Output
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-4-139900c02360> in <module>()
----> 1 kjcsaak
2 ejnkfj
NameError: name 'kjcsaak' is not defined
%% Cell type:code id: tags:
``` python
class VoteClassifier(ClassifierI):
def __init__(self, *classifiers):
self._classifiers = classifiers
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
def classify(self, features):
votes = []
for c in self._classifiers:
v = c.classify(features)
votes.append(v)
return mode(votes)
```
%% Cell type:code id: tags:
``` python
def confidence(self, features):
votes = []
for c in self._classifiers:
v = c.classify(features)
votes.append(v)
choice_votes = votes.count(mode(votes))
conf = choice_votes / len(votes)
return conf
```
%% Cell type:code id: tags:
``` python
import pickle
import nltk
```
%% Cell type:code id: tags:
``` python
classifier_f = open("naivebayes.pickle","rb")
classifier = pickle.load(classifier_f)
classifier_f.close()
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:markdown id: tags:
%% Cell type:code id: tags:
``` python
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment