-
Notifications
You must be signed in to change notification settings - Fork 0
/
Model.py
29 lines (26 loc) · 1.03 KB
/
Model.py
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
import numpy as np
import matplotlib.pyplot as plt
from glob import glob
from keras.models import Sequential
from keras.layers import Dense
class Model():
def __init__(self, X, y, X_test, y_test):
self.X = X
self.y = y
self.X_test = X_test
self.y_test = y_test
def sequential(self):
# define the keras model
model = Sequential()
model.add(Dense(104, input_dim=104, activation='relu'))
model.add(Dense(104, activation='relu'))
model.add(Dense(100, activation='relu'))
model.add(Dense(20, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
# compile the keras model
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# fit the keras model on the dataset
model.fit(self.X, self.y, epochs=150, batch_size=10)
# evaluate the keras model
_, accuracy = model.evaluate(self.X_test, self.y_test)
print('Accuracy: %.2f' % (accuracy*100))