Loading

Quipoin Menu

Learn • Practice • Grow

machine-learning / Setup and First ML Model
tutorial

Setup and First ML Model

Before writing any ML code, set up your environment. This chapter shows you how to create a clean workspace and run your first scikit‑learn example.

Step 1: Install Python and Create a Virtual Environment (Recommended)

# Create and activate a virtual environment
python -m venv ml-env
# On Windows:
ml-envScriptsactivate
# On Mac/Linux:
source ml-env/bin/activate

Step 2: Install Required Libraries

pip install numpy pandas scikit-learn matplotlib

Step 3: Run Your First ML Model (Linear Regression)

Create a file `first_model.py`:
import numpy as np
from sklearn.linear_model import LinearRegression

# Sample data: years of experience → salary
X = np.array([[1], [2], [3], [4]]) # features (must be 2D)
y = np.array([30000, 35000, 40000, 45000])

model = LinearRegression()
model.fit(X, y)

pred = model.predict([[5]])
print(f"Predicted salary for 5 years: {pred[0]:.0f}")
Run it:
python first_model.py
You should see a predicted salary (e.g., 50000).

What Just Happened?

  • X is input (years of experience).
  • y is target (salary).
  • LinearRegression().fit(X, y) learns a line that best fits the data.
  • predict uses that line to estimate salary for 5 years.
This is a tiny ML pipeline – you have just trained your first model!


Two Minute Drill
  • Use a virtual environment to keep dependencies isolated.
  • Install numpy, pandas, scikit‑learn, matplotlib.
  • First model: linear regression on toy data.
  • Congratulations – you have run your first ML code!

Need more clarification?

Drop us an email at career@quipoinfotech.com