Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so dont bother with any of their useless mail servers here and just use oauth login instead. Thank the nice Russians for causing that. :)

Paste

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

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

print(modelo_log_sm.summary2())


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: