Class RegressionService

java.lang.Object
com.leumanuel.woozydata.service.RegressionService

public class RegressionService extends Object
Service class for regression analysis and correlation calculations. Provides methods for various types of regression models and statistical correlations.
Version:
1.0
Author:
Leu A. Manuel
  • Constructor Details

    • RegressionService

      public RegressionService()
  • Method Details

    • calculatePearsonCorrelation

      public double calculatePearsonCorrelation(DataFrame dataFrame, String column1, String column2)
      Calculates Pearson correlation coefficient between two columns.
      Parameters:
      dataFrame - DataFrame containing the data
      column1 - Name of first column
      column2 - Name of second column
      Returns:
      Pearson correlation coefficient
      Throws:
      IllegalArgumentException - if columns are not numeric
    • simpleLinearRegression

      public double[] simpleLinearRegression(DataFrame dataFrame, String xColumn, String yColumn)
      Performs simple linear regression between two columns. Returns array containing [slope, intercept].
      Parameters:
      dataFrame - DataFrame containing the data
      xColumn - Independent variable column name
      yColumn - Dependent variable column name
      Returns:
      double array where [0] = slope, [1] = intercept
      Throws:
      IllegalArgumentException - if columns are not numeric
    • calculateRSquared

      public double calculateRSquared(DataFrame df, String xCol, String yCol)
      Calculates R-squared (coefficient of determination) for linear regression.
      Parameters:
      df - DataFrame containing the data
      xCol - Independent variable column name
      yCol - Dependent variable column name
      Returns:
      R-squared value
      Throws:
      IllegalArgumentException - if columns are not numeric
    • multipleRegression

      public DataFrame multipleRegression(DataFrame df, String[] xCols, String yCol)
      Performs multiple linear regression analysis.
      Parameters:
      df - DataFrame containing the data
      xCols - Array of independent variable column names
      yCol - Dependent variable column name
      Returns:
      DataFrame containing regression coefficients
      Throws:
      IllegalArgumentException - if any column is not numeric
    • polynomialRegression

      public DataFrame polynomialRegression(DataFrame df, String xCol, String yCol, int degree)
      Performs polynomial regression analysis.
      Parameters:
      df - DataFrame containing the data
      xCol - Independent variable column name
      yCol - Dependent variable column name
      degree - Degree of polynomial
      Returns:
      DataFrame containing polynomial coefficients
      Throws:
      IllegalArgumentException - if columns are not numeric or degree is invalid
    • logisticRegression

      public DataFrame logisticRegression(DataFrame df, String xCol, String yCol)
      Performs logistic regression analysis for binary classification.
      Parameters:
      df - DataFrame containing the data
      xCol - Independent variable column name
      yCol - Dependent variable column name (should contain binary values)
      Returns:
      DataFrame containing logistic regression coefficients
      Throws:
      IllegalArgumentException - if columns are not numeric or y is not binary