coco_pipe.fm.cbramod.pipeline ============================= .. py:module:: coco_pipe.fm.cbramod.pipeline .. autoapi-nested-parse:: Pipeline wrapper for running regression with the CBRAMod foundation model. This mirrors the public surface of the classical regression pipeline but swaps the estimator for a foundation-model-backed regressor. The embedder is expected to turn raw inputs into embeddings; a light downstream regressor is trained on top of those embeddings. Classes ------- .. autoapisummary:: coco_pipe.fm.cbramod.pipeline.FoundationRegressor coco_pipe.fm.cbramod.pipeline.CBRAModRegressionPipeline Module Contents --------------- .. py:class:: FoundationRegressor(embed_fn: Callable[[Any], numpy.ndarray], base_regressor: Optional[sklearn.base.BaseEstimator] = None, multioutput: bool = False) Bases: :py:obj:`sklearn.base.BaseEstimator`, :py:obj:`sklearn.base.RegressorMixin` Thin sklearn-compatible wrapper around a foundation model embedder. :param embed_fn: Callable that maps ``X`` to a 2D numpy array of embeddings. Either a ``__call__`` or ``transform`` method will be used. :type embed_fn: callable :param base_regressor: Downstream regressor trained on the embeddings. Defaults to ``Ridge``. :type base_regressor: BaseEstimator, optional :param multioutput: If True, wraps the base regressor in ``MultiOutputRegressor`` for multi-target regression. :type multioutput: bool, optional .. py:attribute:: embed_fn .. py:attribute:: base_regressor .. py:attribute:: multioutput :value: False .. py:method:: _embed(X: Any) -> numpy.ndarray .. py:method:: fit(X: Any, y: Any) .. py:method:: predict(X: Any) -> numpy.ndarray .. py:class:: CBRAModRegressionPipeline(X: Union[pandas.DataFrame, numpy.ndarray], y: Union[pandas.Series, numpy.ndarray], embed_fn: Callable[[Any], numpy.ndarray], metrics: Union[str, Sequence[str], None] = None, base_regressor: Optional[sklearn.base.BaseEstimator] = None, hp_search_params: Optional[Dict[str, Sequence[Any]]] = None, use_scaler: bool = False, random_state: int = 42, n_jobs: int = -1, cv_kwargs: Optional[Dict[str, Any]] = None, groups: Optional[Union[pandas.Series, numpy.ndarray]] = None, verbose: bool = False) Bases: :py:obj:`coco_pipe.ml.base.BasePipeline` Regression pipeline that routes features through the CBRAMod foundation model before fitting a lightweight regressor. The interface mirrors ``RegressionPipeline`` for analysis_type dispatch but exposes a required ``embed_fn`` to obtain embeddings from the foundation model. .. py:attribute:: embed_fn .. py:attribute:: verbose :value: False .. py:attribute:: model_name :value: 'CBRAMod' .. py:method:: run(analysis_type: str = 'baseline', n_features: Optional[int] = None, direction: str = 'forward', search_type: str = 'grid', n_iter: int = 50, scoring: Optional[str] = None) -> Dict[str, Any]