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

Function regression

examples/random_forest.py:45–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

mean_squared_errorFunction · 0.90
fitMethod · 0.45
predictMethod · 0.45

Tested by

no test coverage detected