GithubHelp home page GithubHelp logo

robertlent / iris-flower-classifier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vyvy-vi/iris-flower-classifier

0.0 0.0 0.0 25.86 MB

Logistic Regression on Iris Flower Dataset with Numpy and pandas and predicted weights used to serve results to a website via FastAPI

Home Page: http://iris-flower-ml.vercel.app/

License: MIT License

Python 1.22% HTML 1.14% Jupyter Notebook 97.64%

iris-flower-classifier's Introduction

Iris Flower Classifier

This project is an implementation of Logistic Regression with Gradient Descent and the One-vs-Rest strategy for Multiclass Classification, built from scratch with NumPy and Pandas. It leverages the Iris Dataset from UCI Machine Learning repository to perform precise species classification based on the sepal and petal characteristics of iris flowers. The trained model's weights are then employed to serve predictions through a website powered by FastAPI and HTMX.

Preview

Screen.Recording.2023-09-03.at.11.50.04.AM.mov

Live Version

This page is currently deployed. View the live website.

Implementation details

Features given in the dataset (input features):

  • Petal length
  • Petal width
  • Sepal length
  • Sepal width

Classes Classified (target labels):

  • Iris-setosa
  • Iris-versicolor
  • Iris-virginica

Model used:

  • m - training examples, w - weights vector, b - bias
  • Logistic Regression Model: $$f_{w,b}(x) = g(\textbf{w} . \textbf{x} + b)$$ where g is the sigmoid function given by: $$g(z) = \frac{1}{e^{-z}}$$
  • Cost function for logistic regression: $$\textbf{J}(\textbf{w}, b) = \frac{1}{m} \sum_{i = 0}^{m - 1} \left( loss(f_{\textbf{w}, b}(\textbf{x}^{(i)}), y^{(i)}) \right)$$ where the loss function is the cost for a single data point and is given by: $$loss(f_{\textbf{w},b}(x^{(i)}),y^{(i)}) = \left(−y^{(i)}\log(f_{\textbf{w},b}(\textbf{x}^{(i)})\right) − \left((1 − y^{(i)})\log(1 - f_{\textbf{w}, b}(\textbf{x}^{(i)}))\right)$$ where $f_{\textbf{w},b}(\textbf(x)^{(i)})$ is the model's prediction and $y^{(i)}$ is the actual label $$f_{\textbf{w},b}(\textbf{x}^{(i)}) = g(\textbf{w} . \textbf{x}^{(i)} + b)$$

Setup

  • Clone this project:
    git clone https://github.com/Vyvy-vi/iris-flower-classifier/
    
  • Install Python3
  • Install dependencies
    pip install -r requirements.txt
    
  • Run Jupyter Notebook
    jupyter notebook
    
  • Run application
    python3 main.py
    

Usage

  • Training the Model: To train the model and generate the weights and bias, run the classification-logistic-regression-from-scratch.ipynb Jupyter notebook. (run the jupyter notebook command)
  • Running the Web Application: Execute the web application using python main.py. This starts the web server, making the prediction service available at http://localhost:8000.
  • Making Predictions: Input sepal and petal measurements via the web interface and receive predictions for the iris flower species.

Feedback and Bugs

If you have feedback or a bug report, please feel free to open a GitHub issue!

License

This software is licensed under The MIT License.

Copyright 2023 Vyom Jain.

iris-flower-classifier's People

Contributors

vyvy-vi avatar imgbotapp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.