Experiment 1
ML Project Setup & Reproducibility
Objective: To set up a reproducible ML project using GitHub and Python environments.
Prerequisites
Note on Script Names
In standard examples (or your notes), you might see train.py. Here, we are using specific script names: linear-regression.py and logistic-regression.py to run multiple models.
Procedure
1. Create Project Folder
Create a new folder on your Desktop named mlops-lab.
2. Create Files
Inside the mlops-lab folder, create the following files:
linear-regression.py
import pandas as pd
from sklearn.linear_model import LinearRegression
X = [[1],[2],[3],[4]]
y = [2,4,6,8]
model = LinearRegression().fit(X,y)
print("Prediction for 5:", model.predict([[5]])[0])logistic-regression.py
import pandas as pd
from sklearn.linear_model import LogisticRegression
# Sample dataset (binary classification)
# X represents features, y represents labels (0 or 1)
X = [[1], [2], [3], [4]]
y = [0, 0, 1, 1]
# Train logistic regression model
model = LogisticRegression().fit(X, y)
# Make a prediction
prediction = model.predict([[5]])[0]
probability = model.predict_proba([[5]])[0]
print("Prediction for 5:", prediction)
print("Probability distribution:", probability)requirements.txt
numpy
pandas
scikit-learn3. Push to GitHub
- Open GitHub Desktop.
- Go to
File→Add Local Repository. - Select the
mlops-labfolder on your Desktop. - GitHub Desktop will ask to create a repository. Click Create Repository.
- Add a summary (e.g., "Initial ML project setup").
- Click Commit to main.
- Click Publish repository to push it to GitHub.
Run in Google Colab
Reference Output
Output Document
View Document
Author: Aamir Sarang