robustx.lib.models package
Subpackages
- robustx.lib.models.keras_models package
- robustx.lib.models.pytorch_models package
- Submodules
- robustx.lib.models.pytorch_models.CustomPyTorchModel module
CustomPyTorchModelCustomPyTorchModel.modelCustomPyTorchModel.criterionCustomPyTorchModel.optimizerCustomPyTorchModel.train()CustomPyTorchModel.predict()CustomPyTorchModel.predict_single()CustomPyTorchModel.predict_proba()CustomPyTorchModel.evaluate()CustomPyTorchModel.evaluate()CustomPyTorchModel.predict()CustomPyTorchModel.predict_proba()CustomPyTorchModel.predict_single()CustomPyTorchModel.train()
- robustx.lib.models.pytorch_models.SimpleNNModel module
SimpleNNModelSimpleNNModel.input_dimSimpleNNModel.hidden_dimSimpleNNModel.output_dimSimpleNNModel.criterionSimpleNNModel.optimizerSimpleNNModel.__create_model()SimpleNNModel.train()SimpleNNModel.set_weights()SimpleNNModel.predict()SimpleNNModel.predict_single()SimpleNNModel.evaluate()SimpleNNModel.predict_proba()SimpleNNModel.predict_proba_tensor()SimpleNNModel.get_torch_model()SimpleNNModel.compute_accuracy()SimpleNNModel.evaluate()SimpleNNModel.get_torch_model()SimpleNNModel.predict()SimpleNNModel.predict_proba()SimpleNNModel.predict_proba_tensor()SimpleNNModel.predict_single()SimpleNNModel.set_weights()SimpleNNModel.train()
- Module contents
- robustx.lib.models.sklearn_models package
Submodules
robustx.lib.models.BaseModel module
- class robustx.lib.models.BaseModel.BaseModel(model)[source]
Bases:
ABCAbstract base class to define the essential methods that all model types must implement, providing template for training, predicting, and evaluating models in a standardized way.
- _model
The underlying model object (e.g., a scikit-learn model or a PyTorch model) that this class wraps.
- Type:
object
- train(X: pd.DataFrame, y: pd.DataFrame) None:[source]
Trains the model using the provided feature and target data.
- predict_single(X: pd.DataFrame) int:[source]
Predicts the outcome for a single instance and returns an integer.
- predict_proba(X: pd.DataFrame) pd.DataFrame:[source]
Predicts the probabilities of outcomes for the given instances.
- predict_proba_tensor(X: torch.Tensor) torch.Tensor:[source]
Predicts the probabilities of outcomes for tensor inputs.
- evaluate(X: pd.DataFrame, y: pd.DataFrame):
Evaluates the model’s performance on the provided feature and target data.
- Properties()
- ----------
- model:
Returns the underlying model object.
- abstract evaluate(X, y)[source]
Evaluates the model’s performance on the provided feature and target data.
@param X: pd.DataFrame, The feature variables. @param y: pd.DataFrame, The target variable.
@return: Evaluation result of the model.
- property model
Returns the underlying model object.
@return: The model object.
- abstract predict(X)[source]
Uses the model to predict the outcomes for any number of instances.
@param X: pd.DataFrame, Instances to predict.
@return: pd.DataFrame, Predictions for each instance.
- Return type:
DataFrame
- abstract predict_proba(X)[source]
Predicts the probabilities of outcomes.
@param X: pd.DataFrame, Instances to predict.
@return: pd.DataFrame, Probabilities of each outcome.
- Return type:
DataFrame
- abstract predict_proba_tensor(X)[source]
Predicts the probabilities of outcomes for tensor inputs.
@param X: torch.Tensor, Instances to predict.
@return: torch.Tensor, Probabilities of each outcome.
- Return type:
Tensor
- abstract predict_single(X)[source]
Predicts the outcome of a single instance and returns an integer.
@param X: pd.DataFrame, Instance to predict.
@return: int, Prediction as an integer.
- Return type:
int
- abstract train(X, y, **kwargs)[source]
Trains the model using X feature variables and y target variable. Each implementing class can decide how to train their model and can add additional parameters, but X and y must be of type DataFrame.
@param X: pd.DataFrame, The feature variables. @param y: pd.DataFrame, The target variable.
@return: None
- Return type:
None
robustx.lib.models.Models module
- robustx.lib.models.Models.get_sklearn_model(name)[source]
Retrieves an instance of a scikit-learn model based on the provided name.
- @param name: The name of the desired model. Options are:
“log_reg” for Logistic Regression
“decision_tree” for Decision Tree
“svm” for Support Vector Machine
@return: An instance of the requested scikit-learn model. The model class should be a subclass of BaseModel.
@raises ValueError: If the provided model name does not match any of the predefined options.