Example #1
0
    def _get_initial_regret(
            self,
            context: 'Context',
            function: AbstractFunction,
    ) -> NoReturn:
        """ get the regret only from the starting samples

        :param context: context to analyze
        :param function: target function
        :return:
        """
        y_opt = function.evaluate_scaled(function.get_maxima_x())[0]
        self.data_dict[COLUMNS.REGRET].append(self._get_regret_of_samples(context, 0, y_opt))
Example #2
0
    def _get_regret(self, context: 'Context', step: int, data: pd.DataFrame, function: AbstractFunction) -> NoReturn:
        """calls the functions to get the regret of the samples and of the proposed samples
        and save it to the data dict

        :param context: context to analyze
        :param step: step to analyze
        :param data: dataframe
        :param function: target function
        :return:
        """
        y_opt = function.evaluate_scaled(function.get_maxima_x())[0]
        self.data_dict[COLUMNS.REGRET].append(
            np.min([self._get_regret_of_new_arg_max(context, step, y_opt, data, function), self._get_regret_of_samples(context, step, y_opt)]))
Example #3
0
    def _get_initial_regret_last(
            self,
            context: 'Context',
            function: AbstractFunction,
            data: pd.DataFrame,
            tot_steps: int
    ) -> NoReturn:
        """get the regret only from the starting samples for last step

        :param context: context to analyze
        :param function: target function
        :param data: dataframe
        :param tot_steps: total number of Bo-steps assigned to the BO run
        :return:
        """
        y_opt = function.evaluate_scaled(function.get_maxima_x())[0]
        self.data_dict[COLUMNS.END_REGRET].append(self._get_regret_of_samples(context, tot_steps, y_opt))
Example #4
0
    def _get_regret_last(
            self,
            context: 'Context',
            step: int,
            data: pd.DataFrame,
            function: AbstractFunction,
            tot_steps: int
    ) -> NoReturn:
        """get the regret after the last step and store it in the data dict

        :param context: context to analyze
        :param step: step to analyze
        :param data: dataframe
        :param function: target function
        :param tot_steps: total number of Bo-steps assigned to the BO run
        :return:
        """
        y_opt = function.evaluate_scaled(function.get_maxima_x())[0]
        self.data_dict[COLUMNS.END_REGRET].append(
            np.min([self._get_regret_of_new_arg_max(context, step, y_opt, data, function), self._get_regret_of_samples(context, tot_steps, y_opt)]))