Random Forests

Random Forest model implementations.

class openadmet.models.architecture.rf.RFClassifierModel(*, n_estimators: int = 100, criterion: str = 'gini', max_depth: int | None = None, min_samples_split: int = 2, min_samples_leaf: int = 1, min_weight_fraction_leaf: float = 0.0, max_features: float | str = 'sqrt', max_leaf_nodes: int | None = None, min_impurity_decrease: float = 0.0, bootstrap: bool = True, oob_score: bool = False, n_jobs: int | None = None, random_state: int | None = None, verbose: int = 0, warm_start: bool = False, class_weight: dict | None = None, ccp_alpha: float = 0.0, max_samples: float | None = None, monotonic_cst: float | None = None)[source]

Bases: RFModelBase

RF classifier model.

bootstrap: bool
ccp_alpha: float
class_weight: dict | None
criterion: str
max_depth: int | None
max_features: float | str
max_leaf_nodes: int | None
max_samples: float | None
min_impurity_decrease: float
min_samples_leaf: int
min_samples_split: int
min_weight_fraction_leaf: float
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

monotonic_cst: float | None
n_estimators: int
n_jobs: int | None
oob_score: bool
predict_proba(X: ndarray) ndarray[source]

Predict using the model, returning probabilities for each class.

Parameters:

X (np.ndarray) – Data to predict on

Returns:

Probabilities for each class from the model

Return type:

np.ndarray

random_state: int | None
type: ClassVar[str] = 'RFClassifierModel'
verbose: int
warm_start: bool
class openadmet.models.architecture.rf.RFModelBase[source]

Bases: PickleableModelBase

Base class for Sklearn Random Forest models.

build()[source]

Prepare the model.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

predict(X: ndarray, **kwargs) ndarray[source]

Predict using the model.

Parameters:
  • X (np.ndarray) – Data to predict on

  • **kwargs – Additional keyword arguments for the predict method.

Returns:

Predictions from the model

Return type:

np.ndarray

train(X: ndarray, y: ndarray)[source]

Train the model.

Parameters:
  • X (np.ndarray) – Training data features

  • y (np.ndarray) – Training data labels

type: ClassVar[str]
class openadmet.models.architecture.rf.RFRegressorModel(*, n_estimators: int = 100, criterion: str = 'squared_error', max_depth: int | None = None, min_samples_split: int = 2, min_samples_leaf: int = 1, min_weight_fraction_leaf: float = 0.0, max_features: float = 1.0, max_leaf_nodes: int | None = None, min_impurity_decrease: float = 0.0, bootstrap: bool = True, oob_score: bool = False, n_jobs: int | None = None, random_state: int | None = None, verbose: int = 0, warm_start: bool = False, ccp_alpha: float = 0.0, max_samples: float | None = None, monotonic_cst: float | None = None)[source]

Bases: RFModelBase

Random Forest regression model.

bootstrap: bool
ccp_alpha: float
criterion: str
max_depth: int | None
max_features: float
max_leaf_nodes: int | None
max_samples: float | None
min_impurity_decrease: float
min_samples_leaf: int
min_samples_split: int
min_weight_fraction_leaf: float
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

monotonic_cst: float | None
n_estimators: int
n_jobs: int | None
oob_score: bool
random_state: int | None
type: ClassVar[str] = 'RFRegressorModel'
verbose: int
warm_start: bool