Skip to main content

Simple Machine Learning library from scratch using NumPy

Project description

simpmnct là thư viện dành cho người mới học Machine Learning, tập trung vào việc giúp bạn hiểu bản chất mô hình thay vì chỉ gọi hàm có sẵn.

Thư viện xử lý được hầu hết các trường hợp cơ bản trong Machine Learning, nhưng nhiều bước được giữ lại để người học tự thao tác bằng tay, giúp hiểu rõ cách mô hình hoạt động thay vì phụ thuộc hoàn toàn vào các thư viện lớn.

Thư viện được xây dựng dựa trên: numpy — tính toán ma trận và vector pickle — lưu model torch / torchvision — hỗ trợ mở rộng deep learning pillow — xử lý ảnh Một điểm đặc biệt của simpmnct là khả năng in chi tiết quá trình học của mô hình, bao gồm: Loss qua từng epoch Gradient (dw, db) Cập nhật weight và bias Công thức mô hình Quá trình predict từng bước

Thư viện hỗ trợ: Linear Regression Logistic Regression Train/Test Split Normalize dữ liệu (data) Metrics cơ bản Save/Load model (.best)

simpmnct is a library for beginners in Machine Learning, focusing on helping you understand the fundamentals of the model rather than simply calling built-in functions.

The library handles most basic Machine Learning scenarios, but many steps are left to allow learners to manipulate them manually, helping them understand how the model works instead of relying entirely on large libraries.

The library is built on: numpy — matrix and vector computation pickle — model storage torch / torchvision — support for deep learning extensions pillow — image processing A unique feature of simpmnct is its ability to print detailed model learning progress, including: Loss at each epoch Gradient (dw, db) Update weights and biases Model formulas Step-by-step prediction process

Supported libraries: Linear Regression Logistic Regression Train/Test Split Normalize data Basic Metrics Save/Load model (.best)

Example 1 — Linear Regression_______ import numpy as np from simpmnct.models.linear import Linear from simpmnct.utils.train_test_split import train_test_split

Generate data

X = np.random.rand(100,1) y = 3*X + 2

Split data

X_train, X_test, y_train, y_test = train_test_split(X,y)

Train model

model = Linear(lr=0.01, epochs=1000) model.fit(X_train,y_train)

Predict

pred = model.predict(X_test) print(pred[:5])

Example 2 — Logistic Regression---- import numpy as np from simpmnct.models.logistic import Logistic

Generate classification data

X = np.random.rand(100,2) y = (X[:,0] + X[:,1] > 1).astype(int)

Train model

model = Logistic(lr=0.1, epochs=1000) model.fit(X,y)

Predict

print(model.predict(X[:5]))

Train/Test Split------ from simpmnct.utils.train_test_split import train_test_split X_train, X_test, y_train, y_test = train_test_split(X,y)

Normalize Data from simpmnct.utils.normalize import normalize X_norm = normalize(X)

Metrics----- from simpmnct.metrics.metrics import accuracy from simpmnct.metrics.metrics import mse print(accuracy(y_true,y_pred)) print(mse(y_true,y_pred))

Save Model: model.save("model.best")

Load Model---- from simpmnct.models.linear import Linear model = Linear.load("model.best")

Dataset Loader (Depth Estimation): from simpmnct.dataset.depth_dataset import DepthDataset dataset = DepthDataset(img_dir="images",depth_dir="depth") img, depth = dataset[0]

Output: image -> Tensor (3, H, W) depth -> Tensor (1, H, W)

lưu ý : model này là do thằng sinh viên năm 2 viết ko dùng cho dự án lớn hay dẫn đường tên lửa , có thể sai số hoặc nhiều bug tiềm ẩn , chỉ sử dụng để học hoặc làm dự án nhỏ

Please note: this model was written by a second-year student and is not intended for large projects or missile guidance. It may contain errors or potential bugs; it is only for learning or small projects.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simpmnct-1.0.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simpmnct-1.0.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file simpmnct-1.0.0.tar.gz.

File metadata

  • Download URL: simpmnct-1.0.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for simpmnct-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4bcd7f45e2c3caa34ee162e20447f88b4addb341d748500d23197129053711d2
MD5 824d2270577936bf1fa7a8da09cbde2f
BLAKE2b-256 3fe5d6643554f041e43012a2fa28b61b30d398164b39a8fe0bf49579ac8e5204

See more details on using hashes here.

File details

Details for the file simpmnct-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: simpmnct-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for simpmnct-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f67eca1c08284d7e3191f79d47bc38d8e07e818bd4b35a06b79a9c29b98b759c
MD5 80a8b46600d503b0e43ee7ff41e381d5
BLAKE2b-256 cd8150c4cdaffe407081be1cb4721de39060f910a33eb8a955cd8cda273a28c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page