DEV Community

Cover image for 🎯 How I Built My First Machine Learning Project (A Beginner-Friendly Guide)
Shamanta Sristy
Shamanta Sristy

Posted on

🎯 How I Built My First Machine Learning Project (A Beginner-Friendly Guide)

Today, I’m sharing how I built my first machine learning project after restarting my tech journey β€” and I’ll walk you through it step-by-step so even beginners can follow along!

We’ll build a simple Iris Flower Classification project using Python.

Let’s dive in! πŸš€


Step 1: Setting Up the Project

First, I created a clean folder structure like this:

iris-classification/
β”‚
β”œβ”€β”€ data/
β”œβ”€β”€ notebooks/
β”œβ”€β”€ src/
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
└── .gitignore
Enter fullscreen mode Exit fullscreen mode

βœ… data/ for datasets

βœ… notebooks/ for Jupyter notebooks

βœ… src/ for Python scripts

βœ… README.md to explain the project

βœ… requirements.txt to list all needed Python packages

I highly recommend starting with good organization β€” it makes everything easier later!


Step 2: Loading and Exploring the Data

I used the famous Iris Dataset.

import pandas as pd

df = pd.read_csv('data/iris.csv')
print(df.head())
Enter fullscreen mode Exit fullscreen mode

Then, I checked basic information:

df.info()
df.describe()
Enter fullscreen mode Exit fullscreen mode

βœ… Tip: Always look at your data first before modeling!


Step 3: Visualizing the Data

I made some simple visualizations to understand the features better.

import seaborn as sns
import matplotlib.pyplot as plt
Enter fullscreen mode Exit fullscreen mode

Correlation heatmap

plt.figure(figsize=(10,8))
sns.heatmap(df.corr(), annot=True, cmap='coolwarm')
plt.title('Feature Correlation Heatmap')
plt.show()
Enter fullscreen mode Exit fullscreen mode

Image description

Pairplot

import seaborn as sns
import matplotlib.pyplot as plt

# Create a smaller pairplot using the correct label
g = sns.pairplot(df, hue='target', height=2.3)

# Add a title
g.fig.suptitle('Pairplot of Iris Features', y=1.03)

# Clean layout
plt.tight_layout()

# Save if needed
plt.savefig('pairplot.png', dpi=300, bbox_inches='tight')

plt.show()
Enter fullscreen mode Exit fullscreen mode

Image description

βœ… Tip: Visualization helps you see patterns that numbers alone can't show!


Step 4: Preparing the Data

I separated features (X) and labels (y).

X = df.drop('species', axis=1)
y = df['species']
Enter fullscreen mode Exit fullscreen mode

Then I split the data:

from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
Enter fullscreen mode Exit fullscreen mode

βœ… Tip: Always split your data β€” training and testing on the same data gives fake results.


Step 5: Organizing and Pushing to GitHub

Finally, I learned to push my project properly to GitHub:

git init
git add .
git commit -m "First ML project: Iris Classification"
git branch -M main
git remote add origin https://github.com/ShamantaSristy/iris-classification.git
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

βœ… Tip: Save your work online β€” GitHub shows your growth and makes you look professional!

πŸŽ‰ What I Learned
πŸ’‘How to structure and organize a machine learning project

πŸ’‘How to analyze, visualize, and prepare data

πŸ’‘How to push and maintain a clean GitHub repository

πŸ‘‰ My full project is here:
πŸ”— Iris Flower Classification GitHub Repo

If you're also starting your journey, trust me β€” you can do this! 🌱
One small project at a time, and you’ll get better every day.

See you in the next post, where I'll tackle my next project: the Titanic Survival Prediction πŸš’β“

Top comments (3)

Collapse
Β 
besworks profile image
Besworks β€’

Welcome back to Dev! Nice write up. Clear, concise and well structured. Keep at it! Titanic Survival Prediction sounds like an interesting topic.

Collapse
Β 
shamantasristy profile image
Shamanta Sristy β€’

Thank you so much for the kind words and encouragement! 🌻

Collapse
Β 
debottam1234567890 profile image
Debottam Ghosh β€’

Pls visit my GitHub profile at:
github.com/Debottam1234567890

look at my scam detectors and dream insights projects
hope u have a good time!!

Tip: You can learn a lot!!!