Iris Classification and Prediction Web App

 One of my primary interests in the field of computer science is Machine Learning. Machine Learning has no bounds and here, the sky is not the limit. It has applications in many important sectors such as biotechnology, medicine, aviation etc. This is my second web app on Machine Learning and I’m working hard to successfully deploy many more Machine Learning apps. All of these projects are free to use and I welcome any suggestions and/or additions to the project. 

One of the main reasons why I love Machine Learning is that it perfectly incorporates the beauty of mathematics and computer science to successfully integrate and develop a particular application. As I mentioned in the previous article, Machine Learning not only requires a good understanding of coding, it also requires in depth knowledge in Maths. So for the people out there who question the use of Maths in Computer Science, this is a classic example as to why that’s not always the case. Having a good knowledge about calculus and Linear Algebra definitely helps in Data Science. 

After the positive response of our first web app, Diabetes Detector, I decided to explore Machine Learning in greater depth and decided to deploy many more apps related to it in the future. So if you’re interested in Machine Learning and data science, hey we’re on the same page. Although I’m still a junior in high school so most of you might be more experienced than me. 

So coming onto this app, this is an Iris Classification and Prediction App. It classifies and successfully predicts the type of Iris flower based upon a number of user input features such as Sepal Length, Petal Length, Sepal Width and Petal Width. It uses the Random Forest Classifier algorithm. 

The web app uses a simple design and structure. I tried to make it as simple as possible so that it could be deployed easy. The sidebar sliders help in changing the values of the parameters for determination of the result. It also displays class labels, their corresponding index number and the prediction probability along with the predicted species of the Iris Flower. 

Another interesting feature about this web app is the presence of the image of the predicted species. We have 3 different images for all three species which are displayed depending upon the predicted species based upon user input of parameter values. 

We have deployed the app using Streamlit. It is an open source framework that allows data science teams to deploy web apps fairly easily. It’s one of the best hosting services I’ve used and it’s great for quick and easy deployment of web apps. The app is coded in python. 

This web app helped me to improve my experience in Machine Learning and definately helped in my future projects. Feel free to add onto this project and don’t hesitate to drop by any suggestions. Hope you enjoy the app!

Link of the app:

About the dataset : The Iris dataset was used in R.A. Fisher’s paper written in 1936, The Use of Multiple Measurements in Taxonomic Problems, and can also be found on the UCI Machine Learning Repository. It is an example of linear discriminant analysis. This dataset is also knows as Anderson’s Iris Dataset because Edgar Anderson collected the data to quantify the morphologic variation of Iris flowers of three related species. 

Based on Fisher’s linear discriminant model, this data set became a typical test case for many statistical classification techniques in machine learning such as support vector machines.

It includes three iris species with 50 samples each as well as some properties about each flower. One flower species is linearly separable from the other two, but the other two are not linearly separable from each other.

Iris is a genus of 260–300 species of flowering plants with showy flowers. Its name is derived from the Greek word for Rainbow (yes, we are quite interested in languages and cultures) which in coincidentally also the name for the Greek goddess of rainbow-Iris. Apart from being the scientific name, Iris is also widely used as a common name for all Iris species.

Dataset License: Open Data Commons Public Domain Dedication and License (PDDL)

Explanation of the Code and how you can make this yourself !

Here, I am going to go through the code in a very concise and simple manner so that people with even minimal experience in programming or data science can follow along and benefit it. This app has been coded in python and has been deployed on streamlit as mentioned before. I’ve also used the Random Forest Classifier Algorithm for this particular problem. 

Alright so lets finally get started. First up I’ve imported the python packages / libraries that I’ve used for this app. More information for them is available on the project template of SkillTools. 


import streamlit as st
import pandas as pd
from sklearn import datasets
from sklearn.ensemble import RandomForestClassifier
from PIL import Image,ImageFilter,ImageEnhance
import os

After this I have included a slight description of the app as a string which includes the dataset resource and the developers. I have given due credits to the original makers of this dataset and have acknowledged the license of the dataset which in this case is Open Data Commons Public Domain Dedication and License (PDDL).

Next we need to give our input features i.e. the parameters of the dataset. The users can manipulate the values of these parameters and run the app. Here we also need to provide the range of these parameters which the users can change using the sliders in the sidebar.

def user_input_features():
    sepal_length = st.sidebar.slider('Sepal length', 4.2, 8.0, 4.4)
    sepal_width = st.sidebar.slider('Sepal width', 1.8, 4.2, 3.2)
    petal_length = st.sidebar.slider('Petal length', 0.8, 7.0, 1.6)
    petal_width = st.sidebar.slider('Petal width', 0.1, 2.4, 0.8)
    data = {'sepal_length': sepal_length,
            'sepal_width': sepal_width,
            'petal_length': petal_length,
            'petal_width': petal_width}
    features = pd.DataFrame(data, index=[0])
    return features

Once we’re done with this, we need to load the Iris dataset and run the Random Forest Classifier Algorithm. Once we give those commands, we finally need to assign class labels, their corresponding index number and the prediction probability of that particular species of iris flower.

iris = datasets.load_iris()
X =
Y =

clf = RandomForestClassifier(), Y)

prediction = clf.predict(df)
prediction_proba = clf.predict_proba(df)

st.subheader('Class labels and their corresponding index number')


I’ve also added one more functionality into this web app. It essentially displays an image of the predicted species ! I’ve capped it up with a link of this article and a reference to our Team Skillocity logo.

def load_image(img):
    return im

if iris.target_names[prediction] == 'setosa':
    st.text("Showing Setosa Species")
elif iris.target_names[prediction] == 'versicolor':
    st.text("Showing Versicolor Species")
elif iris.target_names[prediction] == 'virginica':
    st.text("Showing Virginica Species")

So that’s it from this web app and I’ll see you soon with another fun application of Machine Learning / Data Science and give some interesting insights. Hasta pronto !

Iris Classification and Prediction Web App6 min read

186 thoughts on “Iris Classification and Prediction Web App6 min read

  1. whoah this blog is wonderful i really like reading your articles. Keep up the great paintings! You realize, a lot of people are hunting round for this info, you could help them greatly.

  2. AAU Started providing academic services in 1990, Al-Ahliyya Amman University (AAU) was the first private university and pioneer of private education in Jordan. AAU has been accorded institutional and programmatic accreditation. It is a member of the International Association of Universities, Federation of the Universities of the Islamic World, Union of Arab Universities and Association of Arab Private Institutions of Higher Education. AAU always seeks distinction by upgrading learning outcomes through the adoption of methods and strategies that depend on a system of quality control and effective follow-up at all its faculties, departments, centers and administrative units. The overall aim is to become a flagship university not only at the Hashemite Kingdom of Jordan level but also at the Arab World level. In this vein, AAU has adopted Information Technology as an essential ingredient in its activities, especially e-learning, and it has incorporated it in its educational processes in all fields of specialization to become the first such university to do so.

  3. whoah this blog is wonderful i really like reading your articles. Keep up the great paintings! You realize, a lot of people are hunting round for this info, you could help them greatly.

  4. These kind of posts are always inspiring and I prefer to read quality content so I happy to find many good point here in the post. writing is simply wonderful! thank you for the post

  5. It is perfect time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I want to suggest you some interesting things or suggestions. Perhaps you can write next articles referring to this article. I wish to read more things about it!

  6. It’s the best time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I wish to suggest you some interesting things or tips. Maybe you can write next articles referring to this article. I wish to read even more things about it!

  7. Unquestionably believe that which you said. Your favorite reason seemed to be on the net the easiest thing to be aware of. I say to you, I certainly get annoyed while people consider worries that they plainly don’t know about. You managed to hit the nail on the head. Will probably be back to get more. Thanks

  8. have already been reading ur blog for a couple of days. really enjoy what you posted. btw i will be doing a report about this topic. do you happen to know any great websites or forums that I can find out more? thanks a lot.

  9. Your idea is outstanding; the issue is something that not enough persons are speaking intelligently about. I’m very happy that I stumbled throughout this in my seek for one thing regarding this.

  10. Great post. I was checking constantly this blog and I’m impressed! Very useful info specifically the last part 🙂 I care for such info much. I was looking for this certain information for a very long time. Thank you and good luck.

  11. A good web site with interesting content, that’s what I need. Thank you for making this web site, and I will be visiting again. Do you do newsletters? I Can’t find it.

  12. Pretty impressive article. I just stumbled upon your site and wanted to say that I have really enjoyed reading your opinions. Any way I’ll be coming back and I hope you post again soon.

  13. I just couldn’t leave your website before suggesting that I really enjoyed the usual information an individual supply on your visitors? Is gonna be back often in order to investigate cross-check new posts

  14. Nice read, I just passed this onto a colleague who was doing some research on that. And he just bought me lunch as I found it for him smile Therefore let me rephrase that: Thank you for lunch!

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top