Пример #1
0
            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))
            time_spent = time.time() - start 
            vprint( verbose,  "[+] End cycle, remaining time %5.2f sec" % (time_budget-time_spent))
            cycle += 1
            time_spent_last = time.time() - begin
            time_budget = time_budget - time_spent_last # Remove time spent so far