• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python state.load函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中state.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了load函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: update

    def update(self, events):
        '''
        Updates the screen when an event happens 

        @param - list of game events
        '''
        for event in events:
            if not hasattr(event, 'key'):
                continue
            if event.type == KEYDOWN:
                if event.key == K_RETURN:
                    if self.currLine == GameMenuScreenLine.NewGame:
			gui = EnterSaveNameGUI()
			save_name = gui.saveName
			if len(save_name) <= 0:
				continue
			load(NEW_GAME_DIR)
			State.save_name = save_name
                        State.push_screen(gameScreen.GameScreen(CURRENT_GAME_DIR))
                    elif self.currLine == GameMenuScreenLine.LoadGame:
			State.push_screen(loadGameScreen.LoadGameScreen())
                    elif self.currLine == GameMenuScreenLine.Exit:
                        sys.exit(0)
                else:
                    super(GameMenuScreen, self).interact(event)
开发者ID:nhandler,项目名称:cs429,代码行数:25,代码来源:gameMenuScreen.py


示例2: test_load_save_state

 def test_load_save_state(self):
     filename = "test_logs/state.dat"
     my_id = tc.CLIENT_ID
     # TODO: change state
     state.save(my_id, [], filename)
     # TODO:check file
     state.load(filename)
开发者ID:pedromj,项目名称:pymdht,代码行数:7,代码来源:test_state.py


示例3: play

def play():
	if state.canload():
		state.load()
		scene.pop()
		scene.push(gamescene)
		scene.push(buildscene)
	else:
		state.reset()
		scene.pop()
		scene.push(gamescene)
		scene.push(cutscene)
开发者ID:cosmologicon,项目名称:unifac,代码行数:11,代码来源:menuscene.py


示例4: predict

def predict():
    saved = state.load('model')
    #saved = None
    if debug_mode:
        saved = None
    if saved == None:
        train, y, test, _ = data.get()
        ftrain, ftest, _ = fea_1.get()
        ftrain2, ftest2, _ = fea_2.get()
        train = pd.concat([train, ftrain, ftrain2], axis=1)
        test = pd.concat([test, ftest, ftest2], axis=1)
        print(train.shape, test.shape)

        z = pd.DataFrame()
        z['id'] = test.id
        z['y'] = 0

        v = pd.DataFrame()
        v['id'] = train.id
        v['y'] = y
        cv, _ = run(train, y, test, v, z)
        state.save('model', (v, z, cv, None))
    else:
        v, z, cv, _ = saved
    return v, z, cv, _
开发者ID:ivan-filonov,项目名称:mlbootcamp_5,代码行数:25,代码来源:l1_4_xgb_1.py


示例5: __init__

    def __init__(self, dht_addr, state_filename,
                 routing_m_mod, lookup_m_mod,
                 experimental_m_mod,
                 private_dht_name):
        #TODO: don't do this evil stuff!!!
        message.private_dht_name = private_dht_name

        if size_estimation:
            self._size_estimation_file = open('size_estimation.dat', 'w')
        
        
        self.state_filename = state_filename
        saved_id, saved_bootstrap_nodes = state.load(self.state_filename)
        if saved_id:
            self._my_id = saved_id
        else:
            self._my_id = identifier.RandomId()
        self._my_node = Node(dht_addr, self._my_id)
        self._tracker = tracker.Tracker()
        self._token_m = token_manager.TokenManager()

        self._querier = Querier()
        self._routing_m = routing_m_mod.RoutingManager(self._my_node, 
                                                       saved_bootstrap_nodes)
        self._lookup_m = lookup_m_mod.LookupManager(self._my_id)
        self._experimental_m = experimental_m_mod.ExperimentalManager(self._my_node.id) 
                  
        current_ts = time.time()
        self._next_save_state_ts = current_ts + SAVE_STATE_DELAY
        self._next_maintenance_ts = current_ts
        self._next_timeout_ts = current_ts
        self._next_main_loop_call_ts = current_ts
        self._pending_lookups = []
开发者ID:csasm,项目名称:pymdht,代码行数:33,代码来源:controller.py


示例6: __init__

    def __init__( self ):
        """
        Initialise a ScrambleSuitTransport object.
        """

        log.error("\n\n################################################\n"
                  "Do NOT rely on ScrambleSuit for strong security!\n"
                  "################################################\n")

        log.debug("Initialising %s." % const.TRANSPORT_NAME)

        super(ScrambleSuitTransport, self).__init__()

        # Load the server's persistent state from file.
        if self.weAreServer:
            self.srvState = state.load()

        # Initialise the protocol's state machine.
        log.debug("Switching to state ST_WAIT_FOR_AUTH.")
        self.protoState = const.ST_WAIT_FOR_AUTH

        # Buffer for outgoing data.
        self.sendBuf = ""

        # Buffer for inter-arrival time obfuscation.
        self.choppingBuf = fifobuf.Buffer()

        # AES instances to decrypt incoming and encrypt outgoing data.
        self.sendCrypter = mycrypto.PayloadCrypter()
        self.recvCrypter = mycrypto.PayloadCrypter()

        # Packet morpher to modify the protocol's packet length distribution.
        self.pktMorpher = packetmorpher.new(self.srvState.pktDist
                                            if self.weAreServer else None)

        # Inter-arrival time morpher to obfuscate inter arrival times.
        self.iatMorpher = self.srvState.iatDist if self.weAreServer else \
                          probdist.new(lambda: random.random() %
                                       const.MAX_PACKET_DELAY)

        # Used to extract protocol messages from encrypted data.
        self.protoMsg = message.MessageExtractor()

        # Used by the server-side: `True' if the ticket is already
        # decrypted but not yet authenticated.
        self.decryptedTicket = False

        # If we are in external mode we should already have a shared
        # secret set up because of validate_external_mode_cli().
        if self.weAreExternal:
            assert(self.uniformDHSecret)

        if self.weAreClient and not self.weAreExternal:
            # As a client in managed mode, we get the shared secret
            # from callback `handle_socks_args()' per-connection. Set
            # the shared secret to None for now.
            self.uniformDHSecret = None

        self.uniformdh = uniformdh.new(self.uniformDHSecret, self.weAreServer)
开发者ID:Ahiknsr,项目名称:obfsproxy,代码行数:59,代码来源:scramblesuit.py


示例7: main

def main():
	pygame.init()
	pygame.mixer.init()
	sound.setvolume(0)
	pygame.font.init()
	graphics.setmode()
	graphics.init()
	if settings.playback:
		state0, record = cPickle.load(open(data.filepath("record.pkl"), "rb"))
		state.loadobj(state0)
		scene.push(scenes.game if settings.skipmenu else scenes.menu)
	elif settings.restart:
		state.init()
		scene.push(scenes.game if settings.skipmenu else scenes.menu)
	else:
		scene.push(scenes.menu)
		if state.load():
			scene.push(scenes.game)
	clock = pygame.time.Clock()

	if settings.playback:
		for rstate, dt, events, kpress, mpos in record:
			clock.tick(settings.fps)
			s = scene.top()
			random.setstate(rstate)
			if settings.vidcap:
				vidcap._mpos = mpos
			s.think(dt, events, kpress, mpos)
			s.draw(mpos)
			pygame.display.flip()
		return

	if settings.getrecord:
		record = []
		state0 = cPickle.loads(cPickle.dumps(state.saveobj()))
	while scene.top():
		dt = min(0.001 * clock.tick(settings.fps), 0.5)
		if settings.fixfps:
			dt = 1.0 / settings.fps
		s = scene.top()
		while dt > 0:
			tdt = min(dt, 0.1)
			events = map(EventProxy, pygame.event.get())
			kpress = pygame.key.get_pressed()
			mpos = pygame.mouse.get_pos()
			if settings.getrecord:
				record.append((random.getstate(), tdt, events, kpress, mpos))

			s.think(tdt, events, kpress, mpos)
			dt -= tdt
		s.draw(mpos)
		pygame.display.flip()

	graphics.quit()
	
	if settings.getrecord:
		cPickle.dump([state0, record], open(data.filepath("record.pkl"), "wb"))
开发者ID:cosmologicon,项目名称:unifac,代码行数:57,代码来源:main.py


示例8: __enter__

 def __enter__(self):
     """ Resume or start the session. """
     if self.resume and state.load():
         state.basic_state.session.resume()
     else:
         state.basic_state.session = Session(self.show_greeting, self.prog)
     self.thread = threading.Thread(target=state.basic_state.session.run,
                             args=(self.cmd, self.run, self.quit, self.wait))
     self.thread.start()
开发者ID:gilsim12,项目名称:pcbasic,代码行数:9,代码来源:interpreter.py


示例9: update

	def update(self, events):
		'''
        Updates the screen when an event happens 

        @param - list of game events
        '''
		for event in events:
			if not hasattr(event, 'key'):
				continue
			if event.type == KEYDOWN:
				if event.key == K_RETURN:
					if self.currLine == LoadGameScreenLine.ReturnToMainMenu:
						State.pop_screen()
						continue
					save_name = self.lines[self.currLine]
					load(USER_SAVES_DIR + save_name)
					State.save_name = save_name
					State.pop_screen()
					State.push_screen(gameScreen.GameScreen(CURRENT_GAME_DIR))
				else:
					super(LoadGameScreen, self).interact(event)
开发者ID:nhandler,项目名称:cs429,代码行数:21,代码来源:loadGameScreen.py


示例10: setup

    def setup(cls, transportConfig):
        """
        Called once when obfsproxy starts.
        """

        log.error(
            "\n\n################################################\n"
            "Do NOT rely on ScrambleSuit for strong security!\n"
            "################################################\n"
        )

        util.setStateLocation(transportConfig.getStateLocation())

        cls.weAreClient = transportConfig.weAreClient
        cls.weAreServer = not cls.weAreClient
        cls.weAreExternal = transportConfig.weAreExternal

        # If we are server and in managed mode, we should get the
        # shared secret from the server transport options.
        if cls.weAreServer and not cls.weAreExternal:
            cfg = transportConfig.getServerTransportOptions()
            if cfg and "password" in cfg:
                try:
                    cls.uniformDHSecret = base64.b32decode(util.sanitiseBase32(cfg["password"]))
                except (TypeError, AttributeError) as error:
                    raise base.TransportSetupFailed("Password could not be base32 decoded (%s)" % error)

                cls.uniformDHSecret = cls.uniformDHSecret.strip()

        if cls.weAreServer:
            if not hasattr(cls, "uniformDHSecret"):
                log.debug("Using fallback password for descriptor file.")
                srv = state.load()
                cls.uniformDHSecret = srv.fallbackPassword

            if len(cls.uniformDHSecret) != const.SHARED_SECRET_LENGTH:
                raise base.TransportSetupFailed(
                    "Wrong password length (%d instead of %d)" % len(cls.uniformDHSecret), const.SHARED_SECRET_LENGTH
                )

            if not const.STATE_LOCATION:
                raise base.TransportSetupFailed(
                    "No state location set. If you are using external mode, "
                    "please set it using the --data-dir switch."
                )

            state.writeServerPassword(cls.uniformDHSecret)
开发者ID:catinred2,项目名称:obfsproxy,代码行数:47,代码来源:scramblesuit.py


示例11: predict

def predict():
    saved = state.load('model')
    #saved = None
    if saved == None:
        train, y, test, _ = data.get()
        z = pd.DataFrame()
        z['id'] = test.id
        z['y'] = 0

        v = pd.DataFrame()
        v['id'] = train.id
        v['y'] = y
        cv, _ = run(train, y, test, v, z)
        state.save('model', (v, z, cv, None))
    else:
        v, z, cv, _ = saved
    return v, z, cv, _
开发者ID:ivan-filonov,项目名称:mlbootcamp_5,代码行数:17,代码来源:l1_1_ho_xgb_1.py


示例12: predict

def predict():
    saved = state.load('model')
    if saved == None:
        import l1_1_ho_xgb_1
        import l1_1_ho_xgb_2
        import l1_3_ho_xgb_1
        import l1_3_ho_xgb_2
        import l1_3_ho_xgb_3

        #import l1_1_keras_1
        import l1_1_keras_2
        import l1_3_keras_1
        import l1_3_keras_2

        vs, zs, cvs = [], [], []
        for module in [l1_1_ho_xgb_1, l1_1_ho_xgb_2, l1_3_ho_xgb_1, l1_3_ho_xgb_2,
                       l1_1_keras_2, l1_3_keras_1, l1_3_ho_xgb_3, l1_3_keras_2 ]:
            v, z, cv, _ = module.predict()
            vs.append(v)
            zs.append(z)
            cvs.append(cv)

        z = pd.DataFrame()
        z['id'] = zs[-1].id
        z['y'] = 0

        v = pd.DataFrame()
        v['id'] = vs[-1].id
        v['y'] = vs[-1].y

        for s in vs + zs:
            s.drop(['id', 'y'], axis=1, inplace=True)

        train = pd.concat(vs, axis=1)
        test = pd.concat(zs, axis=1)
        y = v.y

        cv, _ = run(train, y, test, v, z)
        #state.save('model', (v, z, cv, None))
    else:
        v, z, cv, _ = saved
    return v, z, cv, _
开发者ID:ivan-filonov,项目名称:mlbootcamp_5,代码行数:42,代码来源:l2_3_ho_stack.py


示例13: get_public_server_options

    def get_public_server_options( cls, transportOptions ):
        """
        Return ScrambleSuit's BridgeDB parameters, i.e., the shared secret.

        As a fallback mechanism, we return an automatically generated password
        if the bridge operator did not use `ServerTransportOptions'.
        """

        log.debug("Tor's transport options: %s" % str(transportOptions))

        if not "password" in transportOptions:
            log.warning("No password found in transport options (use Tor's " \
                        "`ServerTransportOptions' to set your own password)." \
                        "  Using automatically generated password instead.")
            srv = state.load()
            transportOptions = {"password":
                                base64.b32encode(srv.fallbackPassword)}
            cls.uniformDHSecret = srv.fallbackPassword

        return transportOptions
开发者ID:matanmaz,项目名称:pupy,代码行数:20,代码来源:scramblesuit.py


示例14: __init__

    def __init__(self, version_label,
                 my_node, state_filename,
                 routing_m_mod, lookup_m_mod,
                 experimental_m_mod,
                 private_dht_name,
                 bootstrap_mode):
        
        if size_estimation:
            self._size_estimation_file = open('size_estimation.dat', 'w')
        
        
        self.state_filename = state_filename
        saved_id, saved_bootstrap_nodes = state.load(self.state_filename)
        my_addr = my_node.addr
        self._my_id = my_node.id # id indicated by user 
        if not self._my_id:
            self._my_id = saved_id # id loaded from file
        if not self._my_id:
            self._my_id = self._my_id = identifier.RandomId() # random id
        self._my_node = Node(my_addr, self._my_id, version=version_label)
        self.msg_f = message.MsgFactory(version_label, self._my_id,
                                        private_dht_name)
        self._querier = Querier()
        self._routing_m = routing_m_mod.RoutingManager(
            self._my_node, saved_bootstrap_nodes, self.msg_f)

        self._responder = responder.Responder(self._my_id, self._routing_m,
                                              self.msg_f, bootstrap_mode)
        self._tracker = self._responder._tracker
        
        self._lookup_m = lookup_m_mod.LookupManager(self._my_id, self.msg_f)
        self._experimental_m = experimental_m_mod.ExperimentalManager(
            self._my_node.id, self.msg_f) 
                  
        current_ts = time.time()
        self._next_save_state_ts = current_ts + SAVE_STATE_DELAY
        self._next_maintenance_ts = current_ts
        self._next_timeout_ts = current_ts
        self._next_main_loop_call_ts = current_ts
        self._pending_lookups = []
        self._cached_lookups = []
开发者ID:AnandMurugan,项目名称:tgs-android,代码行数:41,代码来源:controller.py


示例15: setup

    def setup( cls, transportConfig ):
        """
        Called once when obfsproxy starts.
        """

        util.setStateLocation(transportConfig.getStateLocation())

        cls.weAreClient = transportConfig.weAreClient
        cls.weAreServer = not cls.weAreClient
        cls.weAreExternal = transportConfig.weAreExternal

        # If we are server and in managed mode, we should get the
        # shared secret from the server transport options.
        if cls.weAreServer and not cls.weAreExternal:
            cfg  = transportConfig.getServerTransportOptions()
            if cfg and "password" in cfg:
                try:
                    cls.uniformDHSecret = base64.b32decode(util.sanitiseBase32(
                            cfg["password"]))
                except TypeError as error:
                    log.error(error.message)
                    raise base.PluggableTransportError("Given password '%s' " \
                            "is not valid Base32!  Run " \
                            "'generate_password.py' to generate a good " \
                            "password." % cfg["password"])

                cls.uniformDHSecret = cls.uniformDHSecret.strip()

        if cls.weAreServer:
            if not hasattr(cls, "uniformDHSecret"):
                log.debug("Using fallback password for descriptor file.")
                srv = state.load()
                cls.uniformDHSecret = srv.fallbackPassword
            state.writeServerDescriptor(cls.uniformDHSecret,
                                        transportConfig.getBindAddr(),
                                        cls.weAreExternal)
开发者ID:MOODOO-SH,项目名称:scramblesuit,代码行数:36,代码来源:scramblesuit.py


示例16: run

def run(state, train, y, test, v, z):
    #cname = sys._getframe().f_code.co_name
    cname = 'p'
    train.drop('id', axis=1, inplace=True)
    test.drop('id', axis=1, inplace=True)
    from hyperopt import fmin, tpe, hp, STATUS_OK, Trials, space_eval
    def step_rf(params):
        clf = ensemble.RandomForestRegressor(**params)
        cv = model_selection.cross_val_score(clf,
                                             train, y,
                                             scoring=metrics.make_scorer(metrics.log_loss),
                                             cv = 10,
                                             n_jobs = -2)
        score = np.mean(cv)
        print(cname, score, params)
        return dict(loss=score, status=STATUS_OK)
    space_rf = dict(
        n_estimators = hp.choice('n_estimators', range(50, 1500)),
        #criterion = hp.choice('criterion', ["gini", "entropy"]),
        min_samples_split = hp.choice('min_samples_split', range(2, 10)),
        min_samples_leaf = hp.choice('min_samples_leaf', range(1, 10)),
        max_features = hp.choice('max_features', range(1, 16)),
        random_state = 1
        )
    trs = state.load('rf_trials')
    if trs == None or debug_mode:
        tr = Trials()
    else:
        tr, _ = trs
    if len(tr.trials) > 0:
        print('reusing %d trials, best was:'%(len(tr.trials)), space_eval(space_rf, tr.argmin))
        best = tr.argmin
    while len(tr.trials) < 15:
        best = fmin(step_rf, space_rf, algo=tpe.suggest, max_evals=len(tr.trials) + 1, trials = tr)
        state.save('et_trials', (tr, space_rf))
    rf_params = space_eval(space_rf, best)
    print(rf_params)

    N_splits = 9
    N_seeds = 3

    skf = model_selection.StratifiedKFold(n_splits=N_splits, shuffle=True)
    cv = []
    for s in range(N_seeds):
        scores = []
        cname2 = cname + str(s)
        v[cname2], z[cname2] = 0, 0
        rf_params['random_state'] = s + 4242
        for n, (itrain, ival) in enumerate(skf.split(train, y)):
            clf = ensemble.RandomForestRegressor(**rf_params)
            clf.fit(train.ix[itrain], y[itrain])
            p = clf.predict(train.ix[ival])
            v.loc[ival, cname2] += p
            score = metrics.log_loss(y[ival], p)
            z[cname2]  += clf.predict(test)
            print(cname, 'seed %d step %d of %d: '%(rf_params['random_state'], n+1, skf.n_splits), score, state.now())
            scores.append(score)
        z[cname2] /= N_splits
        cv.append(np.mean(scores))
        print('seed %d loss: '%(rf_params['random_state']), scores, np.mean(scores), np.std(scores))
        z['y'] = z[cname2]

    print('cv:', cv, np.mean(cv), np.std(cv))
    return cv, None
开发者ID:ivan-filonov,项目名称:mlbootcamp_5,代码行数:64,代码来源:l1_4_rf_1.py


示例17:

        os.system("ln -s log %s " % (verboselogfile))
    else:
        print >> sys.stderr, "Logging to %s, not creating any link because of default settings" % logfile

    import random, numpy
    random.seed(miscglobals.RANDOMSEED)
    numpy.random.seed(miscglobals.RANDOMSEED)

    import vocabulary
#    logging.info("Reading vocab")
#    vocabulary.read()
    
    import model
    try:
        print >> sys.stderr, ("Trying to read training state for %s %s..." % (newkeystr, rundir))
        (m, cnt, epoch, get_train_minibatch) = state.load(rundir, newkeystr)
        print >> sys.stderr, ("...success reading training state for %s %s" % (newkeystr, rundir))
        print >> sys.stderr, logfile
        logging.basicConfig(filename=logfile, level=logging.DEBUG)
#        logging.basicConfig(filename=logfile, filemode="w", level=logging.DEBUG)
        logging.info("CONTINUING FROM TRAINING STATE")
    except IOError:
        print >> sys.stderr, ("...FAILURE reading training state for %s %s" % (newkeystr, rundir))
        print >> sys.stderr, ("INITIALIZING")

        m = model.Model()
        cnt = 0
        epoch = 1
        get_train_minibatch = examples.TrainingMinibatchStream()
        logging.basicConfig(filename=logfile, filemode="w", level=logging.DEBUG)
        logging.info("INITIALIZING TRAINING STATE")
开发者ID:everwind,项目名称:DNNNLP,代码行数:31,代码来源:train.py


示例18: test2_loadState

 def test2_loadState( self ):
     # load() should create the state file if it doesn't exist yet.
     self.failIf(os.path.exists(self.stateFile))
     self.failUnless(isinstance(state.load(), state.State))
开发者ID:MOODOO-SH,项目名称:scramblesuit,代码行数:4,代码来源:unittests.py


示例19: run

def run(train, y, test, v, z):
    #cname = sys._getframe().f_code.co_name
    cname = 'p'
    train.drop('id', axis=1, inplace=True)
    test.drop('id', axis=1, inplace=True)
    from hyperopt import fmin, tpe, hp, STATUS_OK, Trials, space_eval
    dtrain = xgb.DMatrix(train, y)
    def step_xgb(params):
        cv = xgb.cv(params=params,
                    dtrain=dtrain,
                    num_boost_round=10000,
                    early_stopping_rounds=50,
                    nfold=10,
                    seed=params['seed'])
        score = cv.ix[len(cv)-1, 0]
        print(cname, score, len(cv), params)
        return dict(loss=score, status=STATUS_OK)
    space_xgb = dict(
            max_depth = hp.choice('max_depth', range(2, 8)),
            subsample = hp.quniform('subsample', 0.6, 1, 0.05),
            colsample_bytree = hp.quniform('colsample_bytree', 0.6, 1, 0.05),
            learning_rate = hp.quniform('learning_rate', 0.005, 0.03, 0.005),
            min_child_weight = hp.quniform('min_child_weight', 1, 6, 1),
            gamma = hp.quniform('gamma', 0.5, 10, 0.05),

            objective = 'binary:logistic',
            eval_metric = 'logloss',
            seed = 1,
            silent = 1
        )
    trs = state.load('xgb_trials')
    if trs == None:
        tr = Trials()
    else:
        tr, _ = trs
    if len(tr.trials) > 0:
        print('reusing %d trials, best was:'%(len(tr.trials)), space_eval(space_xgb, tr.argmin))
        best = tr.argmin
    while len(tr.trials) < 15:
        best = fmin(step_xgb, space_xgb, algo=tpe.suggest, max_evals=len(tr.trials) + 1, trials = tr)
        state.save('xgb_trials', (tr, space_xgb))
    xgb_params = space_eval(space_xgb, best)
    print(xgb_params)

    N_splits = 9
    N_seeds = 1

    skf = model_selection.StratifiedKFold(n_splits=N_splits, shuffle=True)
    dtest = xgb.DMatrix(test)
    for s in range(N_seeds):
        scores = []
        cname2 = cname + str(s)
        v[cname2], z[cname2] = 0, 0
        xgb_params['seed'] = s + 4242
        for n, (itrain, ival) in enumerate(skf.split(train, y)):
            dtrain = xgb.DMatrix(train.ix[itrain], y[itrain])
            dvalid = xgb.DMatrix(train.ix[ival], y[ival])
            watch = [(dtrain, 'train'), (dvalid, 'valid')]
            clf = xgb.train(xgb_params, dtrain, 10000, watch, early_stopping_rounds=100, verbose_eval=False)

            p = clf.predict(dvalid)
            v.loc[ival, cname2] += p
            score = metrics.log_loss(y[ival], p)
            z[cname2]  += clf.predict(dtest)
            print(cname, 'seed %d step %d of %d: '%(xgb_params['seed'], n+1, skf.n_splits), score, state.now())
            scores.append(score)
        z[cname2] /= N_splits

    cv = scores
    z['y'] = z[cname2]
    print('validation loss: ', cv, np.mean(cv), np.std(cv))

    return cv, None
开发者ID:ivan-filonov,项目名称:mlbootcamp_5,代码行数:73,代码来源:l1_1_ho_xgb_1.py


示例20: SessionTicket

# Give ScrambleSuit server operators a way to manually issue new session
# tickets for out-of-band distribution.
if __name__ == "__main__":

    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument("ip_addr", type=str, help="The IPv4 address of the "
                        "%s server." % const.TRANSPORT_NAME)
    parser.add_argument("tcp_port", type=int, help="The TCP port of the %s "
                        "server." % const.TRANSPORT_NAME)
    parser.add_argument("ticket_file", type=str, help="The file, the newly "
                        "issued ticket is written to.")
    args = parser.parse_args()

    print "[+] Loading server state file."
    serverState = state.load()

    print "[+] Generating new session ticket."
    masterKey = mycrypto.strongRandom(const.MASTER_KEY_LENGTH)
    ticket = SessionTicket(masterKey, serverState).issue()

    print "[+] Writing new session ticket to `%s'." % args.ticket_file
    tickets = dict()
    server = IPv4Address('TCP', args.ip_addr, args.tcp_port)
    tickets[str(server)] = [int(time.time()), masterKey, ticket]

    util.writeToFile(yaml.dump(tickets), args.ticket_file)

    print "[+] Success."
开发者ID:0xa-cc,项目名称:pupy,代码行数:30,代码来源:ticket.py



注:本文中的state.load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python state.State类代码示例发布时间:2022-05-27
下一篇:
Python starutil.NDG类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap