ETIA.AFS.predictive_model
- class PredictiveModel[source]
Bases:
objectA class for creating and training predictive models.
- random_forest(config, target_type)[source]
Creates a Random Forest model based on the configuration and target type.
- fit(config, train_X, train_y, selected_features, preprocessor, target_type)[source]
Fits the model to the training data using the specified configuration.
- random_forest(config: Dict[str, Any], target_type: str)[source]
Creates a Random Forest model based on the configuration and target type.
- Parameters:
config (dict) – Configuration settings for the Random Forest model, including hyperparameters like n_estimators, min_samples_leaf, and max_features.
target_type (str) – The type of the target variable (‘categorical’ for classification, ‘continuous’ for regression).
- Returns:
model – The initialized Random Forest model.
- Return type:
RandomForestClassifier or RandomForestRegressor
- linear_regression()[source]
Creates a Linear Regression model.
- Returns:
model – The initialized Linear Regression model.
- Return type:
LinearRegression
- fit(config: Dict[str, Any], train_X: Any, train_y: Any, selected_features: Any, preprocessor: Any | None, target_type: str)[source]
Fits the model to the training data.
- Parameters:
config (dict) – Configuration settings for the model, including the type of model (‘random_forest’ or ‘linear_regression’).
train_X (array-like) – Training data for the input variables.
train_y (array-like) – Training data for the target variable.
selected_features (any) – The features selected for model training.
preprocessor (object, optional) – A preprocessor object that can be used to transform the input data. Default is None.
target_type (str) – The type of the target variable (‘categorical’ or ‘continuous’).
- Raises:
ValueError – If an unsupported model type is specified in the configuration.