This project demonstrates a basic machine learning workflow using the popular Scikit-Learn library in Python. The script builds a Decision Tree Classifier to classify iris flowers into three species: Setosa, Versicolour, and Virginica based on their features (sepal length, sepal width, petal length, petal width).
This project provides a simple example of how to build, train, and evaluate a machine learning model in Python using Scikit-Learn. The Iris dataset is used, which is a standard dataset in the field of machine learning and is ideal for beginners to understand the basic concepts of classification.
- Model Training: Train a Decision Tree Classifier on the Iris dataset.
- Model Evaluation: Evaluate the model's performance using accuracy score and classification report.
- Prediction: Predict the species of new iris samples.
- Easy to Understand: A simple, well-commented script to help beginners grasp the fundamentals of machine learning.
Ensure you have the following installed:
- Python 3.x
- Scikit-Learn
If you haven't already installed Scikit-Learn, you can do so using pip:
pip install scikit-learn
-
Clone the Repository:
Clone the repository to your local machine:
git clone https://github.com/your-username/iris-classification.git
-
Navigate to the Directory:
Go to the project directory:
cd iris-classification
-
Run the Script:
Run the script using Python:
python iris_classification.py
Once the script is running, it will:
- Load the Iris dataset.
- Split the dataset into training and testing sets.
- Train a Decision Tree Classifier on the training data.
- Evaluate the model using accuracy and a detailed classification report.
- Predict the species of a new sample.
Running the script will produce an output similar to:
Model Accuracy: 0.98
Classification Report:
precision recall f1-score support
setosa 1.00 1.00 1.00 16
versicolor 1.00 0.92 0.96 12
virginica 0.92 1.00 0.96 12
accuracy 0.98 40
macro avg 0.98 0.98 0.98 40
weighted avg 0.98 0.98 0.98 40
Predicted Species: setosa
To predict the species of a new iris flower, you can modify the new_sample
variable in the script:
new_sample = [[5.0, 3.6, 1.4, 0.2]] # Example features: sepal length, sepal width, petal length, petal width
Run the script again to see the predicted species.
Contributions are welcome! If you have suggestions for new features, improvements, or bug fixes, feel free to create a pull request or open an issue.
- Fork the Repository: Click on the 'Fork' button at the top right of this page.
- Clone Your Fork: Clone your forked repository to your local machine.
git clone https://github.com/your-username/iris-classification.git
- Create a Branch: Create a new branch for your feature or bugfix.
git checkout -b feature/your-feature-name
- Make Changes: Make your changes and commit them with a descriptive message.
git commit -m "Add: feature description"
- Push Changes: Push your changes to your forked repository.
git push origin feature/your-feature-name
- Create a Pull Request: Go to the original repository on GitHub and create a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
Thank you for using the Iris Flower Classification script! Feel free to reach out if you have any questions or feedback. Happy learning! 🌸🚀