Skip to content

Commit

Permalink
Add train accuracy to accuracy test
Browse files Browse the repository at this point in the history
  • Loading branch information
Marshall James committed May 4, 2018
1 parent 5007980 commit 082cbb8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Binary file modified __pycache__/sentiment.cpython-35.pyc
Binary file not shown.
6 changes: 5 additions & 1 deletion classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ def n_classify(self, text):
return json.dumps(probs)

def accuracy(self):

fp = open('./data/train.csv')
train_accuracy = self.cl.accuracy(fp, format="csv")
fp.close()
fp = open('./data/test.csv')
test_accuracy = self.cl.accuracy(fp, format="csv")
fp.close()
return test_accuracy
return json.dumps({"train_accuracy": train_accuracy, "test_accuracy": test_accuracy})

def labels(self):
return json.dumps({"labels": self.cl.labels()})
Expand Down
2 changes: 1 addition & 1 deletion sentiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def sentiments():
def accuracy():
acc = cache.get("accuracy")
if acc is None:
acc = str(round(cl.accuracy(), 3))
acc = cl.accuracy()
cache.set("accuracy", acc)
return acc

Expand Down

0 comments on commit 082cbb8

Please sign in to comment.