Skip to content

Instantly share code, notes, and snippets.

@a-mitani
Last active July 23, 2020 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-mitani/4758898e133b7938cba615e6c950769f to your computer and use it in GitHub Desktop.
Save a-mitani/4758898e133b7938cba615e6c950769f to your computer and use it in GitHub Desktop.
交互作用を含むトイデータの生成
def create_toy_dataset(n=100):
# 交互作用を含まない変数
ind_vars = np.random.randn(n, 2)
# 交互作用のもとになる変数
int_var_src = np.random.randn(n, 2)
X = np.hstack([ind_vars, int_var_src])
y = ind_vars[:, 1] + 2 * int_var_src[:, 0] * int_var_src[:, 1]
return X, y
X, y = create_toy_dataset(2000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment