Случайный лес в python, нет корреляции между y_pred и y_test, точность 0,00, confusion_matrix со всеми 0 - PullRequest
0 голосов
/ 07 апреля 2020

Я пытался предсказать, какой параметр (и какой элемент является лучшим) важнее для улучшения моей переменной y.

Я пробовал случайный лес

X_train, X_test, y_train, y_test = train_test_split(X,y, test_size=0.20)
classifier = RandomForestClassifier(n_estimators = 20, criterion="gini", random_state=1, max_depth=3)
classifier.fit(X_train,y_train)

, а также пытался:

regressor = RandomForestRegressor(n_estimators=100, random_state=42)
regressor.fit(X_train, y_train)
y_pred = regressor.predict(X_test)

когда я строю график y_pred, я получаю здесь нормальный график и добавляю два графика y_pred: y_pred_1 из одних данных, y_pred_2 из других данных

y_pred_1 y_pred_2

Но сюжет y_test очень странный, и я не знаю, почему y_test_1 y_test_2

и оба test and pred plot: plot

конечно матрица путаницы, точность и т. д. все будет 0 что-то с y_test неверно

y_test_2 равно:

array(['0.2798', '0.3745', '0.4458', '0.6409', '0.2008', '0.1481',
   '0.5415', '0.1255', '0.2372', '0.1646', '0.5179', '0.0479',
   '0.2590', '0.4734', '0.1051', '0.1568', '0.5210', '0.2272',
   '0.0845', '0.0842', '0.2232', '0.6708', '0.3703', '0.2263',
   '0.4666', '0.3780', '0.2018', '0.4296', '0.2782', '0.3126',
   '0.4120', '0.1389', '0.2909', '0.3245', '0.3955', '0.1265',
   '0.2598', '0.2022', '0.2044', '0.4524', '0.2853', '0.1772',
   '0.3758', '0.0892', '0.4653', '0.2776', '0.4056', '0.3666',
   '0.3798', '0.4629', '0.3397', '0.2002', '0.1804', '0.3841',
   '0.3149', '0.0975', '0.2644', '0.1002', '0.1459', '0.1462',
   '0.5293', '0.2901', '0.4382', '0.0589', '0.5239', '0.0526',
   '0.0704', '0.5252', '0.5351', '0.4999', '0.3419', '0.3938',
   '0.3651', '0.2722', '0.1939', '0.4264', '0.2683', '0.1351',
   '0.1878', '0.0759', '0.4102', '0.6946', '0.3741', '0.5791',
   '0.2315', '0.2908', '0.4303', '0.4977', '0.3117', '0.3494',
   '0.0497', '0.1350', '0.4025', '0.5492', '0.4920', '0.2209',
   '0.4768', '0.4797', '0.0291', '0.2901', '0.4204', '0.4059',
   '0.4822', '0.3046', '0.1985', '0.2648', '0.0482', '0.0497',
   '0.1598', '0.0883', '0.2078', '0.1460', '0.2704', '0.6942',
   '0.4012', '0.1113', '0.3416', '0.4390', '0.1829', '0.0554',
   '0.5297', '0.1918', '0.3959', '0.2974', '0.4829', '0.4338',
   '0.2389', '0.4905', '0.0988', '0.2580', '0.5359', '0.0466',
   '0.3206', '0.3551', '0.2265', '0.4554', '0.2063', '0.1347',
   '0.2026', '0.5615', '0.0366', '0.6326', '0.4696', '0.3145',
   '0.5138', '0.1837', '0.1634', '0.3889', '0.2346', '0.4947',
   '0.0427', '0.4529', '0.0213', '0.4357', '0.1127', '0.5801',
   '0.2593', '0.5576', '0.5619', '0.3195', '0.3656', '0.2440',
   '0.6239', '0.4062', '0.4396', '0.3382', '0.1883', '0.4027',
   '0.4049', '0.3805', '0.1792', '0.1030', '0.0082', '0.0220',
   '0.2610', '0.3016', '0.4545', '0.1541', '0.2340', '0.5803',
   '0.4739', '0.0645', '0.2367', '0.1511', '0.1137', '0.2078',
   '0.1861', '0.3030', '0.5843', '0.2270', '0.1935', '0.7468',
   '0.5152', '0.4301', '0.0426', '0.0476', '0.5879', '0.2396',
   '0.3967'], dtype=object)

y_pred_2:

array(['0.1163', '0.1523', '0.1163', '0.1163', '0.1163', '0.2097',
   '0.1163', '0.1980', '0.1163', '0.1163', '0.1163', '0.1163',
   '0.2206', '0.1163', '0.1163', '0.1523', '0.1523', '0.1163',
   '0.1163', '0.1163', '0.4723', '0.1163', '0.1163', '0.1163',
   '0.2496', '0.1163', '0.1460', '0.1163', '0.1163', '0.1406',
   '0.1163', '0.2496', '0.1564', '0.1163', '0.1163', '0.1163',
   '0.1163', '0.1163', '0.1163', '0.1163', '0.1523', '0.4027',
   '0.1163', '0.1163', '0.1163', '0.1163', '0.1163', '0.1163',
   '0.1163', '0.1163', '0.1163', '0.1163', '0.1523', '0.1523',
   '0.1163', '0.1163', '0.3019', '0.1163', '0.1163', '0.1163',
   '0.1163', '0.1163', '0.0193', '0.1163', '0.1163', '0.1163',
   '0.1163', '0.1163', '0.1523', '0.1184', '0.1163', '0.1163',
   '0.2583', '0.1163', '0.1163', '0.1163', '0.4497', '0.2894',
   '0.2059', '0.1163', '0.1163', '0.1163', '0.1163', '0.1163',
   '0.1163', '0.1163', '0.1163', '0.1163', '0.1163', '0.1163',
   '0.1163', '0.1163', '0.1163', '0.1163', '0.1163', '0.3213',
   '0.1163', '0.1163', '0.2583', '0.1163', '0.1163', '0.1163',
   '0.1419', '0.1163', '0.1163', '0.1163', '0.1163', '0.1163',
   '0.1163', '0.1163', '0.1163', '0.1163', '0.4301', '0.1163',
   '0.1523', '0.1163', '0.1163', '0.1163', '0.1163', '0.1163',
   '0.3213', '0.1163', '0.1163', '0.1163', '0.1163', '0.1163',
   '0.5660', '0.1163', '0.1410', '0.1163', '0.3319', '0.1163',
   '0.4027', '0.1564', '0.1163', '0.1163', '0.2760', '0.1163',
   '0.1163', '0.5660', '0.1523', '0.1163', '0.1163', '0.1163',
   '0.1163', '0.1163', '0.1163', '0.1564', '0.1163', '0.1163',
   '0.4999', '0.1523', '0.2404', '0.1163', '0.1163', '0.1163',
   '0.1163', '0.1419', '0.1163', '0.1163', '0.1163', '0.1163',
   '0.1163', '0.1163', '0.2346', '0.4933', '0.1163', '0.1163',
   '0.3019', '0.7080', '0.7080', '0.1163', '0.2496', '0.1163',
   '0.2355', '0.1163', '0.1163', '0.1163', '0.1163', '0.1163',
   '0.1163', '0.1163', '0.3019', '0.1163', '0.1163', '0.4301',
   '0.1163', '0.1163', '0.1163', '0.5660', '0.1163', '0.1163',
   '0.1163', '0.1163', '0.1184', '0.1163', '0.1163', '0.1163',
   '0.1163'], dtype=object)
...