MCPcopy
hub / github.com/jwasham/practice-python / main

Function main

machine-learning/neural-net.py:8–24  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6
7
8def main():
9 logging.getLogger().setLevel(logging.INFO)
10
11 iris = learn.datasets.load_iris()
12
13 X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=42)
14
15 feature_columns = [tf.contrib.layers.real_valued_column("", dimension=4)]
16
17 # Build a neural network with 3 hidden layers: 10, 20, 10 units respectively
18 classifier = learn.DNNClassifier(hidden_units=[10, 20, 10], n_classes=3, feature_columns=feature_columns)
19
20 classifier.fit(X_train, y_train, steps=2000)
21
22 score = metrics.accuracy_score(y_test, classifier.predict(X_test))
23
24 print("Accuracy: {0:f}".format(score))
25
26
27if __name__ == '__main__':

Callers 1

neural-net.pyFile · 0.70

Calls 2

fitMethod · 0.80
predictMethod · 0.80

Tested by

no test coverage detected