Skip to content

Getting Started

SRIJA DE CHOWDHURY edited this page Jan 4, 2026 · 1 revision

🚀 Getting Started

Quick Setup Guide for Logistic Regression From Scratch

Setup Time


📋 Prerequisites

Before you begin, ensure you have the following installed:

🐍 Python 3.8+

Core programming language

📦 Package Manager

For installing dependencies

💻 Code Editor

VS Code, PyCharm, or Jupyter


🔧 Installation

Step 1: Clone the Repository

# Using HTTPS
git clone https://github.com/willow788/Logistic-Regression-Fron-Scratch.git

# Or using SSH
git clone git@github.com:willow788/Logistic-Regression-Fron-Scratch.git

# Navigate to the directory
cd Logistic-Regression-Fron-Scratch

Step 2: Set Up Virtual Environment (Recommended)

# Create virtual environment
python -m venv venv

# Activate on Windows
venv\Scripts\activate

# Activate on macOS/Linux
source venv/bin/activate

Step 3: Install Dependencies

# Install all required packages
pip install numpy pandas matplotlib seaborn jupyter scikit-learn

# Or install from requirements file (if available)
pip install -r requirements.txt

📦 Required Packages

Package Version Purpose
NumPy 1.21+ Numerical computations
Pandas 1.3+ Data manipulation
Matplotlib 3.4+ Basic plotting
Seaborn 0.11+ Advanced visualizations
Jupyter Latest Interactive notebooks
scikit-learn 0.24+ Dataset & metrics (optional)

🎯 Running Your First Model

Option 1: Jupyter Notebook (Recommended)

# Launch Jupyter Notebook
jupyter notebook

# Or Jupyter Lab
jupyter lab

Then:

  1. Navigate to Main jupyter notebook/ folder
  2. Open the main notebook
  3. Run cells sequentially (Shift + Enter)

Option 2: Python Script

# main.py
import numpy as np
from logistic_regression import LogisticRegression

# Load data
X_train, y_train = load_data()

# Initialize model
model = LogisticRegression(learning_rate=0.01, iterations=1000)

# Train model
model.fit(X_train, y_train)

# Make predictions
predictions = model.predict(X_test)

🗂️ Project Structure

📦 Logistic-Regression-Fron-Scratch/
│
├── 📂 Main jupyter notebook/
│   └── 📓 logistic_regression.ipynb    ← Start here! 
│
├── 📂 Improved Model/
│   └── 📓 improved_model.ipynb         ← Advanced version
│
├── 📜 .gitignore
└── 📖 README.md

✅ Verify Installation

Run this quick test to ensure everything is working:

# test_installation.py
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

print("✅ NumPy version:", np.__version__)
print("✅ Pandas version:", pd.__version__)
print("✅ Matplotlib version:", plt. matplotlib.__version__)
print("✅ Seaborn version:", sns.__version__)
print("\n🎉 All packages installed successfully!")

Expected output:

✅ NumPy version: 1.21.0
✅ Pandas version: 1.3.0
✅ Matplotlib version: 3.4.0
✅ Seaborn version: 0.11.0

🎉 All packages installed successfully!

🎬 Quick Start Tutorial

1️⃣ Import Libraries

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

2️⃣ Load Dataset

# Using sklearn's breast cancer dataset as example
from sklearn.datasets import load_breast_cancer

data = load_breast_cancer()
X = data.data
y = data.target

3️⃣ Split 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
)

4️⃣ Train Model

# Your custom logistic regression model
model = LogisticRegression(learning_rate=0.01, n_iterations=1000)
model.fit(X_train, y_train)

5️⃣ Evaluate

accuracy = model.score(X_test, y_test)
print(f"Accuracy: {accuracy:.2%}")

🎯 Next Steps

📚 Learn the Theory

💻 Dive into Code


🐛 Troubleshooting

Common Issues

❌ ModuleNotFoundError: No module named 'numpy'

Solution:

pip install numpy
❌ Jupyter notebook not opening

Solution:

# Reinstall Jupyter
pip uninstall jupyter
pip install jupyter

# Try alternative
pip install jupyterlab
jupyter lab
❌ Import errors in notebook

Solution:

  • Ensure virtual environment is activated
  • Restart Jupyter kernel: Kernel → Restart
  • Reinstall packages in the correct environment

💡 Tips for Success

💡 Pro Tip #1: Always use a virtual environment to avoid package conflicts!

💡 Pro Tip #2: Run cells in order - don't skip cells in Jupyter notebooks!

💡 Pro Tip #3: Check the FAQ if you get stuck!


📞 Need Help?


✨ Ready to Learn? Let's Go! 🚀

← Back to Home | Mathematical Foundation →

Clone this wiki locally