A package for multiple linear regression by gradient descent.
Project description
Multiple linear regression by gradient descent.
Installation
To install mlr-gd you can use pip:
$ python -m pip install mlr-gd
Alternatively, you can install it by cloning the GitHub repository:
$ git clone https://github.com/DrSolidDevil/mlr-gd.git
$ cd mlr-gd
$ pip install .
To import the package into your script:
import melar
Example
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 = 100
model = 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mlr_gd-0.3.0.tar.gz
(10.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mlr_gd-0.3.0.tar.gz.
File metadata
- Download URL: mlr_gd-0.3.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a125b1b2a722d723418cbae4fc2be8d8c11dca26ef8cd6b560006cf435610a43
|
|
| MD5 |
4e89034e17a2c958009e842956d6f55f
|
|
| BLAKE2b-256 |
6218111a9df023ca8899ed18ae50f1719a2158d71625f7fb28f2f07b8b83ca42
|
File details
Details for the file mlr_gd-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mlr_gd-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9992fdc754dd5fae55876db09a2b5da5a47e823b32ef434c219bffd2c4dc76d
|
|
| MD5 |
05a60282445db20d8f67695e6e414ce1
|
|
| BLAKE2b-256 |
9fc415b79fab642fb620c2c3f9c419c16b0313658514cf57b11cea89ffc91ace
|