()
| 32 | |
| 33 | |
| 34 | def classification(): |
| 35 | X, y = make_classification( |
| 36 | n_samples=500, |
| 37 | n_features=5, |
| 38 | n_informative=5, |
| 39 | n_redundant=0, |
| 40 | n_repeated=0, |
| 41 | n_classes=3, |
| 42 | random_state=1111, |
| 43 | class_sep=1.5, |
| 44 | ) |
| 45 | |
| 46 | X_train, X_test, y_train, y_test = train_test_split( |
| 47 | X, y, test_size=0.1, random_state=1111 |
| 48 | ) |
| 49 | |
| 50 | clf = knn.KNNClassifier(k=5, distance_func=distance.euclidean) |
| 51 | |
| 52 | clf.fit(X_train, y_train) |
| 53 | predictions = clf.predict(X_test) |
| 54 | print("classification accuracy", accuracy(y_test, predictions)) |
| 55 | |
| 56 | |
| 57 | if __name__ == "__main__": |
no test coverage detected