aiqclib.train.models package

Submodules

aiqclib.train.models.decision_tree module

This module provides a Decision Tree model wrapper, inheriting from aiqclib.common.base.scikit_learn_model_base.SklearnModelBase.

It facilitates training, prediction, and evaluation of a Decision Tree classifier using Polars DataFrames, converting them to Pandas for compatibility with the sklearn library.

class aiqclib.train.models.decision_tree.DecisionTree(config)[source]

Bases: SklearnModelBase

A Decision Tree model wrapper class for training and testing.

Inherits from SklearnModelBase to reuse common Scikit-Learn API logic.

Features include:

  • Automatic application of model_params from the YAML config, if defined; otherwise, uses default hyperparameters.

  • Uses sklearn.tree.DecisionTreeClassifier.

Note

This class sets expected_class_name to "DecisionTree". Single Decision Trees in scikit-learn generally do not support the n_jobs parameter.

Parameters:

config (ConfigBase)

expected_class_name: str = 'DecisionTree'
short_name: str = 'DT'

aiqclib.train.models.gaussian_naive_bayes module

This module provides a Gaussian Naive Bayes model wrapper, inheriting from aiqclib.common.base.scikit_learn_model_base.SklearnModelBase.

It facilitates training, prediction, and evaluation of a Naive Bayes classifier using Polars DataFrames, converting them to Pandas for compatibility with the sklearn library.

class aiqclib.train.models.gaussian_naive_bayes.GaussianNaiveBayes(config)[source]

Bases: SklearnModelBase

A Gaussian Naive Bayes model wrapper class for training and testing.

Inherits from SklearnModelBase to reuse common Scikit-Learn API logic.

Features include:

  • Automatic application of model_params from the YAML config, if defined; otherwise, uses default hyperparameters.

  • Uses sklearn.naive_bayes.GaussianNB.

Note

This class sets expected_class_name to "GaussianNaiveBayes". Naive Bayes does not support the n_jobs parameter.

Parameters:

config (ConfigBase)

expected_class_name: str = 'GaussianNaiveBayes'
short_name: str = 'GNB'

aiqclib.train.models.k_nearest_neighbors module

This module provides a K-Nearest Neighbors (KNN) model wrapper, inheriting from aiqclib.common.base.scikit_learn_model_base.SklearnModelBase.

It facilitates training, prediction, and evaluation of a KNN classifier using Polars DataFrames, converting them to Pandas for compatibility with the sklearn library.

class aiqclib.train.models.k_nearest_neighbors.KNearestNeighbors(config)[source]

Bases: SklearnModelBase

A K-Nearest Neighbors (KNN) model wrapper class for training and testing.

Inherits from SklearnModelBase to reuse common Scikit-Learn API logic.

Features include:

  • Automatic application of model_params from the YAML config, if defined; otherwise, uses default hyperparameters.

  • Uses sklearn.neighbors.KNeighborsClassifier.

Note

This class sets expected_class_name to "KNearestNeighbors". Note that KNN can be computationally expensive during prediction for large datasets.

Parameters:

config (ConfigBase)

expected_class_name: str = 'KNearestNeighbors'
short_name: str = 'KNN'

aiqclib.train.models.linear_discriminant_analysis module

This module provides a Linear Discriminant Analysis (LDA) model wrapper, inheriting from aiqclib.common.base.scikit_learn_model_base.SklearnModelBase.

It facilitates training, prediction, and evaluation of an LDA classifier using Polars DataFrames, converting them to Pandas for compatibility with the sklearn library.

class aiqclib.train.models.linear_discriminant_analysis.LinearDiscriminantAnalysis(config)[source]

Bases: SklearnModelBase

A Linear Discriminant Analysis (LDA) model wrapper class for training and testing.

Inherits from SklearnModelBase to reuse common Scikit-Learn API logic.

Features include:

  • Automatic application of model_params from the YAML config, if defined; otherwise, uses default hyperparameters.

  • Uses sklearn.discriminant_analysis.LinearDiscriminantAnalysis.

Note

This class sets expected_class_name to "LinearDiscriminantAnalysis". Note that LDA in scikit-learn does not support the n_jobs parameter.

Parameters:

config (ConfigBase)

expected_class_name: str = 'LinearDiscriminantAnalysis'
short_name: str = 'LDA'

aiqclib.train.models.logistic_regression module

This module provides a Logistic Regression model wrapper, inheriting from aiqclib.common.base.scikit_learn_model_base.SklearnModelBase.

It facilitates training, prediction, and evaluation of a Scikit-Learn Logistic Regression classifier using Polars DataFrames.

class aiqclib.train.models.logistic_regression.LogisticRegression(config)[source]

Bases: SklearnModelBase

A Logistic Regression model wrapper class for training and testing.

Inherits from SklearnModelBase to reuse common Scikit-Learn API logic.

Features include:

  • Automatic application of model_params from the YAML config, if defined; otherwise, uses default hyperparameters suitable for standard classification tasks.

  • Uses sklearn.linear_model.LogisticRegression.

Note

This class sets expected_class_name to "LogisticRegression".

Parameters:

config (ConfigBase)

expected_class_name: str = 'LogisticRegression'
short_name: str = 'Logit'

aiqclib.train.models.model_suite module

This module provides the ModelSuite class, inheriting from aiqclib.common.base.model_base.ModelBase.

It facilitates training, prediction, and evaluation with multiple ML methods.

class aiqclib.train.models.model_suite.ModelSuite(config)[source]

Bases: ModelBase

A model suite class for training and testing multiple machine learning models.

Inherits from aiqclib.common.base.model_base.ModelBase to use the common model class interface.

Features include:

  • Automatic application of model_params from the YAML configuration, if defined.

  • Manages a collection of different machine learning models for comparative analysis or ensemble operations.

Note

This class sets expected_class_name to "ModelSuite".

Parameters:

config (ConfigBase)

build()[source]

Builds the model architecture or pipeline for all models in the suite.

This method is intended to orchestrate the build process for each individual model managed by the ModelSuite. Subclasses or implementations could iterate through self.method_objs and call a build method on each if available, or perform other suite-level setup. As implemented, it currently does nothing (pass).

Return type:

None

expected_class_name: str = 'ModelSuite'
multi = True
set_enable_shap(enable_shap)[source]

Sets the SHAP explanation flag for all models within the suite.

Iterates through all instantiated model objects (method_objs) and sets their enable_shap attribute to the specified value. This allows for global control over SHAP explanation generation across models.

Parameters:

enable_shap (bool) – A boolean flag to enable or disable SHAP explanations.

short_name: str = 'MS'
test()[source]

Evaluates the performance of the models in the suite on a test set.

This method is designed to coordinate the testing phase for each individual model. Implementations might iterate through self.method_objs, call a test method on each, and aggregate results, or perform suite-level validation. As implemented, it currently does nothing (pass).

Return type:

None

update_nthreads(model)[source]

Updates the number of threads for the given ModelSuite instance and its internal models.

This method is intended to update the thread configuration for all sub-models managed within the provided ModelSuite instance. The current implementation (pass) indicates it does not perform any operations. It expects to receive an instance of ModelSuite and is designed to return the modified instance.

Parameters:

model (Self) – The ModelSuite instance whose internal models’ thread configurations need to be updated.

Returns:

The updated ModelSuite instance, potentially with modified thread settings for its constituent models.

Return type:

Self

Warning

The current implementation of this method does nothing (pass). Its intended functionality regarding how it interacts with the model parameter (if it’s self or another instance) and how it updates thread counts for individual sub-models is unclear and needs further implementation.

aiqclib.train.models.multilayer_perceptron module

This module provides a Multi-layer Perceptron (MLP) model wrapper, inheriting from aiqclib.common.base.scikit_learn_model_base.SklearnModelBase.

It facilitates training, prediction, and evaluation of an MLP classifier using Polars DataFrames, converting them to Pandas for compatibility with the sklearn library.

class aiqclib.train.models.multilayer_perceptron.MultilayerPerceptron(config)[source]

Bases: SklearnModelBase

A Multi-layer Perceptron (MLP) model wrapper class for training and testing.

Inherits from SklearnModelBase to reuse common Scikit-Learn API logic.

Features include:

  • Automatic application of model_params from the YAML config, if defined; otherwise, uses default hyperparameters.

  • Uses sklearn.neural_network.MLPClassifier.

Note

This class sets expected_class_name to "MultilayerPerceptron". This is a feedforward neural network implementation.

Parameters:

config (ConfigBase)

expected_class_name: str = 'MultilayerPerceptron'
short_name: str = 'MLP'

aiqclib.train.models.random_forest module

This module provides a Random Forest model wrapper, inheriting from aiqclib.common.base.scikit_learn_model_base.SklearnModelBase.

It facilitates training, prediction, and evaluation of a Random Forest classifier using Polars DataFrames, converting them to Pandas for compatibility with the sklearn library.

class aiqclib.train.models.random_forest.RandomForest(config)[source]

Bases: SklearnModelBase

A Random Forest model wrapper class for training and testing.

Inherits from SklearnModelBase to reuse common Scikit-Learn API logic.

Features include:

  • Automatic application of model_params from the YAML config, if defined; otherwise, uses default hyperparameters.

  • Uses sklearn.ensemble.RandomForestClassifier.

Note

This class sets expected_class_name to "RandomForest".

Parameters:

config (ConfigBase)

expected_class_name: str = 'RandomForest'
short_name: str = 'RF'

aiqclib.train.models.support_vector_machine module

This module provides a Support Vector Machine (SVM) model wrapper, inheriting from aiqclib.common.base.scikit_learn_model_base.SklearnModelBase.

It facilitates training, prediction, and evaluation of an SVM classifier using Polars DataFrames, converting them to Pandas for compatibility with the sklearn library.

class aiqclib.train.models.support_vector_machine.SupportVectorMachine(config)[source]

Bases: SklearnModelBase

A Support Vector Machine (SVM) model wrapper class for training and testing.

Inherits from aiqclib.common.base.scikit_learn_model_base.SklearnModelBase to reuse common Scikit-Learn API logic.

Features include:

  • Automatic application of model_params from the YAML config, if defined; otherwise, uses default hyperparameters.

  • Uses sklearn.svm.SVC.

  • Enforces probability=True by default to support the generation of model-scores tables and ROC/PR curves used in the parent class.

  • Uses a linear kernel by default.

Note

Standard SVM implementations (especially with a linear kernel) typically do not support the n_jobs parameter directly, as parallelization is often handled by underlying BLAS libraries.

Parameters:

config (ConfigBase)

expected_class_name: str = 'SupportVectorMachine'
short_name: str = 'SVM'

aiqclib.train.models.xgboost module

This module provides an XGBoost model wrapper, inheriting from aiqclib.common.base.scikit_learn_model_base.SklearnModelBase.

It facilitates training, prediction, and evaluation of an XGBoost classifier using Polars DataFrames, converting them to Pandas for compatibility with the xgboost library.

class aiqclib.train.models.xgboost.XGBoost(config)[source]

Bases: SklearnModelBase

An XGBoost model wrapper class for training and testing.

Inherits from aiqclib.common.base.scikit_learn_model_base.SklearnModelBase to reuse common Scikit-Learn API logic.

Features include:

  • Automatic application of model_params from the YAML config, if defined; otherwise, uses default hyperparameters.

  • Uses xgboost.XGBClassifier.

Note

This class sets expected_class_name to "XGBoost" and short_name to "XGB".

Parameters:

config (ConfigBase)

expected_class_name: str = 'XGBoost'
short_name: str = 'XGB'