MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / main

Function main

ann_class2/tf_with_save.py:127–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

125
126
127def main():
128 Xtrain, Xtest, Ytrain, Ytest = get_normalized_data()
129
130 model = TFLogistic("./tf.model")
131 model.fit(Xtrain, Ytrain, Xtest, Ytest)
132
133 # test out restoring the model via the predict function
134 print("final train accuracy:", model.score(Xtrain, Ytrain))
135 print("final test accuracy:", model.score(Xtest, Ytest))
136
137 # save the model
138 model.save("my_trained_model.json")
139
140 # load and score again
141 model = TFLogistic.load("my_trained_model.json")
142 print("final train accuracy (after reload):", model.score(Xtrain, Ytrain))
143 print("final test accuracy (after reload):", model.score(Xtest, Ytest))
144
145
146if __name__ == '__main__':

Callers 1

tf_with_save.pyFile · 0.70

Calls 6

fitMethod · 0.95
scoreMethod · 0.95
saveMethod · 0.95
get_normalized_dataFunction · 0.90
TFLogisticClass · 0.85
loadMethod · 0.45

Tested by

no test coverage detected