title: How to fix X does not have valid feature names, but IsolationForest was fitted with feature names warnings.warn(
body: <p>Here is my code:</p>
  <pre><code>import numpy as np
  import pandas as pd
  import seaborn as sns
  from sklearn.ensemble import IsolationForest
  
  data = pd.read_csv('marks1.csv', encoding='latin-1',
                     on_bad_lines='skip', index_col=0, header=0
                     )
  
  random_state = np.random.RandomState(42)
  
  model = IsolationForest(n_estimators=100, max_samples='auto', contamination=float(0.2)
                          , random_state=random_state)
  
  model.fit(data[['Mark']])
  
  random_state = np.random.RandomState(42)
  
  data['scores'] = model.decision_function(data[['Mark']])
  
  data['anomaly_score'] = model.predict(data[['Mark']])
  
  data[data['anomaly_score'] == -1].head()
  </code></pre>
  <p>Error:</p>
  <blockquote>
  <p>C:\Program Files\Python39\lib\site-packages\sklearn\base.py:450: UserWarning: X does not have valid feature names, but IsolationForest was fitted with feature names
  warnings.warn(</p>
  </blockquote>