Skip to content

alvii147/DataCheese

Repository files navigation

Free Palestine

Genocide Watch

DataCheese logo

DataCheese is a Python library with implementations of popular data science and machine learning algorithms.

License Documentation

Installation

Python 3.10 or above required.

2️⃣ Install package using pip

Install directly from the repository:

pip3 install git+https://github.com/alvii147/DataCheese.git

Usage

The MultiLayerPerceptron model can be used to train a feed-forward neural network using data:

import numpy as np
from datacheese.neural_networks import (
    MultiLayerPerceptron,
    SigmoidLayer,
    ReLULayer,
)

# number of data patterns
n_patterns = 5
# number of feature dimensions
n_dimensions = 3
# number of target classes
n_classes = 2

# generate random data
rng = np.random.default_rng()
X = rng.random(size=(n_patterns, n_dimensions))
Y = rng.random(size=(n_patterns, n_classes))

# initialize multi-layer perceptron model
model = MultiLayerPerceptron(lr=0.5)
# add relu layer
model.add_layer(ReLULayer(n_dimensions, 4))
# add sigmoid layer
model.add_layer(SigmoidLayer(4, n_classes))
# fit model to data
model.fit(X, Y, epochs=20, verbose=1)

When verbose is non-zero, progress is logged:

Epoch: 0, Loss: 0.15181599599950849
Epoch: 4, Loss: 0.13701115369406147
Epoch: 8, Loss: 0.11337662383705667
Epoch: 12, Loss: 0.10121139637335393
Epoch: 16, Loss: 0.09388681525946835

The model can then be used to make predictions:

# predict target values
Y_pred = model.predict(X)
# compute mean squared loss
print(np.mean((Y_pred - Y) ** 2))

This outputs the following:

0.05310463606057757

For more details, visit the documentation pages.

About

Python library with implementations of popular data science and machine learning algorithms

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages