[(0, 'id'),
(1, 'comment_text'),
(2, 'toxic'),
(3, 'severe_toxic'),
(4, 'obscene'),
(5, 'threat'),
(6, 'insult'),
(7, 'identity_hate'),
(8, 'message_length'),
(9, 'caps'),
(10, 'elipsis'),
(11, 'exclamation'),
(12, 'commas'),
(13, 'comment_clean')]
# Create pipelines
pipe1 = make_pipeline(ColumnSelector(cols=(13,)),
CountVectorizer(),
DenseTransformer(),
MultinomialNB()
)
pipe2 = make_pipeline(ColumnSelector(cols=(2,3,4,5,6,7,8,9,10,11,12)),
RandomForestClassifier()
)
# Stack
sclf = StackingClassifier(classifiers=[pipe1, pipe2],
meta_classifier=LogisticRegression()
)
sclf.fit(X_train, y_train)
Error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-230-c98b763c8ccf> in <module>()
3 )
4
----> 5 sclf.fit(X_train, y_train)
~/anaconda2/envs/sb/lib/python3.6/site-packages/mlxtend/classifier/stacking_classification.py in fit(self, X, y)
124 print(_name_estimators((clf,))[0][1])
125
--> 126 clf.fit(X, y)
127
128 meta_features = self.predict_meta_features(X)
~/anaconda2/envs/sb/lib/python3.6/site-packages/sklearn/pipeline.py in fit(self, X, y, **fit_params)
246 This estimator
247 """
--> 248 Xt, fit_params = self._fit(X, y, **fit_params)
249 if self._final_estimator is not None:
250 self._final_estimator.fit(Xt, y, **fit_params)
~/anaconda2/envs/sb/lib/python3.6/site-packages/sklearn/pipeline.py in _fit(self, X, y, **fit_params)
211 Xt, fitted_transformer = fit_transform_one_cached(
212 cloned_transformer, None, Xt, y,
--> 213 **fit_params_steps[name])
214 # Replace the transformer of the step with the fitted
215 # transformer. This is necessary when loading the transformer
~/anaconda2/envs/sb/lib/python3.6/site-packages/sklearn/externals/joblib/memory.py in __call__(self, *args, **kwargs)
360
361 def __call__(self, *args, **kwargs):
--> 362 return self.func(*args, **kwargs)
363
364 def call_and_shelve(self, *args, **kwargs):
~/anaconda2/envs/sb/lib/python3.6/site-packages/sklearn/pipeline.py in _fit_transform_one(transformer, weight, X, y, **fit_params)
579 **fit_params):
580 if hasattr(transformer, 'fit_transform'):
--> 581 res = transformer.fit_transform(X, y, **fit_params)
582 else:
583 res = transformer.fit(X, y, **fit_params).transform(X)
~/anaconda2/envs/sb/lib/python3.6/site-packages/sklearn/feature_extraction/text.py in fit_transform(self, raw_documents, y)
867
868 vocabulary, X = self._count_vocab(raw_documents,
--> 869 self.fixed_vocabulary_)
870
871 if self.binary:
~/anaconda2/envs/sb/lib/python3.6/site-packages/sklearn/feature_extraction/text.py in _count_vocab(self, raw_documents, fixed_vocab)
790 for doc in raw_documents:
791 feature_counter = {}
--> 792 for feature in analyze(doc):
793 try:
794 feature_idx = vocabulary[feature]
~/anaconda2/envs/sb/lib/python3.6/site-packages/sklearn/feature_extraction/text.py in <lambda>(doc)
264
265 return lambda doc: self._word_ngrams(
--> 266 tokenize(preprocess(self.decode(doc))), stop_words)
267
268 else:
~/anaconda2/envs/sb/lib/python3.6/site-packages/sklearn/feature_extraction/text.py in <lambda>(x)
230
231 if self.lowercase:
--> 232 return lambda x: strip_accents(x.lower())
233 else:
234 return strip_accents
AttributeError: 'numpy.ndarray' object has no attribute 'lower'