title: Value Error: y contains previously unseen labels:
body: <p>I've used <code>Decision Tree Classifier</code> and I want to enter my <code>input</code> as a <code>string</code> rather than giving an <code>integer</code>
  value, but it gives me <code>error</code> like:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;D:/backup code for odoo project/New folder/New folder/main.py&quot;, line 38, in &lt;module&gt;
      theme_res = lebel_encoder.transform(theme_input)
    File &quot;C:\Users\Dell\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\preprocessing\_label.py&quot;, line 277, in transform
      _, y = _encode(y, uniques=self.classes_, encode=True)
    File &quot;C:\Users\Dell\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\preprocessing\_label.py&quot;, line 121, in _encode
      return _encode_numpy(values, uniques, encode,
    File &quot;C:\Users\Dell\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\preprocessing\_label.py&quot;, line 50, in _encode_numpy
      raise ValueError(&quot;y contains previously unseen labels: %s&quot;
  ValueError: y contains previously unseen labels: ['Food', 'cafe', 'sticky'] 
  </code></pre>
  <p>Code:</p>
  <pre><code>import pandas as pd
  from sklearn.preprocessing import LabelEncoder
  from sklearn import tree
  df = pd.read_csv(&quot;new_data.csv&quot;, encoding='latin1')
  
  inputs = df.drop('selected_theme', axis='columns')
  target = df['selected_theme']
  
  lebel_encoder = LabelEncoder()
  
  inputs['main_cat_n'] = lebel_encoder.fit_transform(inputs['main_cat'])
  inputs['sub_cat_n'] = lebel_encoder.fit_transform(inputs['sub_cat'])
  inputs['nav_bar_n'] = lebel_encoder.fit_transform(inputs['nav_bar'])
  
  inputs_n = inputs.drop(['main_cat', 'sub_cat', 'nav_bar'], axis='columns')
  
   model = tree.DecisionTreeClassifier()
   model.fit(inputs_n, target)
   print(model.score(inputs_n, target))
  
   theme_input = ['Food', 'cafe', 'sticky']
   theme_res = lebel_encoder.transform(theme_input)
   result_theme = model.predict(theme_res)
   print(result_theme)
  </code></pre>