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

Function regression

examples/nearest_neighbors.py:13–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11
12
13def regression():
14 # Generate a random regression problem
15 X, y = make_regression(
16 n_samples=500,
17 n_features=5,
18 n_informative=5,
19 n_targets=1,
20 noise=0.05,
21 random_state=1111,
22 bias=0.5,
23 )
24 X_train, X_test, y_train, y_test = train_test_split(
25 X, y, test_size=0.25, random_state=1111
26 )
27
28 model = knn.KNNRegressor(k=5, distance_func=distance.euclidean)
29 model.fit(X_train, y_train)
30 predictions = model.predict(X_test)
31 print("regression mse", mean_squared_error(y_test, predictions))
32
33
34def classification():

Callers 1

Calls 3

mean_squared_errorFunction · 0.90
fitMethod · 0.45
predictMethod · 0.45

Tested by

no test coverage detected