tradaboost icon indicating copy to clipboard operation
tradaboost copied to clipboard

处理缺失值问题

Open JJMLeo opened this issue 5 years ago • 1 comments

1、请问处理缺失值为什么用这个语句呢?

train_df.fillna(value=-999999)

2、不知道是不是我设置的内存不够,运行程序的时候还是报错

Traceback (most recent call last):
  File "Tradaboost_GitHub.py", line 98, in <module>
    pred = tr.tradaboost(X_train, trans_T, y_train, label_T, X_test, 10)
  File "TrAdaboost.py", line 44, in tradaboost
    result_label[:, i] = train_classify(trans_data, trans_label,test_data, P)
  File "TrAdaboost.py", line 89, in train_classify
    clf.fit(trans_data, trans_label, sample_weight=P[:, 0])
  File "sklearn\tree\tree.py", line 790, in fit
    X_idx_sorted=X_idx_sorted)
  File "sklearn\tree\tree.py", line 117, in fit
    y = check_array(y, ensure_2d=False, dtype=None)
  File "sklearn\utils\validation.py", line 422, in check_array
    _assert_all_finite(array)
  File "sklearn\utils\validation.py", line 43, in _assert_all_finite
    " or a value too large for %r." % X.dtype)
ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

非常感谢给出源代码!

JJMLeo avatar Apr 19 '19 02:04 JJMLeo

The problem is solved. I used the following code to process missing values. df.fillna(value=-999999,inplace=True)

JJMLeo avatar Apr 29 '19 05:04 JJMLeo