Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!


Pasted as Python by registered user vvillacorta ( 2 years ago )
import statsmodels.api as sm

logit_model = sm.Logit(train[target], X_train_scaler)
modelo_log_sm = logit_model.fit()


def calcular_pesos(modelo, new_cols_select):
    coef_model = pd.DataFrame(modelo.tvalues,columns=['t_value']).reset_index()
    coef_model['t_value2'] = np.power(coef_model['t_value'],2)
    coef_model['total'] = sum(coef_model['t_value2'])
    coef_model['part'] = coef_model['t_value2'] / coef_model['total']
    coef_model['pesos'] = coef_model['part'] * 100
    coef_model['variable'] = coef_model['index'].apply(lambda _: new_cols_select[int(_.replace('x', '')) - 1])
    return coef_model.sort_values(['pesos'], ascending=False)

calcular_pesos(modelo_log_sm, seleccionadas)


Revise this Paste

Your Name: Code Language: