xgboost: AttributeError: 'DMatrix' - Objekt hat kein Attribut 'Griff'

Das problem ist wirklich seltsam, denn das Stück funktionierte sehr gut mit anderen dataset.

Der vollständige code:

import numpy as np
import pandas as pd
import xgboost as xgb
from sklearn.cross_validation import train_test_split

# # Split the Learning Set
X_fit, X_eval, y_fit, y_eval= train_test_split(
    train, target, test_size=0.2, random_state=1
)

clf = xgb.XGBClassifier(missing=np.nan, max_depth=6, 
                        n_estimators=5, learning_rate=0.15, 
                        subsample=1, colsample_bytree=0.9, seed=1400)

# fitting
clf.fit(X_fit, y_fit, early_stopping_rounds=50, eval_metric="logloss", eval_set=[(X_eval, y_eval)])
#print y_pred
y_pred= clf.predict_proba(test)[:,1]

Letzten Zeile die den Fehler verursacht, unten (voller Ausgang):

Will train until validation_0 error hasn't decreased in 50 rounds.
[0] validation_0-logloss:0.554366
[1] validation_0-logloss:0.451454
[2] validation_0-logloss:0.372142
[3] validation_0-logloss:0.309450
[4] validation_0-logloss:0.259002
Traceback (most recent call last):
  File "../src/script.py", line 57, in 
    y_pred= clf.predict_proba(test)[:,1]
  File "/opt/conda/lib/python3.4/site-packages/xgboost-0.4-py3.4.egg/xgboost/sklearn.py", line 435, in predict_proba
    test_dmatrix = DMatrix(data, missing=self.missing)
  File "/opt/conda/lib/python3.4/site-packages/xgboost-0.4-py3.4.egg/xgboost/core.py", line 220, in __init__
    feature_types)
  File "/opt/conda/lib/python3.4/site-packages/xgboost-0.4-py3.4.egg/xgboost/core.py", line 147, in _maybe_pandas_data
    raise ValueError('DataFrame.dtypes for data must be int, float or bool')
ValueError: DataFrame.dtypes for data must be int, float or bool
Exception ignored in: >
Traceback (most recent call last):
  File "/opt/conda/lib/python3.4/site-packages/xgboost-0.4-py3.4.egg/xgboost/core.py", line 289, in __del__
    _check_call(_LIB.XGDMatrixFree(self.handle))
AttributeError: 'DMatrix' object has no attribute 'handle'

Was ist hier falsch? Ich habe keine Ahnung, wie das zu reparieren

UPD1: acctually dem das ist kaggle problem: https://www.kaggle.com/insaff/bnp-paribas-cardif-claims-management/xgboost

was ist die Ausgabe von X_fit.dtypes und X_eval.dtypes?
Dies ist für X_fit.dtypes Ziel int64 v1 float64 v2 float64 v3 int64 v4 float64 ; test hat sogar Objekttyp

InformationsquelleAutor Rocketq | 2016-03-17

Schreibe einen Kommentar