Example #1
0
        time_stock = 10
        cycle = 0
        print("{:~^{n}}".format(basename.capitalize(), n=50))
        while cycle <= 1: # max_cycle:
            begin = time.time()
            vprint( verbose,  "=========== " + basename.capitalize() +" Training cycle " + str(cycle) +" ================")
            n_estimators = 10
            if cycle:
                n_estimators = int((time_budget / time_spent_last - 1) * n_estimators - time_stock)
                # n_estimators = int(((time_budget / time_spent_last) - 1) * 5) # * 5 == aim to use 5/10 of the time budget
                if n_estimators <= 0:
                    break
            print("{} estimators".format(n_estimators))
            K = D.info['target_num']
            task = D.info['task']
            autoML = OurAutoML(D.info).fit(D.data['X_train'], D.data['Y_train'], cv=2, n_estimators=n_estimators)

            vprint( verbose,  "[+] Fitting success, time spent so far %5.2f sec" % (time.time() - start))

            # Make predictions
            Y_valid = autoML.predict(D.data['X_valid'])
            Y_test = autoML.predict(D.data['X_test'])

            print("score: {}   ({} s)".format(autoML.scores.mean(), "%5.2f"%(time.time() - start)))
            vprint( verbose,  "[+] Prediction success, time spent so far %5.2f sec" % (time.time() - start))
            # Write results
            filename_valid = basename + '_valid_' + str(cycle).zfill(3) + '.predict'
            data_io.write(os.path.join(output_dir,filename_valid), Y_valid)
            filename_test = basename + '_test_' + str(cycle).zfill(3) + '.predict'
            data_io.write(os.path.join(output_dir,filename_test), Y_test)
            vprint( verbose,  "[+] Results saved, time spent so far %5.2f sec" % (time.time() - start))
Example #2
0
        # The model can also select its hyper-parameters based on other elements of info.  
        # vprint( verbose,  "======== Creating model ==========")
        # M = MyAutoML(D.info, verbose, debug_mode)
        # print M
        
        # ========= Iterating over learning cycles and keeping track of time
        time_spent = time.time() - start

        time_budget = time_budget - time_spent # Remove time spent so far
        start = time.time()              # Reset the counter
        time_spent = 0                   # Initialize time spent learning
        time_spent_last = 0                   # Initialize time spent learning
        time_stock = 5
        cycle = 0
        print("{:~^{n}}".format(basename.capitalize(), n=50))
        autoML = OurAutoML(D.info)
        X_train, Y_train = D.data['X_train'], D.data['Y_train']
        n_estimators = 500
        autoML.preprocess_bin_cl(X_train, Y_train, n_estimators=int(n_estimators/2))
        cycle=1
        while cycle <= 1: # max_cycle:
            begin = time.time()
            vprint( verbose,  "=========== " + basename.capitalize() +" Training cycle " + str(cycle) +" ================")
            print("{} estimators".format(n_estimators))
            prev_n_estimators = n_estimators

            if _MODE == "TEST_SCORE":
                autoML.fit_and_count_av_score(X_train, Y_train,
                                              n_estimators=n_estimators,
                                              test_size=0.4)
            else: