Skip to main content

Streamlit Python Machine Learning Web App

Machine learning is a subfield of artificial intelligence (AI). The goal of machine learning generally is to understand the structure of data and fit that data into models that can be understood and utilised by people. Two of the most widely adopted machine learning methods are supervised learning and unsupervised learning.

Supervised Learning

Supervised learning works as a supervisor or teacher. Basically, In supervised learning, we teach or train the machine with labeled data (that means data is already tagged with some predefined class). Then we test our model with some unknown new set of data and predict the level of them.

Types of supervised learning:

  • Regression: Predicts continuous outcome
  • Classification: Predicts categorical outcome. (Outcome=Yes or No, Black or White)

Unsupervised Learning

In unsupervised learning there would be no correct answer and no teacher for guidance. Algorithms need to discover the interesting pattern in data for learning.

In my model I have used Random Forest Classification model for training my data. I have taken a small dataset which is listed below. In this data set we have five training features (Overall Grade, Obedient, Assignment, Project Score, Research Score) and one output feature (Recommend). The output will be predicted based on these five training features. 


Dataset for machine learning web app







I have trained the model over the training features and predicted the output for my test dataset. After that I have calculated the accuracy of my model. After the model is ready, we need to save it. Pickle is the standard way of serializing objects in python. I have used the pickle operation to serialize my machine learning model and saved the serialized format to a file (filename.pkl). Later I have loaded this file to deserialize my model and used it to make new predictions.

Now I have written a streamlit code to built my machine learning web app. I have saved this file as test_app.py. To run this app we need to type streamlit run test_app.py  in the anaconda prompt. The output of new prediction and the web page is listed below.

Streamlit python web application

This is my machine learning trial web app with small data set. My new machine learning web app with large dataset and new machine learning model will be comming soon.

Keep reading!!





Comments

Popular posts from this blog

Salary Prediction Web App using Streamlit

Salary Prediction Web App In this article, we are going to discuss how to predict the salary based on various attributes related to salary  using Random Forest Regression. This study focuses on a system that predicts the salary of a candidate based on candidate’s qualifications, historical data, and work experience. This app uses a machine learning algorithm to give the result. The algorithm used is Random Forest Regression. In this problem, the target variable (or output), y, takes value of salary for a given set of input features (or inputs), X. The dataset contains gender, secondary school percentage, higher secondary school percentage, higher secondary school stream, degree percentage, degree type, work experience and specialization of candidate. Below is the step-by-step Approach: Step 1: Import the necessary modules and read the dataset we are going to use for this analysis. Below is a screenshot of the dataset we used in our analysis. Step 2: Now before moving ...

STREAMLIT MULTIPAGE WEB APPLICATION | AREA CALCULATOR

Multipage Web App So far, we have worked with python streamlit library and we have built machine learning web applications using streamlit. In this blog we will see how to build a multi-page web app using streamlit. Streamlit multipage web app We can create multiple apps and navigate across each of them in a main app using a radio button. First, we have created separate apps for each shape to calculate the area of that particular shape example app1.py, app2.py, app3.py etc. Then we have created a main app and added a navigator using radio buttons. Now we just have to run the main app and navigate through the desired web page. Area Calculator This particular multipage web app we named it as area calculator. We have included introduction page and ten shapes of which we can calculate the area by putting required inputs. We have downloaded the multiapp.py framework from GitHub, as we have a greater number of web pages. Each shape in the navigation bar indicates new web p...