Module settings

Source
Expand description

§Settings customization

This module contains capabilities for the detailed customization of algorithm settings.

§Complete regression customization

use automl::settings::{
    Algorithm, DecisionTreeRegressorParameters, Distance, ElasticNetParameters,
    KNNAlgorithmName, KNNRegressorParameters, KNNWeightFunction, Kernel, LassoParameters,
    LinearRegressionParameters, LinearRegressionSolverName, Metric,
    RandomForestRegressorParameters, RidgeRegressionParameters, RidgeRegressionSolverName,
    SVRParameters,
 };

 let settings = automl::Settings::default_regression()
    .with_number_of_folds(3)
    .shuffle_data(true)
    .verbose(true)
    .skip(Algorithm::RandomForestRegressor)
    .sorted_by(Metric::RSquared)
    .with_linear_settings(
        LinearRegressionParameters::default().with_solver(LinearRegressionSolverName::QR),
    )
    .with_lasso_settings(
        LassoParameters::default()
            .with_alpha(10.0)
            .with_tol(1e-10)
            .with_normalize(true)
            .with_max_iter(10_000),
    )
    .with_ridge_settings(
        RidgeRegressionParameters::default()
            .with_alpha(10.0)
            .with_normalize(true)
            .with_solver(RidgeRegressionSolverName::Cholesky),
    )
    .with_elastic_net_settings(
        ElasticNetParameters::default()
            .with_tol(1e-10)
            .with_normalize(true)
            .with_alpha(1.0)
            .with_max_iter(10_000)
            .with_l1_ratio(0.5),
    )
    .with_knn_regressor_settings(
        KNNRegressorParameters::default()
            .with_algorithm(KNNAlgorithmName::CoverTree)
            .with_k(3)
            .with_distance(Distance::Euclidean)
            .with_weight(KNNWeightFunction::Uniform),
    )
    .with_svr_settings(
        SVRParameters::default()
            .with_eps(1e-10)
            .with_tol(1e-10)
            .with_c(1.0)
            .with_kernel(Kernel::Linear),
    )
    .with_random_forest_regressor_settings(
        RandomForestRegressorParameters::default()
            .with_m(100)
            .with_max_depth(5)
            .with_min_samples_leaf(20)
            .with_n_trees(100)
            .with_min_samples_split(20),
    )
    .with_decision_tree_regressor_settings(
        DecisionTreeRegressorParameters::default()
            .with_min_samples_split(20)
            .with_max_depth(5)
            .with_min_samples_leaf(20),
    );

§Complete classification customization

use automl::settings::{
    Algorithm, CategoricalNBParameters, DecisionTreeClassifierParameters, Distance,
    GaussianNBParameters, KNNAlgorithmName, KNNClassifierParameters, KNNWeightFunction, Kernel,
    LogisticRegressionParameters, LogisticRegressionSolverName, Metric,
    RandomForestClassifierParameters, SVCParameters,
};

let settings = automl::Settings::default_classification()
    .with_number_of_folds(3)
    .shuffle_data(true)
    .verbose(true)
    .skip(Algorithm::RandomForestClassifier)
    .sorted_by(Metric::Accuracy)
    .with_random_forest_classifier_settings(
        RandomForestClassifierParameters::default()
            .with_m(100)
            .with_max_depth(5)
            .with_min_samples_leaf(20)
            .with_n_trees(100)
            .with_min_samples_split(20),
    )
    .with_logistic_settings(
        LogisticRegressionParameters::default()
            .with_alpha(1.0)
            .with_solver(LogisticRegressionSolverName::LBFGS),
    )
    .with_svc_settings(
        SVCParameters::default()
            .with_epoch(10)
            .with_tol(1e-10)
            .with_c(1.0)
            .with_kernel(Kernel::Linear),
    )
    .with_decision_tree_classifier_settings(
        DecisionTreeClassifierParameters::default()
            .with_min_samples_split(20)
            .with_max_depth(5)
            .with_min_samples_leaf(20),
    )
    .with_knn_classifier_settings(
        KNNClassifierParameters::default()
            .with_algorithm(KNNAlgorithmName::CoverTree)
            .with_k(3)
            .with_distance(Distance::Euclidean)
            .with_weight(KNNWeightFunction::Uniform),
    )
    .with_gaussian_nb_settings(GaussianNBParameters::default().with_priors(vec![1.0, 1.0]))
    .with_categorical_nb_settings(CategoricalNBParameters::default().with_alpha(1.0));

Re-exports§

pub use settings_struct::Settings;

Structs§

CategoricalNBParameters
Parameters for categorical naive bayes (re-export from Smartcore) CategoricalNB parameters. Use Default::default() for default values.
DecisionTreeClassifierParameters
Parameters for decision tree classification (re-export from Smartcore) Parameters of Decision Tree
DecisionTreeRegressorParameters
Parameters for decision tree regression (re-export from Smartcore) Parameters of Regression Tree
ElasticNetParameters
Parameters for elastic net regression (re-export from Smartcore) Elastic net parameters
GaussianNBParameters
Parameters for Gaussian naive bayes (re-export from Smartcore) GaussianNB parameters. Use Default::default() for default values.
KNNClassifierParameters
Parameters for k-nearest neighbors (KNN) classification
KNNRegressorParameters
Parameters for k-nearest neighbor (KNN) regression
LassoParameters
Parameters for LASSO regression (re-export from Smartcore) Lasso regression parameters
LinearRegressionParameters
Parameters for linear regression (re-export from Smartcore) Linear Regression parameters
LogisticRegressionParameters
Parameters for logistic regression (re-export from Smartcore) Logistic Regression parameters
RandomForestClassifierParameters
Parameters for random forest classification (re-export from Smartcore) Parameters of the Random Forest algorithm. Some parameters here are passed directly into base estimator.
RandomForestRegressorParameters
Parameters for random forest regression (re-export from Smartcore) Parameters of the Random Forest Regressor Some parameters here are passed directly into base estimator.
RidgeRegressionParameters
Parameters for ridge regression (re-export from Smartcore) Ridge Regression parameters
SVCParameters
Parameters for support vector classification
SVRParameters
Parameters for support vector regression

Enums§

Algorithm
Algorithm options
Distance
Distance metrics
FinalModel
Final model approach
KNNAlgorithmName
Search algorithms for k-nearest neighbor (KNN) regression (re-export from Smartcore) Both, KNN classifier and regressor benefits from underlying search algorithms that helps to speed up queries. KNNAlgorithmName maintains a list of supported search algorithms, see KNN algorithms
KNNWeightFunction
Weighting functions for k-nearest neighbor (KNN) regression (re-export from Smartcore) Weight function that is used to determine estimated value.
Kernel
Kernel options for use with support vector machines
LinearRegressionSolverName
Solvers for linear regression (re-export from Smartcore) Approach to use for estimation of regression coefficients. QR is more efficient but SVD is more stable.
LogisticRegressionSolverName
Parameters for logistic regression (re-export from Smartcore) Solver options for Logistic regression. Right now only LBFGS solver is supported.
Metric
Metrics for evaluating algorithms
PreProcessing
Options for pre-processing the data
RidgeRegressionSolverName
Solvers for ridge regression (re-export from Smartcore) Approach to use for estimation of regression coefficients. Cholesky is more efficient but SVD is more stable.