Skip to content

Instantly share code, notes, and snippets.

View edwardleoni's full-sized avatar

Edward Leoni edwardleoni

View GitHub Profile
from word_features import extract
import pickle
import sys
try:
f = open('classifier.pickle', 'rb')
except FileNotFoundError:
print('Classifier not found')
exit()
from nltk.classify import NaiveBayesClassifier
from nltk.corpus import movie_reviews
from word_features import extract
import pickle
import nltk.classify.util
"""
Only downloads the movie reviews database
def extract(words):
return dict([(word, True) for word in words])
import tensorflow as tf
import sys
image_path = sys.argv[1]
image_data = tf.gfile.FastGFile(image_path, 'rb').read()
label_lines = [line.rstrip() for line in tf.gfile.GFile('labels.txt')]
with tf.gfile.FastGFile('graph.pb', 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
from keras.models import load_model
import numpy
model = load_model('wine-model.h5')
predict_me = numpy.array([
[6.6, 0.16, 0.4, 1.5, 0.044, 48, 143, 0.9912, 3.54, 0.52, 12.4], # Good
[5.2, 0.405, 0.15, 1.45, 0.038, 10, 44, 0.99125, 3.52, 0.4, 11.6] # Bad
])
from keras.models import load_model
import numpy
dataset = numpy.loadtxt("wine-data.csv", delimiter=";")
input = dataset[:, 0:11]
output = dataset[:, 11]
# since the data comes in a scale of 0 to 10, this is needed to we get a simple true or false
output = [(round(each / 10)) for each in output]
from keras.models import Sequential
from keras.layers import Dense
import numpy
dataset = numpy.loadtxt("wine-data.csv", delimiter=";")
input = dataset[:, 0:11]
output = dataset[:, 11]
# since the data comes in a scale of 0 to 10, this is needed to we get a simple true or false
from keras.models import load_model
import numpy
dataset = numpy.loadtxt("diabetes.csv", delimiter=",")
input = dataset[:,0:8]
output = dataset[:,8]
model = load_model('diabetes.h5')
from keras.models import load_model
import numpy
model = load_model('diabetes.h5')
predict_me = numpy.array([[1, 126, 60, 0, 0, 30.1, 0.349, 47]])
predictions = model.predict(predict_me)
rounded = [round(output[0]) for output in predictions]
from keras.models import Sequential
from keras.layers import Dense
import numpy
# load dataset
dataset = numpy.loadtxt("diabetes.csv", delimiter=",")
# split into input and ouput
input = dataset[:,0:8]
output = dataset[:,8]