Skip to content

ItzRustam/rslearn-ML

Repository files navigation

πŸš€ rslearn

A beginner-friendly machine learning library that automates preprocessing, training, and evaluation.

License Python Status Contributions


NOTE

This is Python version of this library visit more.

Origination - rslearn-lib


✨ Why rslearn?

  • ⚑ Minimal setup β€” no complex configuration
  • πŸ€– Automatic pipeline (scaling, splitting, evaluation)
  • πŸ“Š Built-in metrics for regression & classification
  • 🧠 Designed for beginners learning ML concepts
  • 🧩 Clean and simple API inspired by sklearn

Release & Changes

  • Version : 1.0.9 - 1.0.4
  • Release Date: 2026-06-26

Latest (linear_model):

  • save() & load_model()
  • more control over scaling with hard_scale_off=True
  • custom extension .rslr, .rslc, .prsl
    NOTE: Docs, doc strings & Parameter Info will be changed in feature info.

More Info: CHANGELOG

Download Version Specific Module

Downloads - Module

πŸ“Š Linear Models

  • Linear Regression (Single & Multi-feature)
  • Logistic Regression (Binary & Multi-class)
  • Ridge Regression (L2 Regularization)
  • Lasso Regression (L1 Regularization)
  • Elastic Net (L1 + L2)

πŸ“Š K-nearest Neighbors Models

  • KNNRegressor (Single & Multi-feature)
  • KNNClassifier (Binary & Multi-class)

πŸ“ Metrics

  • Mean Squared Error (MSE)
  • Mean Absolute Error (MAE)
  • Root Mean Squared Error (RMSE)
  • RΒ² Score
  • Accuracy (for classification)
  • Euclidian Distance (for KNN)

βœ” Supports single-output and multi-output tasks


πŸ”§ Preprocessing

  • StandardScaler
  • MinMaxScaler

πŸ§ͺ Model Selection

  • Train-Test Split

    • Supports stratify for balanced sampling

βš™οΈ Optimization Details

All models in rslearn are implemented using Gradient Descent.

⚠️ Important:

  • Feature scaling is highly recommended for stable and faster convergence.

  • Use:

    • StandardScaler (recommended)
    • or MinMaxScaler
  • or just use scale=True parameter while fit()


πŸ€– Auto Standard Scaling (Linear, Logistic, Ridge, Lasso, ElasticNet)

models include Inbuilt StandardScaler Feature in fit() Method:

scale=True  # default
  • Automatically applies feature scaling internally
  • Helps prevent numerical instability

πŸ“ Project Structure

rslearn-ML/
β”‚
β”œβ”€β”€ rslearn/
β”‚   β”‚
β”‚   β”œβ”€β”€ BaseEstimators/
β”‚   β”‚   └── __init__.py  
β”‚   β”‚   └── _base.py  
β”‚   β”‚   └── _estimator.py  
β”‚   β”‚
β”‚   β”œβ”€β”€ Errors/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── _errors.py  
β”‚   β”‚
β”‚   β”œβ”€β”€ loader/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── _pipeline_loader.py
β”‚   β”‚   └── _model_loader.py  
β”‚   β”‚
β”‚   β”œβ”€β”€ linear_model/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   β”œβ”€β”€ _LinearRegression.py
β”‚   β”‚   β”œβ”€β”€ _LogisticRegression.py
β”‚   β”‚   └── _regulizations.py
β”‚   β”‚
β”‚   β”œβ”€β”€ metrics/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   β”œβ”€β”€ classification_readme.md
β”‚   β”‚   β”œβ”€β”€ _classification.py
β”‚   β”‚   β”œβ”€β”€ _distances.py
β”‚   β”‚   └── _regression.py
β”‚   β”‚
β”‚   β”œβ”€β”€ model_selection/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   └── _split.py
β”‚   β”‚
β”‚   β”œβ”€β”€ neighbors/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   β”œβ”€β”€ _knnClass.py
β”‚   β”‚   └── _knnReg.py
β”‚   β”‚
β”‚   β”œβ”€β”€ Pipeline/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   └── _pipeline.py
β”‚   β”‚
β”‚   β”œβ”€β”€ preprocessing/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   └── _scaler.py
β”‚   β”‚
β”‚   └── __init__.py
β”‚
β”œβ”€β”€ README.md

πŸ“Œ Each module contains its own detailed README with usage examples and explanations.


πŸ› οΈ Installation

Clone the repository

git clone https://github.com/rslearn-lib/rslearn-ML-py.git
cd rslearn-ML-py/

Install Usable Library (Stable - Latest)

pip install rslearn-py

Download Version Specific Module

Downloads Older Library

Install dependencies

pip install -r requirements.txt

πŸ“Œ Quick Example

import rslearn
from rslearn.linear_model import LinearRegression
import numpy as np

print(rslearn.__version__)
X = np.array([10, 20, 30])
y = np.array([5, 10, 15])

model = LinearRegression()
model.fit(X, y, scale=True) # Auto Scale if True, else Gradient Stability Backend

print(model.predict([40]))

πŸ“š Documentation

  • Each folder includes its own README.md

  • Covers:

    • Usage
    • Parameters
    • Examples
    • Internal working

🎯 Goals of this Project

  • Understand ML algorithms from scratch
  • Build a sklearn-like API
  • Create reusable and modular ML components
  • Learn real-world ML system design
  • Check Self Ability

πŸ§‘β€πŸ’» Author

ItzRustam

πŸ”¨ Origination

rslearn-lib


πŸ“œ License

This project is licensed under the GNU GPL v3 License.

About

Rslearn-ML Machine Learning Library (From Scratch)

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Contributors

Languages