 # 使用logisticRegression模型跑出來得結果會不相同 - Cupoy

# 空值補 -1, 做羅吉斯迴歸df_m1 = df.fillna(-1)train_X = df_...

ml100-3,ml100-3-d12

### 使用logisticRegression模型跑出來得結果會不相同

2019/09/19 11:04 AM

herohsu

ml100-3
ml100-3-d12

`# 空值補 -1, 做羅吉斯迴歸df_m1 = df.fillna(-1)train_X = df_m1[:train_num]estimator = LogisticRegression(solver='lbfgs', multi_class='auto')cross1 = cross_val_score(estimator, train_X, train_Y, cv=5).mean()print( 'The accuracy fills with -1 when na found: ', cross1 )df_m2 = df.fillna(0)train_X2 = df_m2[:train_num]#estimator = LogisticRegression(solver='lbfgs', multi_class='auto')cross2 = cross_val_score(estimator, train_X2, train_Y, cv=5).mean()print( 'The accuracy fills with 0 when na found: ', cross2 )df_m3 = df.fillna(df.mean())train_X3 = df_m3[:train_num]#estimator = LogisticRegression(solver='lbfgs', multi_class='auto')cross3 = cross_val_score(estimator, train_X3, train_Y, cv=5).mean()print( 'The accuracy fills with mean when na found: ', cross3 )'''The accuracy fills with -1 when na found:  0.6982644788418415The accuracy fills with 0 when na found:  0.6993817972775958The accuracy fills with mean when na found:  0.6959413955734954效果最好當fillna = 0'''`