MCPcopy
hub / github.com/ddbourgin/numpy-ml / random_regression_problem

Function random_regression_problem

numpy_ml/plots/nonparametric_plots.py:18–32  ·  view source on GitHub ↗
(n_ex, n_in, n_out, d=3, intercept=0, std=1, seed=0)

Source from the content-addressed store, hash-verified

16
17
18def random_regression_problem(n_ex, n_in, n_out, d=3, intercept=0, std=1, seed=0):
19 coef = np.random.uniform(0, 50, size=d)
20 coef[-1] = intercept
21
22 y = []
23 X = np.random.uniform(-100, 100, size=(n_ex, n_in))
24 for x in X:
25 val = np.polyval(coef, x) + np.random.normal(0, std)
26 y.append(val)
27 y = np.array(y)
28
29 X_train, X_test, y_train, y_test = train_test_split(
30 X, y, test_size=0.3, random_state=seed
31 )
32 return X_train, y_train, X_test, y_test, coef
33
34
35def plot_regression():

Callers 2

plot_regressionFunction · 0.70
plot_knnFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected