Skip to main content

A package for multiple linear regression by gradient descent.

Project description




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:

$ 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.1.2.tar.gz (4.1 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.1.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file mlr_gd-0.1.2.tar.gz.

File metadata

  • Download URL: mlr_gd-0.1.2.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for mlr_gd-0.1.2.tar.gz
Algorithm Hash digest
SHA256 51abd3b87a16d654aa691fa141e7c4a2c60b4897e4c9e0046faa5c9c01732ab4
MD5 d97aa0a787160a96df2b2c982e244d63
BLAKE2b-256 670dc84f69febc17fae13b691ae0f76bc617a090ba347c676c7a7fc9d497cdc2

See more details on using hashes here.

File details

Details for the file mlr_gd-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mlr_gd-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for mlr_gd-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 593d11a56341332d4222524d69110577b0f6cdb686e8bcee794d3ca033fbacd4
MD5 8c85ad8581205c56706441883dc4b9bd
BLAKE2b-256 77ed2a3e14602f0f5dea5e382ccc7f2c34ae0cc8b7c601833cfdfc47cebc8e69

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