Poly Regression
Module: deeprai.models.regression.poly_regression
Class: PolyRegression
A class representation of the polynomial regression model.
1. Initializer: __init__(self)
Description:
Initializes the PolyRegression
class.
Attributes:
- fitted_vals (
list
): A list to store the results after the model has been fitted. These values represent the coefficients of the polynomial equation.
Example:
from deeprai.models.regression import PolyRegression
model = PolyRegression()
2. Method: fit(self, x_vals, y_vals)
Description:
Fit the model to the given x_vals
and y_vals
using polynomial regression.
Parameters:
-
x_vals (
list
ornp.ndarray
): The input values or features. -
y_vals (
list
ornp.ndarray
): The output values or labels.
Returns:
list
: Coefficients of the polynomial equation, starting from the coefficient of the highest degree term.
Example:
model.fit(x_vals=[1, 2, 3], y_vals=[2, 5, 10])
3. Method: run(self, x_val)
Description:
Use the previously fitted model to predict the output for a given x_val
based on the polynomial equation.
Parameters:
- x_val (
float
): The input value for which the prediction is desired.
Returns:
float
: Predicted value based on the polynomial regression equation.
Example:
predicted_val = model.run(4)
print(predicted_val)
No Comments