Repository navigation
Expand file tree
/
Copy pathtest.py
More file actions
73 lines (57 loc) · 1.99 KB
/
Copy pathtest.py
File metadata and controls
73 lines (57 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from keras.models import Sequential
from keras.layers import Dense
import numpy as np
import pandas as pd
from sklearn.preprocessing import LabelEncoder
from numpy import genfromtxt
from keras.models import model_from_json
from keras.optimizers import SGD
# fix random seed for reproducibility
np.random.seed(7)
# load pima indians dataset
#dataset = pd.read_csv("TRAIN_info_SMS.csv")
#test_dataset = pd.read_csv("DEV_info_SMS.csv")
# split into input (X) and output (Y) variables
# X = np.array(dataset[['Message']])
# Y = np.array(dataset[['Label']])
#f = open('glove/glove.6B.50d.txt','r')
#vecs = {}
#for line in f:
# splitLine = line.split()
# word = splitLine[0]
# embedding = np.array([float(val) for val in splitLine[1:]])
# vecs[word] = embedding
x = genfromtxt('xt.csv', delimiter=',')
#t_x = genfromtxt('DEV_info_SMS.csv', delimiter=',')
y = genfromtxt('yt.csv')
# print n
# print x
#print y
# print x.shape
#print y.shape
# create model
# model = Sequential()
# model.add(Dense(64, input_shape=(150,), activation='relu'))
# model.add(Dense(1, activation='softmax'))
# print model.summary()
# model.add(Dense(4, activation='sigmoid'))
# Compile model
# model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# Fit the model
# model.fit(x, y, epochs=150, batch_size=10)
# load pima indians dataset
# test_dataset = numpy.loadtxt("DEV_info_SMS.csv", delimiter=",")
# split into input (X) and output (Y) variables
# test_X = dataset[:,1:]
# test_Y = dataset[:,0]
# evaluate the model
json_file = open('model25.json','r')
loaded_model_json = json_file.read()
json_file.close()
model = model_from_json(loaded_model_json)
model.load_weights('model25.h5')
sgd = SGD(lr=0.1, momentum=0.9, decay=0.0, nesterov=False)
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
#t_y = y[:3000]
scores = model.evaluate(x, y)
print("\n%s: %.2f%%" % (model.metrics_names[1], scores[1]*100))