<jupyter_start><jupyter_text>Creating new surrogate models for GPyOpt Written by <NAME> and <NAME>. You can create and use your own surrogate models functions in GPyOpt. To do it just complete the following template.<jupyter_code># Copyright (c) 2016, the GPyOpt Authors
# Licensed under the BSD 3-clause license (see LICENSE.txt)

from GPyOpt.models import BOModel
import numpy as np

class NewModel(BOModel):
   
    """
    General template to create a new GPyOPt surrogate model

    :param normalize Y: wheter the outputs are normalized (default, false)

    """

    # SET THIS LINE TO True of False DEPENDING IN THE ANALYTICAL GRADIENTS OF THE PREDICTIONS ARE AVAILABLE OR NOT
    analytical_gradient_prediction = False

    def __init__(self, normalize_Y=True, **kwargs ):

        # ---
        # ADD TO self... THE REST OF THE PARAMETERS OF YOUR MODEL
        # ---
        
        self.normalize_Y = normalize_Y
        self.model = None

    def _create_model(self, X, Y):
        """
        Creates the model given some input data X and Y.
        """
        self.X = X
        self.Y = Y
        
        # ---
        # ADD TO self.model THE MODEL CREATED USING X AND Y.
        # ---
        
        
    def updateModel(self, X_all, Y_all, X_new, Y_new):
        """
        Updates the model with new observations.
        """
        self.X = X_all
        self.Y = Y_all
        
        if self.normalize_Y:
            Y_all = (Y_all - Y_all.mean())/(Y_all.std())
        
        if self.model is None: 
            self._create_model(X_all, Y_all)
        else:
            pass
            # ---
            # AUGMENT THE MODEL HERE AND REUPDATE THE HIPER-PARAMETERS
            # ---
                 
    def predict(self, X):
        """
        Preditions with the model. Returns posterior means m and standard deviations s at X. 
        """

        # ---
        # IMPLEMENT THE MODEL PREDICTIONS HERE (outputs are numpy arrays with a point per row)
        # ---
        
        return m, s
    
    def get_fmin(self):
        return self.model.predict(self.X).min()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08384074941451991, 'fraction_numerical': 0.00234192037470726, 'mean_word_length': 1.7994757536041939, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '132748', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 660, 'n_tokens_neox': 626, 'n_words': 217, 'path': 'manual/GPyOpt_creating_new_models.ipynb', 'repo_name': 'pavel-rev/GPyOpt', 'size': '2152'}