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

Function regression

examples/gbm.py:44–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42
43
44def regression():
45 # Generate a random regression problem
46 X, y = make_regression(
47 n_samples=500,
48 n_features=5,
49 n_informative=5,
50 n_targets=1,
51 noise=0.05,
52 random_state=1111,
53 bias=0.5,
54 )
55 X_train, X_test, y_train, y_test = train_test_split(
56 X, y, test_size=0.1, random_state=1111
57 )
58
59 model = GradientBoostingRegressor(n_estimators=25, max_depth=5, max_features=3)
60 model.fit(X_train, y_train)
61 predictions = model.predict(X_test)
62 print(
63 "regression, mse: %s"
64 % mean_squared_error(y_test.flatten(), predictions.flatten())
65 )
66
67
68if __name__ == "__main__":

Callers

nothing calls this directly

Calls 4

fitMethod · 0.95
mean_squared_errorFunction · 0.90
predictMethod · 0.45

Tested by

no test coverage detected