itsluckysharma01's picture
Update README.md
bdf8e66 verified
metadata
title: Iris Flower Prediction With MachineLearning
emoji: ๐Ÿ“Š
colorFrom: pink
colorTo: green
sdk: docker
pinned: false
license: apache-2.0
short_description: A beautiful,modern web application that uses MachineLearning

๐ŸŒธ Interactive Iris Flower Prediction Web Application ๐ŸŒธ

<<<<<<< HEAD A beautiful, modern web application that uses Machine Learning to predict Iris flower species with an enhanced interactive user interface, animated backgrounds, and stunning visual effects.

Hare Checkout:=๐Ÿ‘‰ https://prediction-iris-flower-machine-learning.onrender.com ๐Ÿ‘ˆ๐Ÿซก

This web is host on render and checkout https://render.com/ this.

5402033a2086745c03342e8a3c63247b4ff7cd0a

Live Demo: https://itsluckysharma01.github.io/Prediction_iris_Flower_Machine_Learning-Flask/ ๐Ÿ‘ˆ๐Ÿซก

๐ŸŒธ Iris Flower Detection ML Project

Python Jupyter Scikit-learn License

Author: Lucky Sharma
Project: Machine Learning classification model to predict Iris flower species

๐Ÿ“‹ Table of Contents

๐ŸŽฏ Project Overview

This project implements a Machine Learning classification model to predict the species of Iris flowers based on their physical characteristics. The model analyzes four key features of iris flowers and classifies them into one of three species with high accuracy.

๐ŸŽฏ What does this project do?

  • Predicts iris flower species (Setosa, Versicolor, Virginica)
  • Analyzes flower measurements (sepal length/width, petal length/width)
  • Provides multiple ML algorithms comparison
  • Offers both interactive notebook and saved model for predictions

๐ŸŒบ About the Iris Dataset

The famous Iris dataset contains measurements of 150 iris flowers from three different species:

Species Count Characteristics
๐ŸŒธ Iris Setosa 50 Smaller petals, distinct features
๐ŸŒบ Iris Versicolor 50 Medium-sized features
๐ŸŒป Iris Virginica 50 Larger petals and sepals

๐Ÿ“ Features Measured:

  • Sepal Length (cm)
  • Sepal Width (cm)
  • Petal Length (cm)
  • Petal Width (cm)

๐Ÿš€ Quick Start

1๏ธโƒฃ Clone the Repository

git clone <your-repository-url>
cd iris_flower_detection

2๏ธโƒฃ Install Dependencies

pip install pandas numpy matplotlib seaborn scikit-learn jupyter

3๏ธโƒฃ Run the Notebook

jupyter notebook iris_flower_Detection_ML-1.ipynb

4๏ธโƒฃ Make a Quick Prediction

import joblib
import pandas as pd

# Load the trained model
model = joblib.load('iris_flower_model.pkl')

# Make a prediction
sample = [[5.1, 3.5, 1.4, 0.2]]  # [sepal_length, sepal_width, petal_length, petal_width]
prediction = model.predict(sample)
print(f"Predicted species: {prediction[0]}")

๐Ÿ“Š Features

๐Ÿ” Data Analysis

  • โœ… Comprehensive data exploration
  • โœ… Missing value analysis
  • โœ… Statistical summaries
  • โœ… Data visualization

๐Ÿค– Machine Learning Models

  • โœ… Logistic Regression - Primary model
  • โœ… Decision Tree Classifier - Alternative approach
  • โœ… K-Nearest Neighbors - Distance-based classification
  • โœ… Model comparison and performance evaluation

๐Ÿ“ˆ Visualizations

  • โœ… Histograms for feature distributions
  • โœ… Scatter plots for feature relationships
  • โœ… Species distribution analysis

๐Ÿ’พ Model Persistence

  • โœ… Save models using joblib
  • โœ… Save models using pickle
  • โœ… Load and use pre-trained models

๐Ÿ”ง Installation

Requirements

pandas>=1.3.0
numpy>=1.21.0
matplotlib>=3.4.0
seaborn>=0.11.0
scikit-learn>=1.0.0
jupyter>=1.0.0

Install via pip

pip install -r requirements.txt

Or install individually

pip install pandas numpy matplotlib seaborn scikit-learn jupyter

๐Ÿ’ป Usage

๐Ÿ““ Interactive Notebook

Open iris_flower_Detection_ML-1.ipynb in Jupyter Notebook to:

  • Explore the complete data science workflow
  • Visualize data patterns
  • Train and compare different models
  • Make interactive predictions

๐Ÿ”ฎ Using the Saved Model

import joblib
import pandas as pd

# Load the pre-trained model
model = joblib.load('iris_flower_model.pkl')

# Create sample data
sample_data = {
    'sepal_length': [5.1],
    'sepal_width': [3.5],
    'petal_length': [1.4],
    'petal_width': [0.2]
}

# Convert to DataFrame
df = pd.DataFrame(sample_data)

# Make prediction
prediction = model.predict(df)
print(f"Predicted Iris species: {prediction[0]}")

๐Ÿค– Model Performance

๐Ÿ“Š Accuracy Results

Algorithm Training Accuracy Test Accuracy
Logistic Regression ~95-98% ~95-98%
Decision Tree ~100% ~95-97%
K-Nearest Neighbors (k=3) ~95-98% ~95-98%

๐ŸŽฏ Why These Results?

  • High Accuracy: Iris dataset is well-separated and clean
  • Low Complexity: Only 4 features make classification straightforward
  • Balanced Dataset: Equal samples for each class

๐Ÿ“ˆ Visualizations

The project includes several visualization techniques:

๐Ÿ“Š Available Plots

  1. Histograms - Feature distribution analysis
  2. Scatter Plots - Relationship between features
  3. Pair Plots - Multiple feature comparisons
  4. Box Plots - Statistical summaries by species

๐ŸŽจ Example Visualization Code

import matplotlib.pyplot as plt
import seaborn as sns

# Create scatter plot
plt.figure(figsize=(10, 6))
sns.scatterplot(data=iris, x='sepal_length', y='sepal_width', hue='species')
plt.title('Sepal Length vs Width by Species')
plt.show()

๐Ÿ”ฎ Making Predictions

๐Ÿงช Interactive Prediction Function

def predict_iris_species(sepal_length, sepal_width, petal_length, petal_width):
    """
    Predict iris species based on measurements
    
    Parameters:
    - sepal_length: float (cm)
    - sepal_width: float (cm) 
    - petal_length: float (cm)
    - petal_width: float (cm)
    
    Returns:
    - species: string (Setosa, Versicolor, or Virginica)
    """
    model = joblib.load('iris_flower_model.pkl')
    
    sample = [[sepal_length, sepal_width, petal_length, petal_width]]
    prediction = model.predict(sample)
    
    return prediction[0]

# Example usage
species = predict_iris_species(5.1, 3.5, 1.4, 0.2)
print(f"Predicted species: {species}")

๐ŸŽฏ Example Predictions

Measurements Predicted Species Confidence
[5.1, 3.5, 1.4, 0.2] Setosa High
[5.9, 3.0, 5.1, 1.8] Virginica High
[6.2, 2.8, 4.8, 1.8] Virginica Medium

๐Ÿ“ Project Structure

iris_flower_detection/
โ”‚
โ”œโ”€โ”€ ๐Ÿ““ iris_flower_Detection_ML-1.ipynb    # Main Jupyter notebook
โ”œโ”€โ”€ ๐Ÿค– iris_flower_model.pkl               # Saved ML model (joblib)
โ”œโ”€โ”€ ๐Ÿค– iris_model.pkl                      # Saved ML model (pickle)
โ”œโ”€โ”€ ๐Ÿ“ README.md                           # This file
โ””โ”€โ”€ ๐Ÿ“‹ requirements.txt                    # Python dependencies

๐Ÿ› ๏ธ Technologies Used

๐Ÿ Core Libraries

  • pandas - Data manipulation and analysis
  • numpy - Numerical computing
  • scikit-learn - Machine learning algorithms

๐Ÿ“Š Visualization

  • matplotlib - Basic plotting
  • seaborn - Statistical visualizations

๐Ÿ““ Development Environment

  • Jupyter Notebook - Interactive development
  • Python 3.7+ - Programming language

๐Ÿ”ง Model Management

  • joblib - Model serialization (recommended)
  • pickle - Alternative model serialization

๐Ÿ“Š Model Comparison

๐Ÿ† Algorithm Strengths

Algorithm Pros Cons Best For
Logistic Regression Fast, interpretable, probabilistic Linear boundaries only Quick baseline
Decision Tree Easy to understand, handles non-linear Can overfit Interpretability
K-Nearest Neighbors Simple, no training period Sensitive to outliers Small datasets

๐ŸŽฏ Recommendation

For the Iris dataset, Logistic Regression is recommended because:

  • โœ… High accuracy with fast training
  • โœ… Provides probability estimates
  • โœ… Less prone to overfitting
  • โœ… Good for deployment

๐ŸŽจ Interactive Examples

๐Ÿงช Try These Samples

๐ŸŒธ Setosa Examples

# Typical Setosa characteristics
predict_iris_species(5.0, 3.0, 1.0, 0.5)   # โ†’ Setosa
predict_iris_species(4.8, 3.2, 1.4, 0.3)   # โ†’ Setosa

๐ŸŒบ Versicolor Examples

# Typical Versicolor characteristics
predict_iris_species(6.0, 2.8, 4.0, 1.2)   # โ†’ Versicolor
predict_iris_species(5.7, 2.9, 4.2, 1.3)   # โ†’ Versicolor

๐ŸŒป Virginica Examples

# Typical Virginica characteristics
predict_iris_species(6.5, 3.0, 5.2, 2.0)   # โ†’ Virginica
predict_iris_species(7.2, 3.2, 6.0, 1.8)   # โ†’ Virginica

๐ŸŽฎ Interactive Prediction Game

def iris_guessing_game():
    """Fun interactive game to test your iris knowledge!"""
    samples = [
        ([5.1, 3.5, 1.4, 0.2], "Setosa"),
        ([6.7, 3.1, 4.4, 1.4], "Versicolor"), 
        ([6.3, 2.9, 5.6, 1.8], "Virginica")
    ]
    
    for i, (measurements, actual) in enumerate(samples):
        print(f"\n๐ŸŒธ Sample {i+1}: {measurements}")
        user_guess = input("Guess the species (Setosa/Versicolor/Virginica): ")
        prediction = predict_iris_species(*measurements)
        
        print(f"Your guess: {user_guess}")
        print(f"ML Prediction: {prediction}")
        print(f"Actual: {actual}")
        print("โœ… Correct!" if user_guess.lower() == actual.lower() else "โŒ Try again!")

# Run the game
iris_guessing_game()

๐Ÿ”ฌ Advanced Usage

๐Ÿ“Š Model Evaluation Metrics

from sklearn.metrics import classification_report, confusion_matrix

# Generate detailed performance report
y_pred = model.predict(X_test)
print("Classification Report:")
print(classification_report(y_test, y_pred))

print("\nConfusion Matrix:")
print(confusion_matrix(y_test, y_pred))

๐ŸŽฏ Cross-Validation

from sklearn.model_selection import cross_val_score

# Perform 5-fold cross-validation
cv_scores = cross_val_score(model, X, y, cv=5)
print(f"Cross-validation scores: {cv_scores}")
print(f"Average CV score: {cv_scores.mean():.3f} (+/- {cv_scores.std() * 2:.3f})")

๐Ÿค Contributing

๐Ÿš€ How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ’ก Ideas for Contributions

  • ๐ŸŽจ Add more visualization techniques
  • ๐Ÿค– Implement additional ML algorithms
  • ๐ŸŒ Create a web interface
  • ๐Ÿ“ฑ Build a mobile app
  • ๐Ÿ”ง Add hyperparameter tuning
  • ๐Ÿ“Š Include more evaluation metrics

๐ŸŽ“ Learning Resources

๐Ÿ“š Learn More About

๐ŸŽฏ Next Steps

  1. Try other datasets (Wine, Breast Cancer, etc.)
  2. Experiment with ensemble methods
  3. Add feature engineering techniques
  4. Deploy the model as a web service
  5. Create a real-time prediction app

โœจ New Enhanced Features

๐ŸŽจ Interactive Design

  • Modern UI/UX: Beautiful gradient backgrounds with glassmorphism effects
  • Animated Background Video: Looping flower videos for immersive experience
  • Interactive Flower Cards: Click-to-fill example values with hover effects
  • Floating Particles: Dynamic flower emojis floating across the screen
  • Smooth Animations: CSS keyframe animations for all elements

๐ŸŒบ Flower Showcase

  • Real Flower Images: Actual photographs of each iris species
  • Visual Flower Display: High-quality images showing true flower colors
  • Detailed Information: Comprehensive facts about each flower type with color names
  • Interactive Examples: Click any flower card to auto-fill the form
  • Species-Specific Styling: Unique colors and animations for each iris type
  • Dynamic Backgrounds: Background colors change based on predicted flower type

๐Ÿš€ Enhanced Functionality

  • Form Validation: Real-time input validation with visual feedback
  • Number Inputs: Proper numeric inputs with step controls
  • Confidence Scoring: Display prediction confidence percentages
  • Error Handling: Graceful error messages with helpful suggestions
  • Responsive Design: Works perfectly on desktop, tablet, and mobile

๐ŸŽญ Visual Effects

  • Real Flower Photography: High-quality images of actual iris flowers
  • Dynamic Background Colors: Background changes based on predicted flower species
  • Background Videos: Multiple fallback video sources for reliability
  • Particle System: Dynamic floating flower animations
  • Confetti Effects: Celebration animations for successful predictions
  • Glow Effects: Smooth glowing animations throughout the interface
  • Hover Interactions: Elements respond to user interactions
  • Custom Favicon: Beautiful iris flower favicon for all devices and sizes
  • PWA Support: Web app manifest for mobile installation
  • Color-Themed Results: Each flower type displays with its natural color scheme

๐ŸŽจ Favicon and Branding

The application now includes a complete set of favicon files for optimal display across all devices and platforms:

๐ŸŒธ Design Elements

  • Gradient backgrounds: Beautiful purple to pink gradients matching the app theme
  • Iris flower motifs: Custom-designed flower shapes in the favicon
  • Consistent branding: All icons follow the same color scheme and design language
  • Multiple sizes: Optimized for different display contexts and resolutions

๐Ÿ“ฑ PWA Features

  • Installable: Users can install the app on their mobile devices
  • Standalone mode: App runs in full-screen mode when installed
  • Custom theme colors: Matches the application's visual design
  • Optimized icons: Perfect display in app drawers and home screens

๐Ÿ› ๏ธ Technical Features

Machine Learning

  • app.py - The main Flask application
  • iris_model.pkl / new_iris_model.pkl - The trained machine learning model
  • templates/ - Folder containing HTML templates
    • form.html - Input form for flower measurements
    • result.html - Page showing prediction results
  • static/ - Folder containing static files

How to Run

  1. Double-click on run_app.bat or run python app.py in your terminal
  2. Open your web browser and go to http://127.0.0.1:5000
  3. Enter the flower measurements and click "Predict Flower Species"

Sample Measurements

Iris Setosa

  • Sepal Length: 5.1 cm
  • Sepal Width: 3.5 cm
  • Petal Length: 1.4 cm
  • Petal Width: 0.2 cm

Iris Versicolor

  • Sepal Length: 6.0 cm
  • Sepal Width: 2.7 cm
  • Petal Length: 4.2 cm
  • Petal Width: 1.3 cm

Iris Virginica

  • Sepal Length: 6.8 cm
  • Sepal Width: 3.0 cm
  • Petal Length: 5.5 cm
  • Petal Width: 2.1 cm

Troubleshooting

If you encounter issues:

  1. Run python test_app.py to verify the model is working correctly
  2. Check that you have all the required Python packages installed:
    • Flask
    • scikit-learn
    • joblib
    • numpy
  3. Try generating a new model with python create_new_model.py

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Ronald A. Fisher - For creating the famous Iris dataset (1936)
  • Scikit-learn Team - For excellent machine learning tools
  • Jupyter Team - For the amazing notebook environment
  • Python Community - For the incredible ecosystem


๐ŸŒŸ Star this repository if you found it helpful! ๐ŸŒŸ

Made with โค๏ธ for the Machine Learning Community


๐ŸŽ‰ Happy Coding!

Remember: The best way to learn machine learning is by doing. Keep experimenting, keep learning! ๐Ÿš€

Ready to explore the beautiful world of Iris flowers! ๐ŸŒธ๐Ÿค–โœจ