Skip to main content

utelearn

utelearn is a custom machine learning library built from scratch for educational purposes at UTE.

Installation

You can install the package directly from PyPI:

pip install utelearn

Features

  • KMeans Clustering: Custom implementation of the KMeans clustering algorithm using NumPy.
  • Built-in support for data visualization with Matplotlib.

Quick Start

Here is a quick example of how to use the KMeans model from utelearn:

import numpy as np
import matplotlib.pyplot as plt
from utelearn.kmeans import KMeans

# 1. Tạo dữ liệu mẫu ngẫu nhiên (2 cụm rõ rệt)
np.random.seed(42)
X = np.vstack([
    np.random.randn(50, 2) + np.array([2, 2]),
    np.random.randn(50, 2) + np.array([-2, -2])
])

# 2. Khởi tạo và huấn luyện mô hình K-Means với k=2
kmeans = KMeans(k=2, max_iters=100)
kmeans.fit(X)

# 3. In kết quả trung tâm cụm (centroids)
print("Tọa độ các tâm cụm (Centroids):")
print(kmeans.centroids)

# 4. Dự đoán nhãn cho các điểm dữ liệu (nếu lớp KMeans có hàm predict)
# Hoặc gán nhãn dựa vào khoảng cách gần nhất tới các centroids
labels = np.argmin([np.linalg.norm(X - c, axis=1) for c in kmeans.centroids], axis=0)

# 5. Vẽ biểu đồ trực quan
plt.figure(figsize=(8, 6))
plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', marker='o', alpha=0.7, edgecolors='k', label='Dữ liệu mẫu')
plt.scatter(kmeans.centroids[:, 0], kmeans.centroids[:, 1], c='red', marker='X', s=250, edgecolors='k', label='Tâm cụm (Centroids)')

plt.title("Trực quan hóa thuật toán K-Means - Utelearn", fontsize=14)
plt.xlabel("Trục X", fontsize=12)
plt.ylabel("Trục Y", fontsize=12)
plt.legend()
plt.grid(True, linestyle='--', alpha=0.5)
plt.show()

Author

Metadata

Release files for utelearn 0.2.2026

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

Source distribution (sdist)

Source distribution for utelearn 0.2.2026
File Size Uploaded
utelearn-0.2.2026.tar.gz 2.9 kB Details

Built distribution (wheel)

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

Total release size: 6.0 kB

Release files / utelearn-0.2.2026.tar.gz

Download URL utelearn-0.2.2026.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
224a12ba51104592d55bd392687257dad91731277221f928e6fc5c60aa3889c3
BLAKE2b-256 checksum
How to use checksums
2d8581b005c3d714d67b4045038f4b14f5f24b153e430456be4aac1577413205
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.4

Release files / utelearn-0.2.2026-py3-none-any.whl

Download URL utelearn-0.2.2026-py3-none-any.whl
Size 3.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03489ea9b7ccf705127194b342acff822b03d1748552586d01d7aff4b792eb85
BLAKE2b-256 checksum
How to use checksums
27b2b5ebfd34325f95be817f363070a570dd3a091aef94eda201c808a3951462
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.4
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