Skip to content

CalibrationModel

CalibrationModel

The function creates the calibrated model.

Parameters:

  • x_data: pd.DataFrame
    A pandas DataFrame with explanatory variables.
  • y_data: pd.Series
    A pandas Series with discrete dependent variable.
  • penalty: str, optional, {None, 'l1', 'l2'}, default = None
    Regularization for Logistic Regression model.
  • alpha: float, default = 0.5
    A float variable for regularization.
  • fit_intercept: bool, {True, False}, default = True
    Whether to fit intercept in the Logistic Regression or not.

Returns:

  • model: Logistic Regression Model

Exceptions:

  • TypeError:
    Raised if x_data parameter is not a pandas DataFrame object.
    Raised if y_data parameter is not a pandas Series.
    Raised if fit_intercept parameter is not logical.

  • ValueError:
    Raised if lengths of x_data and y_data are not identical.
    Raised if penalty parameter is not in [None, 'l1', 'l2'].
    Raised if alpha parameter is not a float from 0 to 1.

Example:

import pandas as pd
from combat.calibration import CalibrationModel

# Sample input data
x_data = pd.DataFrame({'A': [1, 2, 3, 4, 5], 'B': [6, 7, 8, 9, 10]})
y_data = pd.Series([0, 1, 0, 1, 0])
penalty = None
alpha = 0.5
fit_intercept = True

# Create Calibration Model
model = CalibrationModel(x_data, y_data, penalty, alpha, fit_intercept)