Skip to main content

A package for multiple linear regression by gradient descent.

Project description




GitHub Release PyPI - Downloads PyPI - Python Version GitHub repo size Read the Docs GitHub License

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


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlr_gd-0.3.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

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

Hashes for mlr_gd-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a125b1b2a722d723418cbae4fc2be8d8c11dca26ef8cd6b560006cf435610a43
MD5 4e89034e17a2c958009e842956d6f55f
BLAKE2b-256 6218111a9df023ca8899ed18ae50f1719a2158d71625f7fb28f2f07b8b83ca42

See more details on using hashes here.

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

Hashes for mlr_gd-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9992fdc754dd5fae55876db09a2b5da5a47e823b32ef434c219bffd2c4dc76d
MD5 05a60282445db20d8f67695e6e414ce1
BLAKE2b-256 9fc415b79fab642fb620c2c3f9c419c16b0313658514cf57b11cea89ffc91ace

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page