Linear Regression Algorithm
Project description
POLINOMIAL REGRESSION ALGORITHM
pip3 install regressionAlgorithm
POLYNOMIAL ORDER 1
from regressionAlgorithm import PolynomialOrderOne
import matplotlib.pyplot as plt
# value
x = [1,2,3,4,5]
y = [5,4,3,2,1]
# intial
rl = PolynomialOrderOne()
rl.fit(x,y)
rl.start()
# get data
print(rl.plot())
print(rl.line())
# data visualization
plt.figure(figsize=(10,7))
plt.scatter(x,y)
plt.plot(x, rl.line())
plt.savefig("visual.png")
# r squared
print(rl.r_squared()) # result 1.0
# r value
print(rl.r_value()) # result -1.0
PREDICT Y VALUE
...
x = 10
# formula (y = a + b * x) = (y = a + b * 10)
print(rl.predict(x)) # result -4.0
POLYNOMIAL ORDER 2
from regressionAlgorithm import PolynomialOrderTwo
import matplotlib.pyplot as plt
# value
x = [1,2,3,4,5]
y = [5,4,3,2,1]
# intial
q = PolynomialOrderTwo()
q.fit(x,y)
q.start()
# result
print(q.plot())
print(q.r_square())
# data visualization
plt.figure(figsize=(10,7))
plt.scatter(x,y, color="blue")
plt.plot(x, k.draw_line(), color="red")
plt.savefig("quadratic.png")
PREDICT Y VALUE
...
x_pred = 5
# formula y = a + b * x + c * square(x) -> y = a + b * x_red + c * square(x_pred)
print(q.predict(x_pred)) # result 0.9999999999997522
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
File details
Details for the file regressionAlgorithm-0.1.tar.gz
.
File metadata
- Download URL: regressionAlgorithm-0.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 123a46c76093c5c11f40ced305d513646e96c84270eb5f39fbc6f0076da67b8f |
|
MD5 | 31bbb77daa9f767a7fa198a62cc9e12c |
|
BLAKE2b-256 | 9ae04ebccd61b126f3808eaf433e7d4a4af51751ac9ec78697e94b03b204dfdb |