uni_multiStats.py
def derive_class(data, columns_org):
    '''
    Uses a KNN imputed Data Frame with fractions, and uses probabilities and random choice generators to impute the missing values.

    Args:
        data: the data before deriving
        columns_org: column names before dummification
    
    Returns:
        Data after deriving the classes
    '''
    np.random.seed(5)
    for group in columns_org:
        indices = np.asarray(np.where(data.columns.str.startswith(group))).flatten().tolist()
        g_rows = []
        for col in data.columns[indices]:
            for rows in data.index[((data.loc[:,col]) <1) & (data.loc[:,col] >0)].tolist():
               g_rows.append(rows)
        g_rows = set(g_rows)
        for row in g_rows:
            prob=data.iloc[row,indices].tolist()
            if sum(prob) <1:
                indices.append(-1)
                prob.append(1-sum(prob))
            choice = np.random.choice(indices, p=prob)
            if -1 in indices: indices.remove(-1)
            data.iloc[row, indices] = 0
            if choice != -1: data.iloc[row, [choice]] = 1
    return data

    Uses a KNN imputed Data Frame with fractions, and uses probabilities and random choice generators to impute the missing values.

    Args:
        data: the data before deriving
        columns_org: column names before dummification
    
    Returns:
        Data after deriving the classes
    
Uses a KNN imputed Data Frame with fractions, and uses probabilities and random choice generators to impute the missing values.
Uses a KNN imputed Data Frame with fractions and uses probabilities and random choice generators to impute the missing values .
def derive_class(data, columns_org):
    np.random.seed(5)
    for group in columns_org:
        indices = np.asarray(np.where(data.columns.str.startswith(group))).flatten().tolist()
        g_rows = []
        for col in data.columns[indices]:
            for rows in data.index[((data.loc[:,col]) <1) & (data.loc[:,col] >0)].tolist():
               g_rows.append(rows)
        g_rows = set(g_rows)
        for row in g_rows:
            prob=data.iloc[row,indices].tolist()
            if sum(prob) <1:
                indices.append(-1)
                prob.append(1-sum(prob))
            choice = np.random.choice(indices, p=prob)
            if -1 in indices: indices.remove(-1)
            data.iloc[row, indices] = 0
            if choice != -1: data.iloc[row, [choice]] = 1
    return data
def derive_class ( data , columns_org ) : np . random . seed ( 5 ) for group in columns_org : indices = np . asarray ( np . where ( data . columns . str . startswith ( group ) ) ) . flatten ( ) . tolist ( ) g_rows = [ ] for col in data . columns [ indices ] : for rows in data . index [ ( ( data . loc [ : , col ] ) < 1 ) & ( data . loc [ : , col ] > 0 ) ] . tolist ( ) : g_rows . append ( rows ) g_rows = set ( g_rows ) for row in g_rows : prob = data . iloc [ row , indices ] . tolist ( ) if sum ( prob ) < 1 : indices . append ( - 1 ) prob . append ( 1 - sum ( prob ) ) choice = np . random . choice ( indices , p = prob ) if - 1 in indices : indices . remove ( - 1 ) data . iloc [ row , indices ] = 0 if choice != - 1 : data . iloc [ row , [ choice ] ] = 1 return data
Uses a KNN imputed Data Frame with fractions, and uses probabilities and random choice generators to impute the missing values.
Uses a KNN imputed Data Frame with fractions and uses probabilities and random choice generators to impute the missing values .
'''
    Uses a KNN imputed Data Frame with fractions, and uses probabilities and random choice generators to impute the missing values.

    Args:
        data: the data before deriving
        columns_org: column names before dummification
    
    Returns:
        Data after deriving the classes
    '''
Data after deriving the classes
Data after deriving the classes
data
the data before deriving
the data before deriving
columns_org
column names before dummification
column names before dummification