app/service/serve/runner.py
def data_output_sla(df: pd.DataFrame,
                    y_pred: pd.Series) -> pd.DataFrame:
    """Function to align prediction output with SLA
    
    Args:
        df: intput dataframe 
        y_pred: predictions vector
    
    Returns:
        pd.DataFrame
    """
    COL_LOSE = ["computer", "smartphone"]
    COL_DIMS = ["entity_id", *COL_LOSE]
    COL_TARGET = 'cr'

    result = df[COL_DIMS].copy()
    result["device"] = "Computer"
    result.loc[result["smartphone"] == 1,
               "device"] = "Smartphone"
    result.loc[(result["smartphone"] == 0) & (result["computer"] == 0),
               "device"] = "Tablet"
    result[COL_TARGET] = y_pred
    result.drop(COL_LOSE, axis=1, inplace=True)
    
    return result
Function to align prediction output with SLA
    
    Args:
        df: intput dataframe 
        y_pred: predictions vector
    
    Returns:
        pd.DataFrame
    
Function to align prediction output with SLA
Function to align prediction output with SLA
def data_output_sla(df: pd.DataFrame,
                    y_pred: pd.Series) -> pd.DataFrame:
    COL_LOSE = ["computer", "smartphone"]
    COL_DIMS = ["entity_id", *COL_LOSE]
    COL_TARGET = 'cr'
    result = df[COL_DIMS].copy()
    result["device"] = "Computer"
    result.loc[result["smartphone"] == 1,
               "device"] = "Smartphone"
    result.loc[(result["smartphone"] == 0) & (result["computer"] == 0),
               "device"] = "Tablet"
    result[COL_TARGET] = y_pred
    result.drop(COL_LOSE, axis=1, inplace=True)
    return result
def data_output_sla ( df : pd . DataFrame , y_pred : pd . Series ) -> pd . DataFrame : COL_LOSE = [ "computer" , "smartphone" ] COL_DIMS = [ "entity_id" , * COL_LOSE ] COL_TARGET = 'cr' result = df [ COL_DIMS ] . copy ( ) result [ "device" ] = "Computer" result . loc [ result [ "smartphone" ] == 1 , "device" ] = "Smartphone" result . loc [ ( result [ "smartphone" ] == 0 ) & ( result [ "computer" ] == 0 ) , "device" ] = "Tablet" result [ COL_TARGET ] = y_pred result . drop ( COL_LOSE , axis = 1 , inplace = True ) return result
Function to align prediction output with SLA
Function to align prediction output with SLA
"""Function to align prediction output with SLA
    
    Args:
        df: intput dataframe 
        y_pred: predictions vector
    
    Returns:
        pd.DataFrame
    """
None
df
pd.DataFrame
None
y_pred
pd.Series
None