Skip to main content

Module helpers

Function apply_sigmoid

View Source

apply_sigmoid(X: DataFrame, p: int, m: float, col_name: str, multiplier: float = 1.0) -> DataFrame

Helper function for applying sigmoid transformation to a specific column in a DataFrame. Args: X (pd.DataFrame): Input DataFrame containing the data to be transformed p (int): Shape parameter controlling the steepness of the sigmoid curve m (float): Shift parameter controlling the midpoint of the sigmoid curve col_name (str): Name of the column to apply the sigmoid transformation to multiplier (float, optional): Scaling factor applied to values before sigmoid. Defaults to 1.0

Returns: pd.DataFrame: A copy of the input DataFrame where the specified column has been transformed using the sigmoid function, while keeping all other columns unchanged

Function replace_nan

View Source

replace_nan(X: DataFrame, val: float, col_name: str) -> DataFrame

Helper function to replace nan values in a specific column with a given value. Args: X (pd.DataFrame): Input DataFrame containing the data to be transformed val (float): Numeric value that will be used to replace all NaN/missing values col_name (str): Name of the column in which NaN values should be replaced Returns: pd.DataFrame: A copy of the input DataFrame where NaN values in the specified column have been replaced with the given value, while keeping all other columns unchanged

Function sigmoid

View Source

sigmoid(x: UnionType[Series, ndarray, float], p: int = 40, m: float = 0.5) -> UnionType[Series, ndarray, float]

Sigmoid function that transforms input values to range between 0 and 1. Args: x (pd.Series | np.ndarray | float): Input values to be transformed p (int, optional): Shape parameter controlling steepness of the curve. Defaults to 40. m (float, optional): Shift parameter controlling midpoint of the curve. Defaults to 0.50. Returns: pd.Series|np.ndarray|float: Transformed values between 0 and 1