An open API service indexing awesome lists of open source software.

https://github.com/yetalit/Mojmelo

Machine Learning algorithms in pure Mojo 🔥
https://github.com/yetalit/Mojmelo

Last synced: 21 days ago
JSON representation

Machine Learning algorithms in pure Mojo 🔥

Awesome Lists containing this project

README

        

[![Issues][issues-shield]][issues-url]
[![BSD-3-Clause License][license-shield]][license-url]
![CodeQL](https://github.com/yetalit/Mojmelo/workflows/CodeQL/badge.svg)





Logo

Mojmelo



Report Bug
·
Request Feature


## About The Project

The name `Mojmelo` is derived from the "Mojo Machine Learning" expression. It includes the implementation of Machine Learning algorithms from scratch in pure Mojo.
Here is the list of the algorithms:
* Linear Regression
* Polynomial Regression
* Logistic Regression
* KNN
* KMeans
* DBSCAN
* SVM
1. Primal
2. Dual
* Perceptron (single layer: Binary Classification)
* Naive Bayes
1. GaussianNB
2. MultinomialNB
* Decision Tree (both Regression/Classification)
* Random Forest (both Regression/Classification)
* GBDT (both Regression/Classification)
* PCA
* LDA
* Adaboost

Preprocessing:
* normalize
* MinMaxScaler
* StandardScaler
* KFold
* GridSearchCV

**Mojmelo will not only be limited to above algorithms.**

## Getting Started

If you are not familiar with Magic CLI and Mojo projects, here are some links to get you started: (Magic CLI) https://docs.modular.com/magic/ , (Mojo) https://docs.modular.com/mojo/manual/get-started/

### Prerequisites

* Mojo compiler

Additionally, you may want to install bellow Python packages for a better usability and to run tests:
1. Numpy
2. Pandas
3. Scikit-learn
4. Matplotlib

### Installation

There are two ways you can install mojmelo: Using Magic CLI or through the source code.

To complete the installation, you should also finish the setup process which will be discussed later.

#### Magic CLI

Make sure you have the Modular community channel (https://repo.prefix.dev/modular-community) in your `mojoproject.toml` file or `pixi.toml` file in the channels section, then Run the following command:
```
magic add mojmelo
```

To start the setup process, Run the following command from the `main folder` of your project:
```
bash ./.magic/envs/default/etc/conda/test-files/mojmelo/0/tests/setup.sh
```

Note: For better results, please try not to run other tasks on your pc during the setup process.

#### Source Code

You can also install mojmelo through the source code. This way, you will have the source code in your project.

First, Download `mojmelo` folder and `setup.mojo` file. Then Add the following task to your `mojoproject.toml` file or `pixi.toml` file in the tasks section:
```
[tasks]
setup = """
cd &&
mojo ./setup.mojo &&
mojo ./setup.mojo 1 &&
mojo ./setup.mojo 2 &&
mojo ./setup.mojo 3 &&
mojo ./setup.mojo 4 &&
mojo ./setup.mojo 5 &&
mojo ./setup.mojo 6 &&
mojo ./setup.mojo 7 &&
mojo ./setup.mojo 8 &&
mojo ./setup.mojo 9"""
```

Don't forget to change `` according to where `mojmelo` folder and `setup.mojo` file are stored.

Then Run the following command to start the setup process:
```
magic run setup
```

Note: For better results, please try not to run other tasks on your pc during the setup process.

## Usage

Just import any model you want this way:
```python
from mojmelo.LinearRegression import LinearRegression
```
You may also want to use the utility codes I've written for this project:
```python
from mojmelo.utils.Matrix import Matrix
from mojmelo.utils.utils import *
```

## Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

You can contribute to the project in 3 ways:
1. Apply improvements to the code and Open a Pull Request
2. Report a bug
3. Suggest new features

## Acknowledgments

Took inspiration from Patrick Loeber's MLfromscratch and Erik Linder-Norén's ML-From-Scratch

Mojo usage and distribution is licensed under the [MAX & Mojo Community License](https://www.modular.com/legal/max-mojo-license).

[issues-shield]: https://img.shields.io/github/issues/yetalit/mojmelo
[issues-url]: https://github.com/yetalit/mojmelo/issues
[license-shield]: https://img.shields.io/badge/license-BSD%203--Clause-blue
[license-url]: https://github.com/yetalit/Mojmelo/blob/main/LICENSE