title: Trying to load model.pickle to API but raise ```AttributeError: 'Data' object has no attribute 'columns'```
body: <p>I have build a classification model using pycaret and already produced the pickle file. Then, I tried to build an API and load the pickle file using fastapi.</p>
  <pre class="lang-py prettyprint-override"><code>import logging
  import pickle
  from pydantic import BaseModel
  import numpy as np
  from pycaret.classification import *
  
  import uvicorn
  from fastapi import FastAPI
  from fastapi import Depends
  
  
  app = FastAPI()
  
  model = load_model('catboost_cm_creditable')
  
  class Data(BaseModel):
      age: float
      live_province: str
      live_city: str
      live_area_big: str
      live_area_small: str
      sex: float
      marital: float
      bank: str
      salary: float
      amount: float
  
  
  @app.post(&quot;/predict&quot;)
  def predict(data: Data = Depends()):
      predictions_df = predict_model(estimator=model, data=data)
      predictions = predictions_df[&quot;Score&quot;][0]
      return predictions
  </code></pre>
  <p>The api run flawlessly, but the things is when I tried to test the api and giving it inputs based on the features it returns:</p>
  <pre><code>INFO:     127.0.0.1:60235 - &quot;POST /predict?age=24&amp;live_province=DKI%20Jakarta&amp;live_city=Jakarta%20Selatan&amp;live_area_big=Pesanggrahan&amp;live_area_small=Bintaro&amp;sex=1&amp;marital=2&amp;bank=BCA&amp;salary=7000000&amp;amount=1000000 HTTP/1.1&quot; 500 Internal Server Error
  ERROR:    Exception in ASGI application
  Traceback (most recent call last):
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py&quot;, line 390, in run_asgi
      result = await app(self.scope, self.receive, self.send)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py&quot;, line 45, in __call__
      return await self.app(scope, receive, send)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/fastapi/applications.py&quot;, line 179, in __call__
      await super().__call__(scope, receive, send)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/starlette/applications.py&quot;, line 111, in __call__
      await self.middleware_stack(scope, receive, send)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/starlette/middleware/errors.py&quot;, line 181, in __call__
      raise exc from None
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/starlette/middleware/errors.py&quot;, line 159, in __call__
      await self.app(scope, receive, _send)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/starlette/exceptions.py&quot;, line 82, in __call__
      raise exc from None
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/starlette/exceptions.py&quot;, line 71, in __call__
      await self.app(scope, receive, sender)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/starlette/routing.py&quot;, line 566, in __call__
      await route.handle(scope, receive, send)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/starlette/routing.py&quot;, line 227, in handle
      await self.app(scope, receive, send)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/starlette/routing.py&quot;, line 41, in app
      response = await func(request)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/fastapi/routing.py&quot;, line 183, in app
      dependant=dependant, values=values, is_coroutine=is_coroutine
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/fastapi/routing.py&quot;, line 135, in run_endpoint_function
      return await run_in_threadpool(dependant.call, **values)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/starlette/concurrency.py&quot;, line 34, in run_in_threadpool
      return await loop.run_in_executor(None, func, *args)
    File &quot;/Users/bhaskoromuthohar/anaconda3/lib/python3.7/concurrent/futures/thread.py&quot;, line 57, in run
      result = self.fn(*self.args, **self.kwargs)
    File &quot;./main.py&quot;, line 31, in predict
      predictions_df = predict_model(estimator=model, data=data)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/pycaret/classification.py&quot;, line 10700, in predict_model
      Xtest = prep_pipe_transformer.transform(data)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/sklearn/pipeline.py&quot;, line 549, in _transform
      Xt = transform.transform(Xt)
    File &quot;/Users/bhaskoromuthohar/dev/Credit-Scoring-App/.venv/lib/python3.7/site-packages/pycaret/preprocess.py&quot;, line 300, in transform
      data.columns = [str(i) for i in data.columns]
  AttributeError: 'Data' object has no attribute 'columns'
  </code></pre>
  <blockquote>
  <p>! Output from the fastapi documentations
  <a href="https://i.stack.imgur.com/TEyms.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TEyms.png" alt="enter image description here" /></a></p>
  </blockquote>
  <p>I think the problem is the way I load the pickle into the API. Can you guys give me advice for correct way to load the pickle?</p>