Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
creates a variable linearly dependant on its parents and then log it: log(beta*X)
Args:
X_parents (pd.DataFrame): a (num_samples x num_parents) matrix containing the data (over all samples or
samples or patients) of the variables which are topological parents of the current
variable
beta (pd.Series): Optional, a given Series which index corresponds to the parents variables
(X_parents.columns)
Returns:
(pd.Series, pd.Series): 2-element tuple containing:
- **x_new** (*pd.Series*): Newly created signal.
- **beta** (*pd.Series*): The coefficients used to create the linear link.
"""
x_new, beta = CausalSimulator3._affine_link(X_parents=X_parents, beta=beta)
x_new = np.log(np.abs(x_new)) # type: pd.Series
return x_new, beta
"""
creates a variable linearly dependant on its parents and then exponent it: exp(beta*X)
Args:
X_parents (pd.DataFrame): a (num_samples x num_parents) matrix containing the data (over all samples or
samples or patients) of the variables which are topological parents of the current
variable
beta (pd.Series): Optional, a given Series which index corresponds to the parents variables
(X_parents.columns)
Returns:
(pd.Series, pd.Series): 2-element tuple containing:
- **x_new** (*pd.Series*): Newly created signal.
- **beta** (*pd.Series*): The coefficients used to create the linear link.
"""
x_new, beta = CausalSimulator3._affine_link(X_parents=X_parents, beta=beta)
x_new = np.exp(x_new) # type: pd.Series
return x_new, beta
"affine": lambda x, beta=None: CausalSimulator3._affine_link(x, beta),
"exp": lambda x, beta=None: CausalSimulator3._exp_linking(x, beta),