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

Function main

machine-learning/iris.py:6–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5
6def main():
7 iris = load_iris()
8
9 print(iris.feature_names)
10 print(iris.target_names)
11
12 # print(iris.data[0])
13 # print(iris.target[0])
14
15 test_idx = [0, 50, 100]
16
17 train_target = np.delete(iris.target, test_idx)
18 train_data = np.delete(iris.data, test_idx, axis=0)
19
20 test_target = iris.target[test_idx]
21 test_data = iris.data[test_idx]
22
23 # print(test_target)
24 # print(test_data)
25
26 clf = tree.DecisionTreeClassifier()
27 clf.fit(train_data, train_target)
28
29 print('actual:', test_target)
30 print('predicted:', clf.predict(test_data))
31
32
33if __name__ == '__main__':

Callers 1

iris.pyFile · 0.70

Calls 3

deleteMethod · 0.80
fitMethod · 0.80
predictMethod · 0.80

Tested by

no test coverage detected