Beispiel #1
0
            if cycle==1 and max_cycle==1:
                # Directly use up all time left in one iteration
                n_estimators = M.model.n_estimators
                new_n_estimators = int((np.floor(time_left_over / time_spent) - 1 ) * n_estimators)
                if new_n_estimators<=n_estimators: break
                M.model.n_estimators = new_n_estimators
            else:
                # Make a learning curve by exponentially increasing the number of estimators
                M.model.n_estimators = int(np.exp2(cycle))
                
            M.model.n_estimators = min(max_estimators, M.model.n_estimators)
            vprint( verbose,  "[+] Number of estimators: %d" % (M.model.n_estimators))  
            last_n_estimators =  M.model.n_estimators 
            # Fit base estimators
            # -------------------
            M.fit(D.data['X_train'], D.data['Y_train']) 

            vprint( verbose,  "[+] Fitting success, time spent so far %5.2f sec" % (time.time() - start))
            vprint( verbose,  "[+] Size of trained model  %5.2f bytes" % data_io.total_size(M))
            # Make predictions
            # -----------------
            Y_valid = M.predict(D.data['X_valid'])
            Y_test = M.predict(D.data['X_test'])                         
            vprint( verbose,  "[+] Prediction success, time spent so far %5.2f sec" % (time.time() - start))
            # Write results
            # -------------
            if overwrite_output:
                filename_valid = basename + '_valid.predict'                
                filename_test = basename + '_test.predict'
            else:
                filename_valid = basename + '_valid_' + str(cycle).zfill(3) + '.predict'                
Beispiel #2
0
        arr_range = np.array([[elem_hyps[3], elem_hyps[4]]
                              for elem_hyps in space_hyps])
        model_bo = bayesobo.BO(arr_range, str_acq='ucb')
        cur_hyps = [elem_hyps[2] for elem_hyps in space_hyps]
        list_hyps_all = []
        list_measures_all = []

        while time_spent <= time_budget - (
                2 * time_one_loop) - TIME_RESIDUAL and is_bo and True:
            vprint(
                verbose, "=========== " + basename.capitalize() +
                " Training cycle " + str(cycle) + " ================")
            M = MyAutoML(D.info, verbose=False, debug_mode=debug_mode)

            M.fit(X_train_train, Y_train_train)

            vprint(
                verbose, "[+] Fitting success, time spent so far %5.2f sec" %
                (time.time() - start))
            # Make predictions
            # -----------------
            pred_train_valid = M.predict(X_train_valid)
            if 'classification' in D.info['task']:
                performance = sklearn.metrics.roc_auc_score(
                    Y_train_valid, pred_train_valid)
                performance = 2 * performance - 1
                vprint(verbose,
                       "[+] AUC for X_train_valid, %5.4f" % (performance))
            else:
                preformance = 0.0