Skip to main content

Sine Regression

Module: deeprai.models.regression.sine_regression


Class: SineRegression

A class representation of the sine regression model.


1. Initializer: __init__(self)

Description:

Initializes the SineRegression class.

Attributes:

  • fitted_vals (list): A list to store the results after the model has been fitted. These values represent the parameters of the sine equation.

Example:

from deeprai.models.regression import SineRegression

model = SineRegression()

2. Method: fit(self, x_vals, y_vals)

Description:

Fit the model to the given x_vals and y_vals using sine regression.

Parameters:

  • x_vals (list or np.ndarray): The input values or features.

  • y_vals (list or np.ndarray): The output values or labels.

Returns:

  • list: Parameters of the sine equation, which includes amplitude, frequency, phase shift, and vertical shift.

Example:

model.fit(x_vals=[1, 2, 3], y_vals=[2, 1.5, 2.5])

3. Method: run(self, x_val)

Description:

Use the previously fitted model to predict the output for a given x_val based on the sine equation.

Parameters:

  • x_val (float): The input value for which the prediction is desired.

Returns:

  • float: Predicted value based on the sine regression equation.

Example:

predicted_val = model.run(4)
print(predicted_val)