Thanks to visit codestin.com
Credit goes to github.com

Skip to content

You will see my own models made from scratch. Hope this can help you understand how they are working under the hood.

License

Notifications You must be signed in to change notification settings

myrodar/AI_cookbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Binary Classifier Models

Welcome to the Binary Classifier Models repository. This library provides two simple, easy-to-understand implementations of fundamental machine learning algorithms for binary classification tasks, built with pure Python and NumPy.

Models

  • Decision Tree (dt.py): A depth-limited decision tree that splits features based on thresholding at 0.5.
  • Perceptron (main.py): A classic single-layer perceptron suitable for linearly separable data.

Installation

  1. Clone the repository:
    git clone https://github.com/myrodar/AI_cookbook.git
    cd your-repo
  2. (Optional) Create and activate a virtual environment:
    python3 -m venv venv
    source venv/bin/activate
  3. Install dependencies:
    pip install -r requirements.txt

Getting Started

Coming soon!

Decision Tree (dt.py)

  • DT(opts: dict)
    Initialize with options:

    • opts['maxDepth']: Maximum depth of the tree.
  • train(X: np.ndarray, Y: Sequence[int])
    Build the decision tree from the data.

  • predict(x: np.ndarray) -> int
    Predict the label (-1 or 1) for a single sample.

  • __repr__() / displayTree()
    Print a human-readable representation of the tree.

Perceptron

This folder contains two scripts.

Contributing

This folder contains two scripts:

  • main.py is the main script for the raw perceptron. It contains the Perceptron class and its main function to instantiate, train, and predict based on the data you provide.

  • test.py uses the Perceptron implementation from main.py and generates a visual representation of the decision boundary, allowing you to see how the single neuron learns.

  • Challenge: Try swapping the generated dataset for the Iris dataset. Be sure to use only two classes from the Iris dataset, as a perceptron can only perform binary classification.

Contributing

Contributions are welcome. To contribute: Contributions are welcome. To contribute:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/your-feature.
  3. Commit your changes and push your branch.
  4. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

You will see my own models made from scratch. Hope this can help you understand how they are working under the hood.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages