Commit bae7e627 authored by Dinithi Anupama's avatar Dinithi Anupama

Merge branch 'IT18116984_WeerasundaraD.A' into 'master'

Ann model changes

See merge request !24
parents d4a279a3 9dd41308
......@@ -10,8 +10,9 @@ from sklearn import preprocessing
def loadModel(model):
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Flatten())
model.add(tf.keras.layers.Dense(25, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(25, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(50, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(50, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(50, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(7, activation=tf.nn.softmax))
model.compile(optimizer='adam',
......@@ -23,8 +24,9 @@ def loadModel(model):
def trainModel(model, datasetFilePath):
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Flatten())
model.add(tf.keras.layers.Dense(25, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(25, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(50, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(50, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(50, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(7, activation=tf.nn.softmax))
model.compile(optimizer='adam',
......@@ -39,6 +41,7 @@ def trainModel(model, datasetFilePath):
leBreeds = preprocessing.LabelEncoder()
leBreeds.fit(model_df['Breeds'])
print(leBreeds.classes_)
model_df['Breeds'] = leBreeds.transform(model_df['Breeds'])
dataDf = model_df.fillna(0)
print(model_df.shape)
......@@ -49,7 +52,7 @@ def trainModel(model, datasetFilePath):
x_train = tf.keras.utils.normalize(x_train, axis=1)
x_test = tf.keras.utils.normalize(x_test, axis=1)
history = model.fit(x_train, y_train, epochs=15, validation_data=(x_test, y_test))
history = model.fit(x_train, y_train, epochs=75, validation_data=(x_test, y_test))
print("History: ", history)
val_loss, val_acc = model.evaluate(x_test, y_test)
......
age,symptom1,symptom2,symptom3,symptom4,sym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,1,1,1,1,1,0,1,0,1,0,1,0,0,1,2
6,1,1,1,1,1,1,0,1,1,1,1,1,0,0,1,1,1,3
1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,3
1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,3
1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,3
1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,3
1,1,1,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0
1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0
1,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0
1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0
1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0
1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
1,1,1,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0
1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0
4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0
4,0,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,0
4,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0
4,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0
4,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,0,2
4,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,2
4,0,0,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,2
4,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,2
4,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,2
4,1,1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,2
4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,2
\ No newline at end of file
......@@ -5,6 +5,7 @@ from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
from sklearn import preprocessing
# load the dataset using pandas library
dataDf = pd.read_csv("data.csv")
leDiseases = preprocessing.LabelEncoder()
......
......@@ -15,8 +15,9 @@ def predict():
model = tf.keras.models.Sequential()
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Flatten())
model.add(tf.keras.layers.Dense(25, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(25, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(50, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(50, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(50, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(7, activation=tf.nn.softmax))
model.compile(optimizer='adam',
......@@ -29,4 +30,4 @@ def predict():
return {"pred": str(numpy.argmax(prediction))}
if __name__ == '__main__':
app.run(debug=True, port=5001)
app.run(debug=True, port=5001, host="0.0.0.0")
......@@ -17,10 +17,17 @@ model.compile(optimizer='adam',
metrics=['accuracy'])
model = load_model('model.h5')
pred = model.predict(numpy.array([[2,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]]))
def predict(data):
return model.predict(numpy.array(data))
print(numpy.array(data))
pred = model.predict(numpy.array([[2,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]]))
print(pred)
return pred
# Test prediction
print(predict([[1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0]]))
print(numpy.argmax(predict([[1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0]])))
print(disease_labels[numpy.argmax(predict([[1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0]]))])
# input = [2,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
# print(len(input))
# print(predict([[2,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]]))
# print(numpy.argmax(predict([[1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0]])))
# print(disease_labels[numpy.argmax(predict([[1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0]]))])
This diff is collapsed.
Markdown is supported
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