Building a Full-Stack Machine Learning Web Application: Integrating FastAPI, Streamlit

borandabak
3 min readMar 4, 2023

--

Hello everyone, Today we will make a Full-Stack Machine learning application with you.

In this project, we will use Front-End, Back-End and Machine learning algorithms together.

Front-End: Streamlit
Back-End: FastAPI
Machine Learning Algorithm: Logistic Regression, KNN, Decision Tree.

When we examine the diagram above, our user selects the desired machine learning algorithm via Front-End and enters the parameters. Then, it processes the model selected on the Back-End side and the values entered by the user and sends the model result to the Front-End again.

Front-End Streamlit

Here, we simply create a selectbox for our users to select a model, first, after our user selects the Model, we take the input of other parameters required for the model. Then, when we press the predict button, we apply the information entered by the user and send the result to the screen.

Machine Learning Models

Here we create the models that we will use. First, we do the reading of our dataset, then we separate our data by putting the dataset into train_test_split. then we make our model a file with pkl extension by performing the fit operation on our model. Our purpose in doing this is to make it faster while processing our back-end values.

Back-End FastAPI

Here we create 3 endpoints at first. We have 3 models for our user to choose from (Logistic Regression, KNN, Decision Tree). After our user throws these requests, we send a list of other parameters to our model. Thus, after our model has applied all the parameters, we send the result to the front-end.

Conclusion

As a result, making a Full-Stack project using more than one technology and especially new technologies in this project is really enjoyable, as well as making a big project using more than one technology at the same time, it is a great method for personal development. FastAPI is a technology that has really made its mark lately, and its simplicity and speed give the user great pleasure. I hope you enjoyed this project very much, see you in the next project.

Contact me

Linkedin: https://www.linkedin.com/in/boran-oktay-dabak/

Source Code: https://github.com/oktaydbk54/Machine-Learning-Model-Deployment-using-FastAPI-and-Streamlit

Youtube: https://www.youtube.com/channel/UCsGwZ3006CuJWcA5J3UPVWw

--

--