Rahul Banerjee
Just an average computer engineering student 💻 I mostly write ‘How to’ tutorials related to Python. https://www.linkedin.com/in/rahulbanerjee2699/

PuLP is a python library which can be used to solve linear programming problems. Linear Programming is used to solve optimization problems and has uses in various industries such as Manufacturing, Transportation, Food Diets etc

Image for post
Image for post
Photo by Emile Perron on Unsplash

A basic Linear Programming problem is where we are given multiple equations. The value of one of the equations has to be maximized or minimized while the other equations are constraints. In high school, we used to plot the equations on a graph, shade the feasible region and find the value of the equation to be maximized or minimized by substituting the variables with the verticle values of the shaded region. I briefly go over this technique in the first part of the tutorial

I will be dividing the tutorial into two parts


If you have worked with Python you must be familiar with the pip command used to install packages. This article will show you how to create a wheel file for your custom packages and import it in other projects.

Image for post
Image for post
Photo by Jon Cartagena on Unsplash

When you use pip to install modules or packages, you must have unknowingly installed a few wheel files as well. A wheel file is similar to a zip file in many ways, you compress all your python files and dependencies into a single file. You can use this file in different projects or the cloud. Installing a wheel file is as simples as installing a package using pip. They can also be helpful when you are collaborating with others or when you need to deploy your projects.

Setup Virtual Environment

pip install virtualenv /* Install virtual environment */
virtualenv venv /* Create a virtual environment */
venv/Scripts/activate /* Activate the virtual environment…


Legendary or not, Pokemon will always be awesome but it does help when you have a Moltres on your side instead of a Metapod. Use streamlit, seaborn and scikit-learn to build a webapp to predict if a pokemon is legendary or not.

Image for post
Image for post
Screencast of Streamlit WebApp

In this tutorial, we will be working with Pokemon Dataset. We will be using seaborn for the visualizations and RandomForest to build our model. View the website live

Setup Virtual Environment

pip install virtualenv /* Install virtual environment */
virtualenv venv /* Create a virtual environment */
venv/Scripts/activate /* Activate the virtual environment */

Install Libraries

Make sure your virtual environment is activated before installing the libraries

pip install streamlit, seaborn, scikit-learn

Import the Libraries

import streamlit as st
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import confusion_matrix , accuracy_score, precision_score, recall_score

We import streamlit, seaborn and models, metrics from sci-kit-learn. …


Let’s build a web app using Streamlit and sklearn

Image for post
Image for post
Screen Capture by Author

In this tutorial, we will be working with three datasets (Iris, Breast Cancer, Wine)

We will use 3 different models (KNN, SVM, Random Forest) for classification and give the user the ability to set some parameters.

Install and Import Necessary Libraries

Setup Virtual Environment

pip install virtualenv  /* Install virtual environment */
virtualenv venv /* Create a virtual environment */
venv/Scripts/activate /* Activate the virtual environment */

Install Libraries

Make sure your virtual environment is activated before installing the libraries

pip install streamlit, seaborn, scikit-learn

Import the Libraries

import streamlit as st
from sklearn.datasets import load_wine, load_breast_cancer, load_iris
from sklearn.neighbors import KNeighborsClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.svm import SVC
from sklearn.model_selection import train_test_split
from sklearn.decomposition import PCA
import matplotlib.pyplot …


Computer Vision

This tutorial will be a basic introduction to OpenCV and some basic Instagram filters

Image for post
Image for post
Photo by Janis Fasel on Unsplash

OpenCV is a library primarily built for computer vision. You do not need to be a pro in image processing to build a few simple image filters like Instagram’s sepia effect, Emboss effect, etc. We will be going over the following.

How is an Image Stored?

Image for post
Image for post
Photo by Greyson Joralemon on Unsplash

Each image is made of pixels. The number of pixels in an image is determined by the width and height of the image. The above image is 3776 x 2832, and therefore it has 3776 x 2832 pixels in total. For black and white images, the image will have only one channel, but for a colored image, like the one above, there will be three channels, namely Red, Blue, and Green. …


Life is short, let Python automate your EDA

Image for post
Image for post
Photo by Samantha Hurley from Burst

EDA (Exploratory Data Analysis) is one of the first steps performed on a given dataset. It helps us to understand more about our data and gives us an idea of manipulations and cleaning we might have to do. EDA can take anywhere from a few lines to a few hundred lines. In this tutorial, we will look at libraries which help us perform EDA in a few lines

Dataset

We will use the Titanic Dataset provide by Kaggle. Using Panda’s describe() method, we get the below output

Image for post
Image for post
Screenshot by Author

As you can see the Age Column has missing values. …


Most of the data used for Data Science and Machine Learning is stored as a Dataframe or a Numpy array. In this article, we will be going over Numpy

Image for post
Image for post
Photo by Mika Baumeister on Unsplash

NumPy Why

NumPy is a library provided by Python for scientific computations. Machine Learning and Data Analysis need a lot of data to be stored and more often than not, NumPy is used to store the data. Some of its benefits are listed below


Deploy your Machine Learning Web App using Streamlit Sharing

Image for post
Image for post
Deploying Streamlit App GIF by Author

In my previous articles, I have talked about building a Github Web Scraper and KNN classification model from scratch and using Streamlit for the UI.

What’s the point of building a UI if you can not show it to others.

Enter Streamlit Sharing!

Streamlit sharing is a service provided by Streamlit to easily deploy your app. Below I will walk over the steps in the deployment process.

Get Access to Streamlit Sharing

Streamlit Sharing is currently in its beta mode and you need to join the waiting list to get access to it. It usually takes a few days to get access, I got access within 72 hours. …


Although libraries like sklearn have made our lives easier, it is always a good practice to make a model from scratch. In this tutorial, we will be building a KNN Classification model from Scratch and build a web app using Streamlit to visualize it. Below is a demo of the final app.

Image for post
Image for post
Screencast of Final Streamlit App

KNN overview

KNN or K Nearest Neighbour is used for classification and regression. In this tutorial, we will be using it for classification. Since the target label is known, it is a Supervised algorithm. It essentially takes an input and finds the K nearest points to it. It then checks the labels of the nearest points and classifies the input as the label which occurred the most. Say we want to build a model to classify an animal as a dog or a cat based on the weight, height as input. If K = 3, we find the 3 nearest points to our input and check their label. If 2 of the 3 nearest points have a label ‘dog’, our model classifies the input as ‘dog’. …


What’s the point of building a fancy web app if you can’t show off your dashboard/model to the world? 🌎 In this tutorial, we will deploy a Streamlit app using Heroku

Image for post
Image for post
Photo by Joshua Aragon on Unsplash

Things you will need

Files needed

Requirements.txt

pip freeze > requirements.txt

The above command lists down all the libraries your app uses in a text file. …

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store