MCPcopy Create free account
hub / github.com/rushter/MLAlgorithms / classification

Function classification

examples/naive_bayes.py:8–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6
7
8def classification():
9 # Generate a random binary classification problem.
10 X, y = make_classification(
11 n_samples=1000,
12 n_features=10,
13 n_informative=10,
14 random_state=1111,
15 n_classes=2,
16 class_sep=2.5,
17 n_redundant=0,
18 )
19 X_train, X_test, y_train, y_test = train_test_split(
20 X, y, test_size=0.1, random_state=1111
21 )
22
23 model = NaiveBayesClassifier()
24 model.fit(X_train, y_train)
25 predictions = model.predict(X_test)[:, 1]
26
27 print("classification accuracy", roc_auc_score(y_test, predictions))
28
29
30if __name__ == "__main__":

Callers 1

naive_bayes.pyFile · 0.70

Calls 3

fitMethod · 0.95
predictMethod · 0.45

Tested by

no test coverage detected