LinPredict
Simple linear prediction library. Pass x and y values, get the next predicted value.
Installation
pip install linpredict
Quick Start
from linpredict import quick_predict, fit, predict_next
# Simplest usage - just pass y values
predictions = quick_predict([2, 4, 6, 8])
print(predictions) # [10.0]
# Predict multiple steps ahead
predictions = quick_predict([2, 4, 6, 8], steps=3)
print(predictions) # [10.0, 12.0, 14.0]
Full Usage
from linpredict import fit, predict_next
# Fit a line to your data
x = [1, 2, 3, 4, 5]
y = [2.1, 3.9, 6.2, 7.8, 10.1]
# Get the line equation
eq = fit(x, y)
print(eq) # y = 1.9900x + 0.0600
# Access slope and intercept
print(f"Slope: {eq.slope}") # ~2.0
print(f"Intercept: {eq.intercept}") # ~0.0
# Predict specific x values
print(eq.predict(6)) # Single prediction
print(eq.predict([6, 7, 8])) # Multiple predictions
# Or use predict_next for automatic next value
next_x, next_y = predict_next(x, y, steps=2)
print(f"Next x: {next_x}, Next y: {next_y}")
API Reference
fit(x, y) -> LineEquation
Fit a line (y = mx + c) to data points. Returns a LineEquation object.
predict_next(x, y, steps=1) -> (list, list)
Predict the next value(s) in sequence. Returns tuple of (next_x_values, predicted_y_values).
quick_predict(y, steps=1) -> list
Quick prediction when you only have y values (assumes x is 0, 1, 2, ...).
LineEquation
.slope- The m in y = mx + c.intercept- The c in y = mx + c.predict(x)- Predict y for given x value(s)
License
MIT
Author
PRAVIN MR
GitHub: https://github.com/mr-pravin
Email: mrpravin000@gmail.com
Metadata
Release files for linpredict 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| linpredict-0.1.0.tar.gz | 5.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| linpredict-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.8 kB
Release files / linpredict-0.1.0.tar.gz
| Download URL | linpredict-0.1.0.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06d1e6e4f9074c4f20a315036c70c3042e7b9da52e8cd624ea6dc1f9ef25e859
|
|
BLAKE2b-256 checksum How to use checksums |
1b92b1f74b6c7bf5373f21daf1f0a63477a79f9a0061c5f3a41f58e26c33031d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Release files / linpredict-0.1.0-py3-none-any.whl
| Download URL | linpredict-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9885749021e4b8219b3cafbd2f25ac940340ded59c686cf451210a33a54bcdd5
|
|
BLAKE2b-256 checksum How to use checksums |
4c5e5122fab9b2689fe53bfee2e0ef0d18e24db1c067c56bbecc9a0780f0136a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|