Пример #1
0
def load(city):
    TicToc = tic_toc.TicTocGenerator()
    tic_toc.tic(TicToc)
    junctions = []
    subjun = []
    for line in enumerate(codecs.open("{}_net.txt".format(city), "r",
                                      "utf-8")):
        junctions.append(Junction(line[1]))
        subjun.append(len(junctions[-1].subjunctions))
    city_array = np.array(subjun)
    tic_toc.toc(TicToc)
    return junctions, city_array
Пример #2
0
def maneuver(city_array, city):
    step = 1
    checked = 0
    y_array = []
    x_array = []
    while checked < city_array.size:
        TicToc = tic_toc.TicTocGenerator()
        tic_toc.tic(TicToc)
        x_array.append(step)
        y_array.append(0)
        y_array[-1] += np.extract(city_array == step, city_array).size
        checked += y_array[-1]
        tic_toc.toc(TicToc)
        print(step, checked, city_array.size)
        step += 1
    pickle.dump(x_array, open('histogram_a/x_array_{}.p'.format(city), 'wb'))
    pickle.dump(y_array, open('histogram_a/y_array_{}.p'.format(city), 'wb'))
Пример #3
0
#!/usr/bin/python
# -*- coding:utf-8 -*-

import requests
from bs4 import BeautifulSoup
import pandas as pd
from collections import defaultdict
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time
from tic_toc import tic, toc

tic()

trainfle = './data/train3.csv'
f1 = open(trainfle, 'w')

train_urls = ['https://music.douban.com/top250']
#
#
#
sel = webdriver.Chrome()
loginurl = 'https://music.douban.com/top250'
#open the login in page
sel.get(loginurl)

s = requests.session()
s.keep_alive = False
head = {
    'User-Agent':
Пример #4
0
X_train, X_test, y_train, y_test = train_test_split(df.drop(['Survived'],
                                                            axis=1),
                                                    df['Survived'],
                                                    test_size=.1)
#%% iris binary
df = pd.read_csv('data/iris_binary_prepd.csv')
#%% bike buyer
df = pd.read_csv('data/bike_buyer_prepd.csv')
df = df.set_index('ID')
#%%
X_train, X_test, y_train, y_test = train_test_split(df.drop(['label'], axis=1),
                                                    df['label'],
                                                    test_size=.1)

#%% test the training module
tic_toc.tic()
size = len(X_train)
# titanic does well with norm 1
# if validation is an integer cross validation is performed and perc_cluster is set to 0
best_part = gen_part.train(df.drop(['Survived'], axis=1),
                           df['Survived'],
                           500,
                           15,
                           prob_mutate=.05,
                           mutate_strength=.3,
                           survival_rate=.1,
                           alien_rate=.1,
                           min_cubes=20,
                           min_rows_in_cube=20,
                           metric='acc',
                           validation=5,