RandomizedSearchClassifier
Module: strata.model_selection • Kind: struct • Traits: Classifier, Copyable, Movable
Source: strata/model_selection/randomized_search.mojo
struct RandomizedSearchClassifier[ModelType: Classifier, feat_dtype: DType = DType.float64, target_dtype: DType = DType.int32](Classifier, Copyable, Movable)from strata.model_selection import RandomizedSearchClassifierRandomized hyperparameter search for classification models.
Evaluates a random subset of the supplied candidate configurations rather than the full grid, trading exhaustive coverage for a fixed search budget.
Constructors
Section titled “Constructors”def __init__( out self, var candidates: List[Self.ModelType], n_iter: Int = 10, cv: Int = 5, scoring: String = "accuracy", refit: Bool = True, random_state: Int = 42,)Initializes the randomized search classifier cross-validator.
| Argument | Type | Description |
|---|---|---|
candidates |
— | Pool of candidate model configurations to sample from. |
n_iter |
Int |
Number of candidates to evaluate, clamped to the pool size. |
cv |
Int |
Number of stratified cross-validation folds. |
scoring |
String |
Scoring metric name. |
refit |
Bool |
Whether to refit the best model on the complete dataset. |
random_state |
Int |
Seed controlling which candidates are sampled. |
Methods Overview
Section titled “Methods Overview”| Method | Description |
|---|---|
RandomizedSearchClassifier.fit() |
Cross-validates a random subset of candidates and fits the best one. |
RandomizedSearchClassifier.predict() |
Predicts class labels using the best discovered model configuration. |
RandomizedSearchClassifier.predict_proba() |
Predicts class probabilities using the best model configuration. |
Method Details
Section titled “Method Details”RandomizedSearchClassifier.fit()
Section titled “RandomizedSearchClassifier.fit()”def fit[in_feat_dtype: DType, in_target_dtype: DType]( mut self, X: Matrix[in_feat_dtype], y: List[Scalar[in_target_dtype]],)
def fit[feat_dtype: DType, target_dtype: DType]( mut self, dataset: Dataset[feat_dtype, target_dtype],)Overload Note: This method accepts either standard
(X, y)inputs or a unifieddataset: Datasetcontainer.
Cross-validates a random subset of candidates and fits the best one.
| Parameter | Type | Description |
|---|---|---|
X |
Matrix[in_feat_dtype] |
Feature training matrix. |
y |
List[Scalar[in_target_dtype]] |
Discrete class labels. |
dataset |
Dataset[feat_dtype, target_dtype] |
Dataset container holding feature matrix and targets. (Can be provided alternatively in place of (X, y)) |
RandomizedSearchClassifier.predict()
Section titled “RandomizedSearchClassifier.predict()”def predict[in_feat_dtype: DType]( self, X: Matrix[in_feat_dtype],) -> List[Int]
def predict[feat_dtype: DType, target_dtype: DType]( self, dataset: Dataset[feat_dtype, target_dtype],) -> List[Int]Overload Note: This method accepts either standard
(X, y)inputs or a unifieddataset: Datasetcontainer.
Predicts class labels using the best discovered model configuration.
| Parameter | Type | Description |
|---|---|---|
X |
Matrix[in_feat_dtype] |
Feature matrix. |
dataset |
Dataset[feat_dtype, target_dtype] |
Dataset container holding feature matrix and targets. (Can be provided alternatively in place of (X, y)) |
Returns: List[Int]
RandomizedSearchClassifier.predict_proba()
Section titled “RandomizedSearchClassifier.predict_proba()”def predict_proba[in_feat_dtype: DType]( self, X: Matrix[in_feat_dtype],) -> Matrix[in_feat_dtype]
def predict_proba[feat_dtype: DType, target_dtype: DType]( self, dataset: Dataset[feat_dtype, target_dtype],) -> Matrix[feat_dtype]Overload Note: This method accepts either standard
(X, y)inputs or a unifieddataset: Datasetcontainer.
Predicts class probabilities using the best model configuration.
| Parameter | Type | Description |
|---|---|---|
X |
Matrix[in_feat_dtype] |
Feature matrix. |
dataset |
Dataset[feat_dtype, target_dtype] |
Dataset container holding feature matrix and targets. (Can be provided alternatively in place of (X, y)) |
Returns: Matrix[in_feat_dtype]