Skip to main content

Here's the English translation of your machine learning lab README:


Machine Learning Labs

GitHub stars GitHub forks GitHub license GitHub issues

中文文档


This repository contains machine learning models implemented from scratch using numpy, pandas, and matplotlib, aimed at helping learners understand the internal workings of various machine learning algorithms. If you encounter any issues while using this repository, feel free to open an Issue or improve the project by submitting a Pull Request.

Features

  • Implement machine learning algorithms manually and package them in Python for testing.
  • Provide comprehensive basic tests.
  • Easily create and run custom tests.

Install Dependencies

Use the requirements.txt file to configure the environment dependencies. It’s recommended to use pload as a lightweight virtual environment management tool focused on managing Python environments. To set it up, follow these steps:

pload new -m 'MLLabs' -v 3.8.20 -f requirements.txt  # v3.8.20 recommended; other versions not tested.

Usage

The following sections outline how to run benchmark tests, custom models, and create and execute tests.

1. Run Benchmark Tests

First, create a dedicated virtual environment for the project and activate it. To learn more about using pload to create virtual environments, refer to: Creating Virtual Environments with pload.

  1. Clone the Repository:

    git clone --branch main --single-branch https://github.com/HugoPhi/MachineLearningLabs.git
    
  2. Install Local Library:

    Enter the project directory:

    cd MachineLearningLabs/
    

    Compile and install the library:

    pip install .
    

    You can verify successful installation by running pip list and checking if the hym library is included.

  3. Run Tests:

    For example, to run the test/DecisionTree/watermelon2.0 experiment, execute the following in the project directory:

    python ./test/DecisionTree/watermelon2.0/main.py
    

    This will generate the experiment results.

2. Custom Models

You can modify or create your own machine learning models. The project structure is divided into two main parts: src and test. The src directory stores the source code for machine learning algorithms, while the test directory stores basic and custom tests for each algorithm. Understanding the project structure will help you modify it more efficiently.

2.1 src Directory

The src directory stores the source code and is organized as follows:

src/
├── hym/
│   ├── __init__.py
│   ├── DecisionTree/
│   │   ├── __init__.py
│   │   ├── DecisionTree.py
│   │   └── ...
│   ├── LinearRegression/
│   └── ...
  • hym/: Top-level module containing the implementations of various machine learning algorithms.

  • To add a new algorithm category, such as Support Vector Machine, create a SupportVectorMachine/ directory under hym/, and add it to hym/__init__.py as follows:

    from . import DecisionTree
    from . import LinearRegression
    from . import SupportVectorMachine  # New algorithm module
    
    __all__ = [
        'DecisionTree',
        'LinearRegression',
        'SupportVectorMachine'  # Add new module
    ]
    
  • File Naming Conventions:

    1. Algorithm Class Files: Use CamelCase, e.g., BasicDecisionTree.py, Variants.py, for implementing algorithm classes.
    2. Helper Class Files: Use snake_case, e.g., node.py, for implementing helper classes.
    3. Helper Function Files: utils.py contains utility functions, e.g., data loading, preprocessing, and math functions.
    4. Package Initialization File: __init__.py, which marks the package and submodules, with exported contents listed in __all__.

2.2 test Directory

The test directory stores test code and is structured similarly to src:

test/
├── DecisionTree/
│   ├── iris/
│   │   ├── iris.xlsx
│   │   └── main.py
│   ├── watermelon2.0/
│   │   ├── watermelon2.0.xlsx
│   │   └── main.py
│   └── ...
├── LinearRegression/
└── ...
  • Create directories under test/ by algorithm category, matching the structure in src/.
  • Inside each algorithm directory, add test cases. Some tests for basic datasets are already provided, but you can also add your own experiments.

2.3 Other Important Files

  1. setup.py

    Contains package build information such as version, dependencies, and author information. The version format follows v[x].[y].[z], where:

    • x: Major updates, breaking API changes.
    • y: Significant new features, such as implementing a new algorithm category.
    • z: Minor updates, including bug fixes or small adjustments.
  2. README.md

    Documents usage and updates. It’s recommended to check periodically for the latest information.

Progress

Algorithm Library
  • Supervised Learning
    • Linear Regression
    • Logistic Regression
    • Decision Tree
      • ID3
      • C4.5
      • CART
    • Support Vector Machine
    • Neural Networks
  • Unsupervised Learning
    • K-means Clustering
    • Principal Component Analysis
Testing
  • Supervised Learning
    • Linear Regression
    • Logistic Regression
      • iris
    • Decision Tree
      • watermelon2.0
      • iris
      • ice-cream
      • wine quality
      • house price
    • Support Vector Machine
    • Neural Networks
  • Unsupervised Learning
    • K-means Clustering
    • Principal Component Analysis

References

Add your references here.

License

This project is licensed under the MIT License. Please refer to the LICENSE file for details.


If you find this project helpful, please consider ⭐️ starring us!

Star History Chart


Metadata

Release files for hym20220592 0.1.5

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

Source distribution (sdist)

Source distribution for hym20220592 0.1.5
File Size Uploaded Provenance Actions
hym20220592-0.1.5.tar.gz 11.8 kB Without provenance Details for hym20220592-0.1.5.tar.gz

Built distribution (wheel)

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

Total release size: 23.6 kB

Release files / hym20220592-0.1.5.tar.gz

Download URL hym20220592-0.1.5.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7931f99e0e04b02d5530ece415800b077e60006d7112456b19a7c4edb69e394b
BLAKE2b-256 checksum
How to use checksums
a803eef0d11b81ac919a17f0c491a2a42381b592aa462dd0d8375460f26e36b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / hym20220592-0.1.5-py3-none-any.whl

Download URL hym20220592-0.1.5-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e39bba7a1a727600012f26d4de6f05f6b125f1dd04636b8b2793bb331c80a830
BLAKE2b-256 checksum
How to use checksums
9188106dec6f5d07dea4f0e4a34b09cb9afdc11c3b93e001e4875db5b7ac5ab1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Security for hym20220592 0.1.5

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.1.5 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