https://github.com/alvii147/datacheese
Python library with implementations of popular data science and machine learning algorithms
https://github.com/alvii147/datacheese
data-science machine-learning python
Last synced: about 1 year ago
JSON representation
Python library with implementations of popular data science and machine learning algorithms
- Host: GitHub
- URL: https://github.com/alvii147/datacheese
- Owner: alvii147
- License: bsd-3-clause
- Created: 2023-03-06T21:43:03.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-08-11T23:18:58.000Z (almost 2 years ago)
- Last Synced: 2025-02-16T16:57:55.810Z (over 1 year ago)
- Topics: data-science, machine-learning, python
- Language: Python
- Homepage:
- Size: 2.95 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.pcrf.net/)
[](https://www.pcrf.net/)
DataCheese is a Python library with implementations of popular data science and machine learning algorithms.
[](https://github.com/alvii147/DataCheese/actions) [](https://opensource.org/licenses/BSD-3-Clause) [](https://alvii147.github.io/DataCheese/build/html/index.html)
## Installation
### :one: [Install Python](https://www.python.org/)
Python 3.10 or above required.
### :two: Install package using [pip](https://pypi.org/project/pip/)
Install directly from the repository:
```bash
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:
```python
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:
```python
# 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](https://alvii147.github.io/DataCheese/build/html/index.html).