Last active
April 9, 2020 14:31
-
-
Save smazzanti/a80adebaf62cfc5a9b75137649b8d9a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def X2y(X, with_error = True): | |
# functional form of the dependence between y and X | |
y_star = X['linear'] + X['nonlinear_square'] ** 2 + np.sin(3 * X['nonlinear_sin']) + (X['interaction_1'] * X['interaction_2'] * X['interaction_3']) | |
# add random error called epsilon (this will be used for creating y) | |
if with_error: | |
np.random.seed(0) | |
epsilon = np.random.normal(0, .1, len(y_star)) | |
return y_star + epsilon | |
# do not add error (this will be used for prediction) | |
else: | |
return y_star |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment