app/package/model_pkg/conversion_rate_model/v3/model.py
def grid_search(self,
                    X: pd.DataFrame,
                    y: pd.Series,
                    config: dict) -> NamedTuple('model_eval',
                                                mse=float):
        """Function for hyper-parameters tuning to search best configuration of the estimator
           Results in the best tuned estimator object being assigned to the Model.model attr
           
           Args:
                X: pd.DataFrame with features values
                y: target column values
                config: dictionary with a grid of hyperparameters

           Returns: 
                namedtuple with metrics values: 
                    "mse": float
        """
        if self.model is None:
            self._model_definition(config=None)
        
        grid = GridSearchCV(estimator=self.model,
                            param_grid=config,
                            scoring='neg_mean_squared_error',
                            cv=2,
                            n_jobs=-1,
                            verbose=2)
        # find best tuned estimator
        grid.fit(X, y)
        self.model = grid.best_estimator_
        
        # evalute on train set
        y_pred = self.predict(X)
        model_eval = self.score(y_true=y, y_pred=y_pred)
        return model_eval
Function for hyper-parameters tuning to search best configuration of the estimator
           Results in the best tuned estimator object being assigned to the Model.model attr
           
           Args:
                X: pd.DataFrame with features values
                y: target column values
                config: dictionary with a grid of hyperparameters

           Returns: 
                namedtuple with metrics values: 
                    "mse": float
        
Function for hyper-parameters tuning to search best configuration of the estimator
Results in the best tuned estimator object being assigned to the Model.model attr
Function for hyper - parameters tuning to search best configuration of the estimator Results in the best tuned estimator object being assigned to the Model . model attr
def grid_search(self,
                    X: pd.DataFrame,
                    y: pd.Series,
                    config: dict) -> NamedTuple('model_eval',
                                                mse=float):
        if self.model is None:
            self._model_definition(config=None)
        grid = GridSearchCV(estimator=self.model,
                            param_grid=config,
                            scoring='neg_mean_squared_error',
                            cv=2,
                            n_jobs=-1,
                            verbose=2)
        grid.fit(X, y)
        self.model = grid.best_estimator_
        y_pred = self.predict(X)
        model_eval = self.score(y_true=y, y_pred=y_pred)
        return model_eval
def grid_search ( self , X : pd . DataFrame , y : pd . Series , config : dict ) -> NamedTuple ( 'model_eval' , mse = float ) : if self . model is None : self . _model_definition ( config = None ) grid = GridSearchCV ( estimator = self . model , param_grid = config , scoring = 'neg_mean_squared_error' , cv = 2 , n_jobs = - 1 , verbose = 2 ) grid . fit ( X , y ) self . model = grid . best_estimator_ y_pred = self . predict ( X ) model_eval = self . score ( y_true = y , y_pred = y_pred ) return model_eval
Function for hyper-parameters tuning to search best configuration of the estimator
Results in the best tuned estimator object being assigned to the Model.model attr
Function for hyper - parameters tuning to search best configuration of the estimator Results in the best tuned estimator object being assigned to the Model . model attr
"""Function for hyper-parameters tuning to search best configuration of the estimator
           Results in the best tuned estimator object being assigned to the Model.model attr
           
           Args:
                X: pd.DataFrame with features values
                y: target column values
                config: dictionary with a grid of hyperparameters

           Returns: 
                namedtuple with metrics values: 
                    "mse": float
        """ # find best tuned estimator # evalute on train set
namedtuple with metrics values:
"mse": float
namedtuple with metrics values : " mse " : float
self
X
pd.DataFrame
pd.DataFrame with features values
pd . DataFrame with features values
y
pd.Series
target column values
target column values
config
dict
dictionary with a grid of hyperparameters
dictionary with a grid of hyperparameters