Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drsoliddevil/mlr-gd
Multiple linear regression by gradient descent.
https://github.com/drsoliddevil/mlr-gd
data-science gradient-descent linear-regression machine-learning ml numpy python regression
Last synced: 1 day ago
JSON representation
Multiple linear regression by gradient descent.
- Host: GitHub
- URL: https://github.com/drsoliddevil/mlr-gd
- Owner: DrSolidDevil
- License: bsd-3-clause
- Created: 2025-01-09T16:02:55.000Z (27 days ago)
- Default Branch: main
- Last Pushed: 2025-02-03T21:15:50.000Z (2 days ago)
- Last Synced: 2025-02-03T21:34:15.717Z (2 days ago)
- Topics: data-science, gradient-descent, linear-regression, machine-learning, ml, numpy, python, regression
- Language: Python
- Homepage: https://pypi.org/project/mlr-gd/
- Size: 102 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Multiple linear regression by gradient descent.
Disclaimer:
This code is very early on and my first proper attempt to create a package so things may be a bit weird/not up to standard.
Installation
To install mlr-gd you can use [pip](https://pip.pypa.io):
```bash
$ python -m pip install mlr-gd
```Alternatively, you can install it by cloning the [GitHub repository](https://github.com/DrSolidDevil/mlr-gd):
```bash
$ git clone https://github.com/DrSolidDevil/mlr-gd.git
$ cd mlr-gd
$ pip install .
```
To import the package into your script:
```python
import melar
```
Example
```python
import numpy as np
import melar# y = x1 + 0.5*x2
x = np.array([[1, 3, 5, 8], [1, 2, 3, 6]])
y = np.array([1.5, 4, 6.5, 11])learning_rate = 0.01
generations = 100model = melar.LinearRegression(weights_amount=2)
model.train(x, y, learning_rate, generations, do_print=True)
print(f"Weights: {model.weights}, Bias: {model.bias}")
``````
Gen: 0, Cost: 95.4852602406095
Gen: 1, Cost: 5.593624864417041
Gen: 2, Cost: 0.3286224504551768
Gen: 3, Cost: 0.020244781001893267
...
Gen: 99, Cost: 0.0007438760098695897
Training Complete
Weights: [0.94643617 0.57630021], Bias: -0.003265101149422934
```