-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
114 lines (80 loc) · 1.99 KB
/
main.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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# import <
import numpy as np
from os import path
from dash import Dash
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output, State
from frontend import frontendFunction
from backend import buildModel, trainModel
from backend import loadData, translateData
# >
# global <
gModel = None
gRealpath = path.realpath(__file__)
gData = {'star' : 5000, 'galaxy' : 5000}
gDirectory = ('/'.join(gRealpath.split('/')[:-1]))
application = Dash(
suppress_callback_exceptions = True,
external_stylesheets = [dbc.themes.GRID]
)
server = application.server
# >
# main <
if (__name__ == '__main__'):
# <
# <
x, y = zip(*loadData(
pFile = 'aData',
pDir = gDirectory,
pKey = gData.keys(),
pValue = gData.values()
))
x, y, inputShape = translateData(
x = x,
y = y,
pData = gData
)
# >
# <
# <
model = buildModel(
inputShape = inputShape
)
history, model = trainModel(
x = x,
y = y,
model = model
)
# >
# test model on unused aData <
# use model to classify unused aData <
scores = model.evaluate(x[1], y[1], verbose = 0)
prediction = model.predict(x[1])
# limit output precision for floats <
with np.printoptions(precision = 4):
# output test evaluation of model <
# output test classifications from model <
print('\nModel Evaluation\ntest loss = ', scores[0], '\ntest accuracy = ', scores[1], '\ntest AUC = ', scores[2])
print('\nModel Prediction')
for i in range(0, 10): print('True = ', y[1][i], '\nPred = ', prediction[i], '\n')
# >
# >
# <
# <
application.layout = frontendFunction(
history = history
)
application.run_server()
# >
# >
# @application.callback(
#
# Input('uploadId', 'children'),
# Output('outputId', 'children')
#
# )
# def callbackFunction(*args):
# ''' '''
#
# print('ok')
# return None