Getting the Machine Learning Model Ready for Go-Live with Fast-API

Creating machine learning models that we create with Jupyter notebook or R studio is only a very small part of the data science cycle. As long as we cannot bring our models to life, we will not be able to create any added value. Therefore, the work of bringing the created model to life rather than creating a model is very valuable. In this article, I will prepare a guide on how to bring a machine learning model to life. In this article, I used the Titanic dataset for the model. My main goal is to enter the information of the passengers on the titanic ship, and we will be predicting whether they will survive the crash. We created and saved our model with the "model_creation" notebook.

Fast-API

Setup

  1. pip install fastapi
  2. pip install uvicorn[standard]

An example fast api file;

Operation;

  • When "uvicorn main:app –reload" is typed into the terminal, the server starts to run.
  • The feature that we will use most in Fast-API is that it actually provides us with a ready-made interface. This is achieved with http://127.0.0.1:8000/docs.
  • Now, let's take the machine learning model we created live with Fast-API.

  • When it is run, we provide access to the Fast-API interface with the address http://127.0.0.1:8000/docs.

  • The “predict_is_survived” function we created appears. First of all, when we click on post and then try it out, we can see the parameters of our model. We defined them inside the function.

  • After we say Execute, our model runs and gives information about whether we will survive or not.

  • Unfortunately, we cannot survive when the above information is entered into the variables. Generating the model and details are on github.

Stay Informed!

By signing up for our e-bulletin, you can be informed about all our innovations.

"We use cookies to personalize and improve your Sisasoft Website usage experience. By making your visit with default settings, you accept the use of cookies as specified in Sisasoft's

Privacy Policy
0312 227 06 34