Skip to main content

SahilAI v0.2.0

Learn machine learning by using it and understanding the mathematics behind it.

SahilAI is an early educational machine-learning framework by Sahil Khan. It is designed so students can import algorithms in Python, train them, and explore the calculations step by step.

Installation from source

Requires Python 3.10 or newer.

python -m pip install -e .

Import your own algorithms

from sahilai.linear_model import EasyLearn, ComplexLearning

X = [[1], [2], [3], [4], [5]]
y = [20, 30, 40, 50, 60]

# EasyLearn: closed-form least-squares solution, explained simply
easy = EasyLearn()
easy.fit(X, y)
print(easy.predict([[6]]))

# ComplexLearning: gradient-descent version, with training history
complex_model = ComplexLearning(learning_rate=0.01, epochs=5000)
complex_model.fit(X, y, verbose=True)
print(complex_model.predict([[6]]))
print(complex_model.loss_history_[-1])

These two classes are educational implementations, not production replacements for scikit-learn. This first version supports one numerical feature.

Terminal learning commands

sahilai start
sahilai lesson 1
sahilai lesson 2
sahilai lesson 3
sahilai demo linear

Mathematical details

Both models use the linear equation:

prediction = weight * x + bias

EasyLearn computes the least-squares solution directly using the closed-form equations for a one-feature linear regression.

ComplexLearning optimizes mean squared error with gradient descent:

MSE = (1/n) * sum((prediction - target)^2)
dMSE/dw = (2/n) * sum((prediction - target) * x)
dMSE/db = (2/n) * sum(prediction - target)

Parameter update:

parameter = parameter - learning_rate * gradient

Tests

python -m unittest discover -s tests -v

Roadmap

  1. More lessons and interactive exercises
  2. Multiple input features
  3. Classification algorithms
  4. Tensors and neural-network layers
  5. Backpropagation and deep learning
  6. Documentation and a public PyPI release

License

MIT.

Metadata

Release files for sahilai 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sahilai 0.2.0
File Size Uploaded Provenance Actions
sahilai-0.2.0.tar.gz 7.8 kB Without provenance Details for sahilai-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sahilai 0.2.0
File Interpreter ABI Platform Actions
sahilai-0.2.0-py3-none-any.whl Python 3 none any Details for sahilai-0.2.0-py3-none-any.whl

Total release size: 15.7 kB

Release files / sahilai-0.2.0.tar.gz

Download URL sahilai-0.2.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
267719bcd879e4f9cd5e9f0798b0d6264dda4bcb919c68a701cdc3513c53f8be
BLAKE2b-256 checksum
How to use checksums
51854beecba5a8466db0490e4dd2bad903ac01b24dcc9adaa74c0ee60f9837ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / sahilai-0.2.0-py3-none-any.whl

Download URL sahilai-0.2.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
990b13a3f231b554d9bd4baaea05759b5187241c8d2efa20056f3a7f4c66ac89
BLAKE2b-256 checksum
How to use checksums
18ff31bffcbecbb352251466c2a4a99169c1b5fd8a1cd875be63fbf6eb7472e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for sahilai 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page