title: Getting error "AttributeError: 'numpy.ndarray' object has no attribute 'lower' " in word tokenizer
body: <p>I am trying to train a model to classify multi-label data set by referring <a href="https://stackabuse.com/python-for-nlp-multi-label-text-classification-with-keras/" rel="nofollow noreferrer">this</a> article. I am entirely new to this field and I am getting this error &quot;AttributeError: 'numpy.ndarray' object has no attribute 'lower'&quot;</p>
  <p>Here is my code</p>
  <pre><code>reviews = pd.read_csv(&quot;/content/drive/My Drive/Interim Project Data/score.csv&quot;)
  
  Review_labels = reviews[[&quot;natral score&quot;, &quot;man-made score&quot;, &quot;sport score&quot;, &quot;special event score&quot;]]
  Review_labels.head()
  
  def preprocess_text(sen):
      # Remove punctuations and numbers
      sentence = re.sub('[^a-zA-Z]', ' ', sen)
      sentence = re.sub(r&quot;\s+[a-zA-Z]\s+&quot;, ' ', sentence)
      sentence = re.sub(r'\s+', ' ', sentence)
      return sentence
  
  X = []
  sentences = list(reviews[&quot;User Review&quot;])
  for sen in sentences:
      X.append(preprocess_text(sen))
  
  y = Review_labels.values
  
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=123)
  print(len(X_train))
  print(len(X_test))
  
  from numpy import array
  from keras.preprocessing.sequence import pad_sequences
  from keras.preprocessing.text import Tokenizer
  
  
  tokenizer = Tokenizer(num_words=5000)
  tokenizer.fit_on_texts(X)
  
  X_train = tokenizer.texts_to_sequences(X_train)
  X_test = tokenizer.texts_to_sequences(X_test)
  </code></pre>
  <p>The error is here</p>
  <pre><code>---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  &lt;ipython-input-128-ff374d8c5eb4&gt; in &lt;module&gt;()
        7 tokenizer.fit_on_texts(X)
        8 
  ----&gt; 9 X_train = tokenizer.texts_to_sequences(X_train)
       10 X_test = tokenizer.texts_to_sequences(X_test)
       11 
  
  2 frames
  /usr/local/lib/python3.6/dist-packages/keras_preprocessing/text.py in text_to_word_sequence(text, filters, lower, split)
       41     &quot;&quot;&quot;
       42     if lower:
  ---&gt; 43         text = text.lower()
       44 
       45     if sys.version_info &lt; (3,):
  
  AttributeError: 'numpy.ndarray' object has no attribute 'lower'
  </code></pre>
  <p><a href="https://drive.google.com/file/d/1z7oPHzcA0QTdCRT3VUDxXyUPN57Q86OW/view?usp=sharing" rel="nofollow noreferrer">here is the data set that I used in the code</a></p>
  <p>It will be really helpful if someone can help with this issue.</p>