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.2.1.tar.gz (9.4 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.2.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mlr_gd-0.2.1.tar.gz
  • Upload date:
  • Size: 9.4 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.2.1.tar.gz
Algorithm Hash digest
SHA256 a8685da7d8274db287e0aa6f59eb46c2cde427169bf0cadd12ff673cbce6e369
MD5 02517e8b212fd256c7ae745c186e70a3
BLAKE2b-256 f939ca42ca5346f15362026ae12078bc38f9ecd8dd5a5aef7ee714e4ff83af64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlr_gd-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 124c7f43a52367cc4e522bf8b40da2244eab9211c88618c567dd4af00113631f
MD5 3b3f519e7dee89722625e04756268bbf
BLAKE2b-256 e27768ac1985439e22db88626736ab65fa8bd94533d2d5756b47f2b5f0852283

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