def __init__(self): self.ais = [ ai.RandomAI(), ai.BeijingAlgorithmAI(), ai.MarkovChainAi(), ai.RandomBiasedAi(), ] self.stats = Stats()
def create_player(): if request.method == 'POST': player = request.form['name'] # checking for existing player existing = session.query(Stats).filter_by(player=player).scalar() is not None # show flash message if player already exist if existing: flash("Player already exist. Try entering different name") return redirect(url_for('create_player')) # if player not exist then create new player in database else: new_player = Stats(player = player, game = 0, win = 0, lose = 0) session.add(new_player) session.commit() return redirect(url_for('start_game')) else: return render_template('create_player.html')
def convert_from_dict_to_maze(data) -> Maze: """ Convert dict data to maze object\n Returns: Maze object """ maze = Maze( data["maze"], data["width"], data["height"], data["start_coords"], data["end_coords"], ) if "stats" in data: # if maze has stats, add Stats() object maze.Stats = Stats() for stat in data["stats"]: maze.Stats.solutions.append(stat) return maze
def get(self): stats = Stats() stats.nr_of_users = 0 stats.nr_of_active_users = 0 stats.nr_of_playlists = len([i for i in Playlist.all()]) stats.nr_of_users_with_flattr_account = 0 stats.nr_of_flattrs = len([ i for i in Activity.all().filter('type =', 'outgoing').filter( 'verb =', 'flattr') ]) stats.nr_of_playlist_subscriptions = 0 stats.nr_of_follow_relations = len([i for i in FollowRelation.all()]) for user in YoutifyUser.all(): stats.nr_of_users += 1 if user.flattr_user_name: stats.nr_of_users_with_flattr_account += 1 if user.playlist_subscriptions: stats.nr_of_playlist_subscriptions += len( user.playlist_subscriptions) if user.last_login: delta = datetime.now() - user.last_login if delta.seconds < 3600 * 24 * 7: stats.nr_of_active_users += 1 pings = [] last_ping = None for m in PingStats.all().order('-date').fetch(6 * 24 * 7): if last_ping is not None and last_ping.date.hour is not m.date.hour: pings.append({ 'date': str(last_ping.date), 'pings': last_ping.pings }) last_ping = m elif last_ping is None or m.pings > last_ping.pings: last_ping = m stats.pings = simplejson.dumps(pings) stats.put()
def get(self): stats = Stats() stats.nr_of_users = 0 stats.nr_of_active_users = 0 try: stats.nr_of_playlists = Playlist.all(keys_only=True).count( read_policy=EVENTUAL_CONSISTENCY) except: pass stats.nr_of_users_with_flattr_account = 0 stats.nr_of_users_with_dropbox = 0 try: stats.nr_of_flattrs = Activity.all().filter( 'type =', 'outgoing').filter( 'verb =', 'flattr').count(read_policy=EVENTUAL_CONSISTENCY) except: pass stats.nr_of_playlist_subscriptions = 0 try: stats.nr_of_follow_relations = FollowRelation.all( keys_only=True).count(read_policy=EVENTUAL_CONSISTENCY) except: pass try: for user in YoutifyUser.all(): stats.nr_of_users += 1 if user.flattr_user_name: stats.nr_of_users_with_flattr_account += 1 if user.dropbox_user_name: stats.nr_of_users_with_dropbox += 1 if user.playlist_subscriptions: stats.nr_of_playlist_subscriptions += len( user.playlist_subscriptions) if user.last_login: delta = datetime.now() - user.last_login if delta.seconds < 3600 * 24 * 7: stats.nr_of_active_users += 1 except: pass pings = [] last_ping = None try: for m in PingStats.all().order('-date').fetch(6 * 24 * 7): if last_ping is not None and last_ping.date.hour is not m.date.hour: pings.append({ 'date': str(last_ping.date), 'pings': last_ping.pings }) last_ping = m elif last_ping is None or m.pings > last_ping.pings: last_ping = m except: pass stats.pings = simplejson.dumps(pings) stats.put()
engine = create_engine('sqlite:///stats.db') # Bind the engine to the metadata of the Base class so that the # declaratives can be accessed through a DBSession instance Base.metadata.bind = engine DBSession = sessionmaker(bind=engine) # A DBSession() instance establishes all conversations with the database # and represents a "staging zone" for all the objects loaded into the # database session object. Any change made against the objects in the # session won't be persisted into the database until you call # session.commit(). If you're not happy about the changes, you can # revert all of them back to the last commit by calling # session.rollback() session = DBSession() player1 = Stats(player="Sayed", game=0, win=0, lose=0) session.add(player1) session.commit() player2 = Stats(player="Sohel", game=0, win=0, lose=0) session.add(player2) session.commit() player3 = Stats(player="Jay", game=0, win=0, lose=0) session.add(player3) session.commit() player4 = Stats(player="Tim", game=0, win=0, lose=0) session.add(player4) session.commit()
# Dataset samples, read .CSV file csv_dataset = pd.read_csv('./data/Dataset.csv') # dropping passed columns csv_dataset.drop([ "Silica", "Fosfato", "Alumina", "Manganes", "Titanio", "Magnesio", "Carbonato" ], axis=1, inplace=True) x = csv_dataset.iloc[:, 1:].values #Predictors y = csv_dataset.iloc[:, 0].values #To be Predicted y = y.reshape(-1, 1) # needs 2D vector arrays_RF5 = Stats() arrays_RF20 = Stats() arrays_MLP55 = Stats() arrays_MLP2020 = Stats() # For loop to vary the seed and train "training_qnt" times for i in range(1, training_qnt + 1): # splitting Dataset samples in train and test x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=1 / 3, random_state=None) # Get Regressors regressor_RF5 = get_rf_regressor(5, 'mse') regressor_RF20 = get_rf_regressor(20, 'mse')
def __init__(self): self.stats = Stats()