Skip to content

ML Templates

Data Preprocessing

Provide a general template to use in ML data preparation.

Processo Padrão:

Informações iniciais - Estatística Descritiva.

Ajuste Dos Tipos Das Variáveis.

Tratamento De Valores Ausentes.

Tratamento Das Variáveis Métricas.

Tratamento Das Variáveis Categóricas.

Verificar Se As Escalas Dos Valores São Similares E Padronizar Os Valores.

Eliminação De Variáveis / Redução De Dimensão.

Verificar o Vazamento De Informação (Data Leakage).

Eliminação De Variáveis Colineares (Alta Correlação).

Verificar possibilidade de utilizar Análise De Componentes Principais (PCA).

@author: Ulf Bergmann

Clusterization

Provide general template to use in Clusterization.

@author: ulf Bergmann

PCA

Provide general template to use in Análise Fatorial PCA.

@author: ulf Bergmann

plot_loading(df, var_list)

Plot loading factors. Parameters


df(DataFrame) : data to be ploted. var_list(list) : variable column name in df.

Returns

None.

Source code in templates\template_pca.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def plot_loading(df , var_list):
    '''Plot loading factors.
    Parameters
    ----------
    df(DataFrame) : data to be ploted.
    var_list(list) : variable column name in df.

    Returns
    -------
    None.

    '''

    plt.figure(figsize=(12,8))
    df_chart = df.reset_index()
    plt.scatter(df_chart[var_list[0]], df_chart[var_list[1]], s=50, color='red')



    label_point(x = df_chart[var_list[0]],
                y = df_chart[var_list[1]],
                val = df_chart['index'],
                ax = plt.gca()) 

    plt.axhline(y=0, color='grey', ls='--')
    plt.axvline(x=0, color='grey', ls='--')
    plt.ylim([-1.1,1.1])
    plt.xlim([-1.1,1.1])
    plt.title("Loading Plot", fontsize=16)
    plt.xlabel(var_list[0], fontsize=12)
    plt.ylabel(var_list[1], fontsize=12)
    plt.show()

ANACOR

Provide general template to use in Análise de Correspondência Simples (ANACOR).

@author: ulf Bergmann

MCA

Provide general template to use in Análise de Correspondência Multipla (MCA).

@author: ulf Bergmann

Show Shapefile

Provide general template to use in Clusterization.

@author: ulf Bergmann