sklearn

时间:2018-08-14 09:09:44

标签: python scikit-learn

sklearn中探索管道时,我注意到Pipeline类目前不支持构建仅分类器管道。

为了更加清楚,我需要做的是这样的事情:

from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.pipeline import Pipeline

pipeline = Pipeline(
    ('logreg', LogisticRegression()),
    ('random_clf', RandomForestClassifier()))

以上内容引发了错误:

TypeError: All intermediate steps should be transformers and implement fit and transform.
  "RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
            max_depth=None, max_features='auto', max_leaf_nodes=None,
            min_impurity_decrease=0.0, min_impurity_split=None,
            min_samples_leaf=1, min_samples_split=2,
            min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
            oob_score=False, random_state=None, verbose=0,
            warm_start=False)"
  (type <class 'sklearn.ensemble.forest.RandomForestClassifier'>) doesn't 

这是设计决定吗?

有没有办法做到这一点?我偶然发现了imblearn'的{​​{1}}类here,但这似乎也没有满足我的要求。

0 个答案:

没有答案