def delete_experiments(self): conn = Connection(client_token=self.client_token, user_token=self.user_token) for e in conn.client_experiments(self.client_id).experiments: if e.name.startswith('Example Classifier'): conn.experiment_delete(e.id) else: raise Exception( "Refusing to delete experiment that was not created by this script." " Please visit https://sigopt.com/experiment/{0}/properties to delete manually." .format(e.id) )
def create_experiment(self): """Create a SigOpt experiment for optimizing the classifier hyperparameters.""" conn = Connection(client_token=self.client_token, user_token=self.user_token) params = CLASSIFIER_TYPE_TO_PARAMS[self.classifier_type] try: response = conn.experiment_create(self.client_id, { "name": "Example Classifier {num}".format(num=int(time.time())), "parameters": params, }) return response.experiment except ApiException as e: if e.status_code == 403 and '*****@*****.**' in str(e): existing_experiments = conn.client_experiments(self.client_id).experiments if existing_experiments: raise Exception( "You have existing experiments on sigopt.com: {0}." " You can only have one experiment under the free plan." " Run again with --delete-existing to remove your existing experiments." .format(['https://sigopt.com/experiment/{0}'.format(e.id) for e in existing_experiments]) ) raise