Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as Python by registered user vvillacorta ( 3 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