TypeError: Expected sequence or array-like, got estimator
<p>I am working on a project that has user reviews on products. I am using TfidfVectorizer to extract features from my dataset apart from some other features that I have extracted manually.</p>
<pre><code>df = pd.read_csv('reviews.csv', header=0)

FEATURES = ['feature1', 'feature2']
reviews = df['review']
reviews = reviews.values.flatten()

vectorizer = TfidfVectorizer(min_df=1, decode_error='ignore', ngram_range=(1, 3), stop_words='english', max_features=45)

X = vectorizer.fit_transform(reviews)
idf = vectorizer.idf_
features = vectorizer.get_feature_names()
FEATURES += features
inverse =  vectorizer.inverse_transform(X)
  
for i, row in df.iterrows():
   for f in features:
      df.set_value(i, f, False)
      for inv in inverse[i]:
        df.set_value(i, inv, True)

train_df, test_df = train_test_split(df, test_size = 0.2, random_state=700)
</code></pre>
<p>The above code works fine. But when I change the <code>max_features</code> from 45 to anything higher I get an error on <code>tran_test_split</code> line.</p>
<p>Traceback as follows:</p>
<pre><code>Traceback (most recent call last):
  File &quot;analysis.py&quot;, line 120, in &lt;module&gt;
    train_df, test_df = train_test_split(df, test_size = 0.2, random_state=700)
  File &quot;/Users/user/Tools/anaconda/lib/python2.7/site-packages/sklearn/cross_validation.py&quot;, line 1906, in train_test_split
    arrays = indexable(*arrays)
  File &quot;/Users/user/Tools/anaconda/lib/python2.7/site-packages/sklearn/utils/validation.py&quot;, line 201, in indexable
    check_consistent_length(*result)
  File &quot;/Users/user/Tools/anaconda/lib/python2.7/site-packages/sklearn/utils/validation.py&quot;, line 173, in check_consistent_length
    uniques = np.unique([_num_samples(X) for X in arrays if X is not None])
  File &quot;/Users/user/Tools/anaconda/lib/python2.7/site-packages/sklearn/utils/validation.py&quot;, line 112, in _num_samples
    'estimator %s' % x)
TypeError: Expected sequence or array-like, got estimator
</code></pre>
<p>I am not sure what exactly is changing when I change increase the <code>max_features</code> size.</p>
<p>Let me know if you need more data or if I have missed something</p>