MCPcopy Index your code
hub / github.com/rushter/MLAlgorithms / classification

Function classification

examples/linear_models.py:38–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36
37
38def classification():
39 # Generate a random binary classification problem.
40 X, y = make_classification(
41 n_samples=1000,
42 n_features=100,
43 n_informative=75,
44 random_state=1111,
45 n_classes=2,
46 class_sep=2.5,
47 )
48 X_train, X_test, y_train, y_test = train_test_split(
49 X, y, test_size=0.1, random_state=1111
50 )
51
52 model = LogisticRegression(lr=0.01, max_iters=500, penalty="l1", C=0.01)
53 model.fit(X_train, y_train)
54 predictions = model.predict(X_test)
55 print("classification accuracy", accuracy(y_test, predictions))
56
57
58if __name__ == "__main__":

Callers 1

linear_models.pyFile · 0.70

Calls 4

LogisticRegressionClass · 0.90
accuracyFunction · 0.90
fitMethod · 0.45
predictMethod · 0.45

Tested by

no test coverage detected