(n_ex, n_in, n_out, d=3, intercept=0, std=1, seed=0)
| 16 | |
| 17 | |
| 18 | def 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 | |
| 35 | def plot_regression(): |
no outgoing calls
no test coverage detected