# Notebook from imsanjoykb/MindGames
Path: Game_Streamer_Analysis.ipynb

### Project :   Game Streamer Analysis
### Author :    Sanjoy Kumar
### Email :      sanjoy.eee32@gmail.com
### Portfolio : imsanjoykb.github.io_____no_output_____## Import Necessary Libraries_____no_output_____

import pandas as pd
import numpy as np
import matplotlib.pylab as plt
import datetime
import missingno as msno
from collections import Counter_____no_output_____

## Import Data Source_____no_output_____

data_source =  'Maingames_DS_dataset.csv'
df = pd.read_csv(data_source, index_col="Unnamed: 0")
df.head(5)_____no_output_____

## Data Internal Insights_____no_output_____

df.shape_____no_output_____df.isnull().sum()_____no_output_____df.describe()_____no_output_____

## Data Cleaning_____no_output_____

# Drop NA value (value = '-')
df = df[df.Game != '-']
df = df[df.Game != 'No MLBB Video']
# Merge same game name
 # Arena of Valor
df['Game'] = df['Game'].replace(['Garena Liên Quân Mobile','Liên Quân Mobile'],'Arena of Valor')
 # Age of Empires
df['Game'] = df['Game'].replace(['Agge of Empires'],'Age of Empires')
 # Audition online
df['Game'] = df['Game'].replace(['Audition'],'Audition Online')
df['Game'] = df['Game'].replace(['Call of Duty: Mobile VN'],'Call of Duty: Mobile')
df['Total Follower'] = df['Total Follower'].replace(['250,98'],25098)

# change datatype
df['Total Follower'] = pd.to_numeric(df['Total Follower'])

# Other
df['PaidStarPerWatchedHourPerFollower'] = df['PaidStarPerWatchedHour']/df['Total Follower']
_____no_output_____# Show all games
for game in df.groupby('Game').groups.keys():
  print(game)
df.groupby('Game').groups.keys()
df.groupby('Game').count().iloc[:,0].shape
8 Ball Pool
Age of Empires
Apex Legends
Arena of Valor
Assassin's Creed Odyssey
Audition Online
Auto Chess
Blade & Soul
CABAL ONLINE
Call of Duty: Mobile
Call of Duty: Warzone
Coin Master
Counter-Strike: Global Offensive
Crazy Kart
Crossfire
Days Gone
Dead by Daylight
Dota 2
EA Sports UFC 3
Euro Truck Simulator 2
FIFA Online 4
Five Nights at Freddy's 2
Free Fire - Battlegrounds
God of War
Grand Theft Auto V
Green Hell
Identity V
J-League Jikkyou Winning Eleven
League of Legends
League of Legends: Wild Rift
Little Big Snake
MLBB
MU Online
Minecraft
Moon of Madness
MotoGP
NBA 2K20
Naruto Shippuden: Ultimate Ninja Storm 4
Ngọc Rồng Online
PUBG
Persona 5 Royal
Point Blank Indonesia
RULES OF SURVIVAL
Ragnarok M: Eternal Love
Roblox
Sea of Thieves
Star Wars Jedi: Fallen Order
Teamfight Tactics
The Last of Us
The Last of Us: Part II
The Warriors
Township Mobile
Valorant
World War Z
Wormate.io
Worms Zone
Yakuza: Kiwami 2
eFootball PES 2020
# Generate game count
df_game_count = df.groupby('Game').count().sort_values('Country', ascending=False).iloc[:, 0:1].rename(columns={'Country':'Count'})
# df_game_count.head(10)
_____no_output_____

## Check Per Followers_____no_output_____

cols = ['Total Follower','PaidStarPerWatchedHour'] # The columns you want to search for outliers in

# Calculate quantiles and IQR
Q1 = df[cols].quantile(0.25) # Same as np.percentile but maps (0,1) and not (0,100)
Q3 = df[cols].quantile(0.75)
IQR = Q3 - Q1

# Return a boolean array of the rows with (any) non-outlier column values
condition = ~((df[cols] < (Q1 - 1.5 * IQR)) | (df[cols] > (Q3 + 1.5 * IQR))).any(axis=1)

# Filter our dataframe based on condition
filtered_df = df[condition]
filtered_df.shape_____no_output_____filtered_df[['Total Follower', 'PaidStarPerWatchedHourPerFollower']].plot(x='Total Follower', y='PaidStarPerWatchedHourPerFollower', grid=True, kind='scatter')_____no_output_____# select data of PaidStarPerWatchedHourPerFollower in Q3-Q4
cols = ['PaidStarPerWatchedHourPerFollower']
Q1 = df[cols].quantile(0.25)
Q3 = df[cols].quantile(0.75)
condition = (df[cols]>Q3).any(axis=1)
df_filtered_by_PSPWPF = df[condition]_____no_output_____c = df_filtered_by_PSPWPF.corr()
c['PSPW_abs'] = c['PaidStarPerWatchedHour'].apply(lambda x: abs(x))
c_rank = c[['PaidStarPerWatchedHour', 'PSPW_abs']].sort_values('PSPW_abs', ascending=False)[c['PSPW_abs'] > c['PSPW_abs'].mean()]
c_rank = c_rank.iloc[3:]
c_rank.head(10)
/home/eclbd/.local/lib/python3.6/site-packages/ipykernel_launcher.py:3: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  This is separate from the ipykernel package so we can avoid doing imports until

## Correlation Matrix with General Data _____no_output_____

corr_matrix = df.corr()
corr_matrix['PSPW_abs'] = corr_matrix['PaidStarPerWatchedHour'].apply(lambda x: abs(x))
corr_core = corr_matrix[['PaidStarPerWatchedHour', 'PSPW_abs']]
_____no_output_____corr_core.sort_values('PSPW_abs', ascending=False).head(10)
_____no_output_____

## Divide into several group: Country, Game, Genger_____no_output_____

# Distribution of VN, PUBG, Male
vpm = df.loc[df['Game'] == 'PUBG'].loc[df['Country'] == 'VN'].loc[df['Gender'] == 'Male']
test_corr = vpm.corr()
test_corr['PSPW_abs'] = test_corr['PaidStarPerWatchedHour'].apply(lambda x: abs(x))
test_corr = test_corr[['PaidStarPerWatchedHour', 'PSPW_abs']]
test_corr
_____no_output_____# select data of PaidStarPerWatchedHourPerFollower in Q3-Q4
cols = ['PSPW_abs']
Q3 = test_corr[cols].quantile(0.75)
condition = (test_corr[cols]>Q3).any(axis=1)
test_corr = test_corr[condition]
test_corr = test_corr.sort_values('PSPW_abs',ascending= False).iloc[3:,1:]
test_corr
test_corr.head(5).plot(kind='barh')
_____no_output_____# Distribution of VN, PUBG, Female
vpf = df.loc[df['Game'] == 'PUBG'].loc[df['Country'] == 'VN'].loc[df['Gender'] == 'Female']
test_corr_f = vpf.corr()
test_corr_f['PSPW_abs'] = test_corr_f['PaidStarPerWatchedHour'].apply(lambda x: abs(x))
test_corr_f = test_corr_f[['PaidStarPerWatchedHour', 'PSPW_abs']]
test_corr_f_____no_output_____# select data of PaidStarPerWatchedHourPerFollower in Q3-Q4
cols = ['PSPW_abs']
Q3 = test_corr_f[cols].quantile(0.75)
condition = (test_corr_f[cols]>Q3).any(axis=1)
test_corr_f = test_corr_f[condition]
test_corr_f = test_corr_f.sort_values('PSPW_abs',ascending= False)[test_corr_f['PSPW_abs'] > test_corr_f['PSPW_abs'].mean()].iloc[3:,1:]
test_corr_f.plot(kind='barh')
/home/eclbd/.local/lib/python3.6/site-packages/ipykernel_launcher.py:6: UserWarning: Boolean Series key will be reindexed to match DataFrame index.

# print(df.groupby('Country').mean()['PaidStarPerWatchedHour'])
print(df.groupby('Country').mean()['PaidStarPerWatchedHour']/df.groupby('Country').count()['PaidStarPerWatchedHour'])
(df.groupby('Country').mean()['PaidStarPerWatchedHour']/df.groupby('Country').count()['PaidStarPerWatchedHour']).plot(kind='barh')
Country
ID    0.000022
PH    0.000202
VN    0.000025
Name: PaidStarPerWatchedHour, dtype: float64
df[df['Gender'] == 'Male'].groupby('Country').mean()['PaidStarPerWatchedHour'].plot(kind='barh')
_____no_output_____df[df['Gender'] == 'Female'].groupby('Country').mean()['PaidStarPerWatchedHour'].plot(kind='barh')
_____no_output_____df.groupby('Gender').mean()['PaidStarPerWatchedHour'].plot(kind='barh')
_____no_output_____df[df['Country'] == 'PH'].groupby('Gender').mean()['PaidStarPerWatchedHour'].plot(kind='barh')
_____no_output_____print(df.groupby('Gender').mean()['PaidStarPerWatchedHour']/df.groupby('Gender').count()['PaidStarPerWatchedHour'])
(df.groupby('Gender').mean()['PaidStarPerWatchedHour']/df.groupby('Gender').count()['PaidStarPerWatchedHour']).plot(kind='barh')
Gender
Female    0.000183
Male      0.000010
Name: PaidStarPerWatchedHour, dtype: float64
df[df['Country'] == 'VN'].groupby('Gender').mean()['PaidStarPerWatchedHour'].plot(kind='barh')
_____no_output_____df[df['Country'] == 'ID'].groupby('Gender').mean()['PaidStarPerWatchedHour'].plot(kind='barh')
_____no_output_____

## Thank you_____no_output_____


# Notebook from DiffEqML/diffeqml_research
Path: hypersolver/image_classification/hypereuler_cifar.ipynb

# HyperEuler on CIFAR-trained Neural ODEs_____no_output_____

import sys ; sys.path.append('..')
from torchdyn.models import *; from torchdyn import *_____no_output_____import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from torchvision import datasets, transforms

import pytorch_lightning as pl
from pytorch_lightning.loggers import WandbLogger
from pytorch_lightning.metrics.functional import accuracy
from tqdm import tqdm_notebook as tqdm
from src.custom_fixed_explicit import ButcherTableau, GenericExplicitButcher
from src.hypersolver import *_____no_output_____device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")_____no_output_____# smaller batch_size; only needed for visualization. The classification model
# will not be retrained
batch_size=16
size=32
path_to_data='../data/cifar10_data'

transform_train = transforms.Compose([
    transforms.ToTensor(),
    transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
])

transform_test = transforms.Compose([
    transforms.ToTensor(),
    transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
])

train_data = datasets.CIFAR10(path_to_data, train=True, download=True,
                              transform=transform_train)
test_data = datasets.CIFAR10(path_to_data, train=False,
                             transform=transform_test)

trainloader = DataLoader(train_data, batch_size=batch_size, shuffle=True)
testloader = DataLoader(test_data, batch_size=batch_size, shuffle=True)Files already downloaded and verified

## Loading the pretrained Neural ODE _____no_output_____

func = nn.Sequential(nn.Conv2d(20, 50, 3, padding=1),
                     nn.Softplus(),
                     nn.Conv2d(50, 50, 3, padding=1),
                     nn.Softplus(),
                     nn.Conv2d(50, 20, 3, padding=1)
                     ).to(device)
ndes = []
for i in range(1):
    ndes.append(NeuralDE(func,
                       solver='dopri5',
                       sensitivity='adjoint',
                       atol=1e-5,
                       rtol=1e-5,
                       s_span=torch.linspace(0, 1, 2)).to(device))
    #ndes.append(nn.Conv2d(32, 32, 3, padding=1)))

model = nn.Sequential(nn.BatchNorm2d(3),
                      nn.Conv2d(3, 20, 3, padding=1),
                      #Augmenter(1, 5),
                      *ndes,
                      nn.AdaptiveAvgPool2d(2),
                      #nn.Conv2d(32, 1, 3, padding=1),
                      nn.Flatten(),
                      nn.Linear(20*4, 10)).to(device)_____no_output_____state_dict = torch.load('../pretrained_models/nde_cifar')

# remove state_dict keys for `torchdyn`'s Adjoint nn.Module (not used here)
copy_dict = state_dict.copy()
for key in copy_dict.keys():
    if 'adjoint' in key: state_dict.pop(key)

model.load_state_dict(state_dict)_____no_output_____

### Visualizing pretrained flows_____no_output_____

x, y = next(iter(trainloader)); x = x.to(device)
for layer in model[:2]: x = layer(x)
model[2].nfe = 0
traj = model[2].trajectory(x, torch.linspace(0, 1, 50)).detach().cpu()
model[2].nfe /home/jyp/michael_dev/testenv/lib/python3.7/site-packages/torchdiffeq/_impl/misc.py:237: UserWarning: t is not on the same device as y0. Coercing to y0.device.
  warnings.warn("t is not on the same device as y0. Coercing to y0.device.")

Pixel-flows of the Neural ODE, solved with `dopri5`_____no_output_____

fig, axes = plt.subplots(nrows=5, ncols=10, figsize=(12, 6))
K = 4
for i in range(5):
    for j in range(10):
        im = axes[i][j].imshow(traj[i*5+j, K, 0], cmap='inferno')
fig.tight_layout(w_pad=0)_____no_output_____

### Defining the HyperSolver class (-- HyperEuler version --)_____no_output_____

tableau = ButcherTableau([[0]], [1], [0], [])
euler_solver = GenericExplicitButcher(tableau)

hypersolv_net = nn.Sequential(nn.Conv2d(20+20+1, 32, 3, stride=1, padding=1),
                nn.PReLU(),
                nn.Conv2d(32, 32, 3, padding=1),
                nn.PReLU(),
                nn.Conv2d(32, 20, 3, padding=1)).to(device)
#for p in hypersolv_net.parameters(): torch.nn.init.zeros_(p)

hs = HyperEuler(f=model[2].defunc, g=hypersolv_net)

x0 = torch.zeros(12, 20, 6, 6).to(device)
span = torch.linspace(0, 2, 10).to(device)

traj = model[2].trajectory(x0, span)
res_traj = hs.base_residuals(traj, span)
hyp_res_traj = hs.hypersolver_residuals(traj, span)
hyp_traj = hs.odeint(x0, span)_____no_output_____

### Training the Hypersolver_____no_output_____

PHASE1_ITERS = 10 # num iters without swapping of the ODE initial condition (new sample)
ITERS = 15000
s_span = torch.linspace(0, 1, 10).to(device)

run_loss = 0.

# using test data for hypersolver training does not cause issues
# or task information leakage; the labels are not utilized in any way
it = iter(trainloader)
X0, Y = next(it)
Y = Y.to(device)
X0 = model[:2](X0.to(device))

model[2].solver = 'dopri5'
traj  = model[2].trajectory(X0, s_span)
etraj = odeint(model[2].defunc, X0, s_span, method='euler')

opt = torch.optim.AdamW(hypersolv_net.parameters(), 1e-3, weight_decay=1e-8)
sched = torch.optim.lr_scheduler.CosineAnnealingLR(opt, T_max=ITERS, eta_min=5e-4)
for i in tqdm(range(ITERS)):

    ds = s_span[1] - s_span[0]
    base_traj  = model[2].trajectory(X0, s_span)
    residuals = hs.base_residuals(base_traj, s_span).detach()
    # Let the model generalize to other ICs after PHASE1_ITERS
    if i > PHASE1_ITERS:
        if i % 10 == 0: # swapping IC
            try:
                X0, _ = next(it)
            except:
                it = iter(trainloader)
                X0, _ = next(it)
            X0 = model[:2](X0.to(device))
            model[2].solver = 'dopri5'
            base_traj  = model[2].trajectory(X0, s_span)
            residuals = hs.base_residuals(base_traj.detach(), s_span).detach()

    corrections = hs.hypersolver_residuals(base_traj.detach(), s_span)
    loss =  torch.norm(corrections - residuals.detach(), p='fro', dim=(3, 4)).mean() * ds**2

    loss.backward()
    torch.nn.utils.clip_grad_norm_(hypersolv_net.parameters(), 1)
    if i % 10 == 0: print(f'\rLoss: {loss}', end='')
    opt.step()
    sched.step()
    opt.zero_grad()_____no_output_____it = iter(testloader)
X0, _ = next(it)
X0 = model[:2](X0.to(device))
steps = 10
s_span = torch.linspace(0, 1, steps)
# dopri traj
model[2].solver = 'dopri5'
traj = model[2].trajectory(X0, s_span).detach().cpu()
# euler traj
model[2].solver = 'euler'
etraj = model[2].trajectory(X0, s_span).detach().cpu()

straj = hs.odeint(X0, s_span).detach().cpu()_____no_output_____

Evolution of absolute error: [Above] HyperEuler, [Below] Euler_____no_output_____

fig, axes = plt.subplots(nrows=2, ncols=steps-1, figsize=(10, 4))
K = 8
vmin = min(torch.abs(straj[steps-1,:]-traj[steps-1,:]).sum(1)[K].min(),
           torch.abs(etraj[steps-1,:]-traj[steps-1,:]).sum(1)[K].min())
vmax = max(torch.abs(straj[steps-1,:]-traj[steps-1,:]).sum(1)[K].max(),
           torch.abs(etraj[steps-1,:]-traj[steps-1,:]).sum(1)[K].max())

for i in range(steps-1):
    im = axes[0][i].imshow(torch.abs(straj[i+1,:]-traj[i+1,:]).sum(1)[K], cmap='inferno', vmin=vmin, vmax=vmax)
for i in range(steps-1):
    im = axes[1][i].imshow(torch.abs(etraj[i+1,:]-traj[i+1,:]).sum(1)[K], cmap='inferno', vmin=vmin, vmax=vmax)
fig.colorbar(im,  ax=axes.ravel().tolist(), orientation='horizontal')
#tikz.save('MNIST_interpolation_AE_plot.tex')_____no_output_____

Evolution of absolute error: HyperEuler (alone). Greater detail_____no_output_____

fig, axes = plt.subplots(nrows=1, ncols=steps-1, figsize=(10, 4))
for i in range(steps-1):
    im = axes[i].imshow(torch.abs(straj[i+1,:]-traj[i+1,:]).sum(1)[K], cmap='inferno')
fig.colorbar(im,  ax=axes.ravel().tolist(), orientation='horizontal')_____no_output_____

### Evaluating ODE solution error_____no_output_____

it = iter(testloader)

x = []
# NOTE: high GPU mem usage for generating data below for plot (on GPU)
# consider using less batches (and iterating) or performing everything on CPU
for i in range(5):
    x_b, _ = next(it)
    x += [model[:2](x_b.to(device))]
x = torch.cat(x); x.shape_____no_output_____euler_avg_error, euler_std_error = np.array(euler_avg_error), np.array(euler_std_error)
hyper_avg_error, hyper_std_error = np.array(hyper_avg_error), np.array(hyper_std_error)
midpoint_avg_error, midpoint_std_error = np.array(midpoint_avg_error), np.array(midpoint_std_error)
rk4_avg_error, rk4_std_error = np.array(rk4_avg_error), np.array(rk4_std_error)

range_steps = range(8, 50, 1)
fig, ax = plt.subplots(1, 1); fig.set_size_inches(8, 3)
ax.plot(range_steps, euler_avg_error, color='red', linewidth=3, alpha=0.5)
ax.fill_between(range_steps, euler_avg_error-euler_std_error, euler_avg_error+euler_std_error, alpha=0.05, color='red')

ax.plot(range_steps, hyper_avg_error, c='black', linewidth=3, alpha=0.5)
ax.fill_between(range_steps, hyper_avg_error+hyper_std_error, hyper_avg_error-hyper_std_error, alpha=0.05, color='black')

# start from 10 steps, balance the steps
mid_range_steps = range(8, 50, 2)
ax.plot(mid_range_steps, midpoint_avg_error[::2], color='green', linewidth=3, alpha=0.5)
ax.fill_between(mid_range_steps, midpoint_avg_error[::2]-midpoint_std_error[::2], midpoint_avg_error[::2]+midpoint_std_error[::2], alpha=0.1, color='green')

# start from 10 steps, balance the steps
mid_range_steps = range(8, 50, 4)
ax.plot(mid_range_steps, rk4_avg_error[::4], color='gray', linewidth=3, alpha=0.5)
ax.fill_between(mid_range_steps, rk4_avg_error[::4]-rk4_std_error[::4], rk4_avg_error[::4]+rk4_std_error[::4], alpha=0.05, color='gray')

ax.set_ylim(0, 100)
ax.set_xlim(8, 40)
ax.legend(['Euler', 'HyperEuler', 'Midpoint', 'RK4'])
ax.set_xlabel('NFEs')
ax.set_ylabel('Terminal error (MAPE)')_____no_output_____


# Notebook from mehdi-kaytoue/sc2-player-identification
Path: basic.ipynb

<code>
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import sc2reader, time
from sc2reader import events # Use the LOTV branch for sc2reader!
from multiprocessing import Pool as ThreadPool

global params
# arguments to be shared for all threads.
params = {}
params["dir"] = "./replay-data/"
params["nbac"] = 300
params["nbsec"] = 30
params["tw"] = 5
params["out"] = "replay-traces.txt"

# Parse a single replay
def parse_replay(filename):
    global params
    print("Parsing: " + str(filename))
    try:
        result = ""
        replay = sc2reader.load_replay(filename, load_level=4, debug=True)
        # @TODO: Do we really get players only? No observator, refeerees, ...?
        players = [t.players for t in replay.teams]
        players = [y for x in players for y in x]
        for i in range(1, len(players) + 1):
            player_trace = players[i - 1].url
            player_trace += "," + players[i - 1].play_race
            last = 0
            action_count = 0
            for event in replay.player[i].events:
                if event.second > params["nbsec"]: break
                if action_count > params["nbac"]: break
                if event.second - last >= params["tw"]:
                    while event.second - last >= params["tw"]:
                        last += params["tw"]
                        player_trace += ",t" + str(last)
                if isinstance(event, sc2reader.events.game.SelectionEvent):
                    elements = [o.name for o in event.objects]
                    if "Nexus" in elements or "Hatchery" in elements or "Command Center" in elements:
                        player_trace += ",Base"
                        action_count += 1
                    if "MineralField" in elements and len(elements) == 1:
                        player_trace += ",SingleMineral"
                        action_count += 1
                    player_trace += ",s"
                elif isinstance(event, sc2reader.events.game.ControlGroupEvent):
                    player_trace += ",hotkey" + str(event.hotkey) + str(event.update_type)
                    action_count += 1
            result += player_trace+"\n"
        return result
    except:
        print("Unable to parse this replay:" + filename)
        return ""

def replays2traces(dir, nbac, nbsec, tw, out):
    global params
    params["dir"] = dir
    params["nbac"] = nbac
    params["nbsec"] = nbsec
    params["tw"] = tw
    params["out"] = out
    replays_to_parse = sc2reader.utils.get_files(dir)
    pool = ThreadPool(4)
    results = pool.map(parse_replay, replays_to_parse)
    pool.close()
    pool.join()
    with open(out, "w") as text_file:
        for r in results:
            if len(r) > 0:
                text_file.write(r)

_____no_output_____from collections import Counter

def traces2features(inputfile, outputfile, maxsec):
    features = []
    races = []
    urls = []
    with open(inputfile, "r") as traces:
        for trace in traces:
            trace = trace[:len(trace)-1]  # remove the '\n'
            actions = trace.split(",")
            urls += [actions[0]]
            races += [actions[1]]
            if "t"+str(maxsec) in actions:
                actions = actions[:actions.index("t"+str(maxsec))]
            actions = actions[2:]
            actions = [a for a in actions if not a[0] == "t"]
            dico = Counter(actions)
            features += [dico]
    features_name_list = sorted(set([action for f in features for action in f.keys()]))

    with open(outputfile, "w") as text_file:
        text_file.write(",".join(features_name_list) + ",race,battleneturl\n" )
        index = 0
        for f in features:
            text_file.write(",".join([str(f[k]) for k in features_name_list]) + "," + races[index] + "," + urls[index] + '\n')
            index += 1
_____no_output_____import numpy as np
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from sklearn import cross_validation
from sklearn import metrics
from sklearn import preprocessing
import matplotlib.pyplot as plt
from sklearn import tree
from collections import Counter

def encode_target(df, target_column):
    """Add column to df with integers for the target.
    Args
    ----
    df -- pandas DataFrame.
    target_column -- column to map to int, producing
                     new Target column.
    Returns
    -------
    df_mod -- modified DataFrame.
    targets -- list of target names.
    """
    df_mod = df.copy()
    targets = df_mod[target_column].unique()
    map_to_int = {name: n for n, name in enumerate(targets)}
    df_mod[target_column] = df_mod[target_column].replace(map_to_int)
    return(df_mod, targets)

def remove_unpopulated_classes(_df, target_column, threshold):
    """
    Removes any row of the df for which the label in target_column appears less
    than threshold times in the whole frame (not enough populated classes)
    :param df: The dataframe to filter
    :param target_column: The target column with labels
    :param threshold: the number of appearances a label must respect
    :return: The filtered dataframe
    """
    count = Counter(_df[target_column])
    valid = [k for k in count.keys() if count[k] >= threshold]
    _df = _df[_df[target_column].isin(valid)]
    return _df

def learn(inputfile, minlabels):

    df = pd.read_csv(inputfile)
    df2, _ = encode_target(df, "battleneturl")
    df3, _ = encode_target(df2, "race")
    df4 = remove_unpopulated_classes(df3, "battleneturl", minlabels)
    train_data = df4.values
    target = train_data[:, -1:].ravel()
    features = train_data[:, :-1]
    print("Data read.")

    # Cross validation
    model = RandomForestClassifier(max_features=None)
    print(model.get_params())
    X_train, X_test, y_train, y_test = cross_validation.train_test_split(features,target, test_size=0.2, random_state=0)
    model.fit(X_train, y_train)
    score = model.score(X_test, y_test)
    print(score)

    # 5 Cross validation
    #model = RandomForestClassifier(max_features=None)
    #print(model.get_params())
    #scores = cross_validation.cross_val_score(model, features, target, cv=5, scoring='accuracy')
    #print("accuracy: ", scores)
    #scores = cross_validation.cross_val_score(model, features, target, cv=5, scoring='precision_micro')
    #print("precision:", scores)

    return score
_____no_output_____import time

from parser import replays2traces
from features import traces2features
from models import learn
import matplotlib.pyplot as plt

import numpy as np
import numpy.random

replays2traces("replay-data/Whitera_replay_pack/", 1000, 100, 5, "replay-traces.txt")
maxseconds = [i for i in range(0, 101, 20)]
minlabels = [j for j in range(0, 101, 20)]
scores = []

for i in maxseconds:
    traces2features("replay-traces.txt", "features-train.txt", i)
    row = []
    for j in minlabels:
        score = learn("features-train.txt", j)
        row += [score]
    scores.append(row)

print(scores)

    #plt.clf()
    #plt.xlabel('Minimum number of games per player')
    #plt.ylabel('Classifier score ')
    #plt.ylim([0.0, 1.05])
    #plt.xlim([0.0, 100])
    #plt.title('Classifier score w.r.t. label count')
    #plt.legend(loc="lower left")
    #plt.plot(minlabels, scores, '-')
    #plt.show()

   Parsing: replay-data/Whitera_replay_pack/2012-07-30 - WhiteRa (P) vs DaNa (Z) - ESL Cloud Kingdom.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs nSgZlaTaN (Z) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs aLtnirvAnA (T) - Fractured Glacier.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs AlaStOr (Z) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs aTnDelphi (Z) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs Protosser (Z) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs aTnClouD (T) - Entombed Valley.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs SjoW (T) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs aTnDelphi (Z) - Entombed Valley.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-30 - WhiteRa (P) vs DaNa (Z) - GSL_Metropolis.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs Avekatten (Z) - Fractured Glacier.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs EmpireKas (T) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs Avekatten (Z) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs TypeReaL (P) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-30 - WhiteRa (P) vs DeeN (Z) - GSL_Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs TypeReaL (P) - Cloud Kingdom LE (2).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs EmpireKas (T) - Shakuras Plateau.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs TypeReaL (P) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs FXOBabyK (P) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs AvOiD (Z) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs TypeReaL (P) - Entombed Valley.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-30 - WhiteRa (P) vs DeViL (Z) - Ohana LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs FXOBabyK (P) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs beepboop (Z) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs WTF (P) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs IlIlIIlIIlIl (T) - Ohana LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs CuteAngel (P) - Fractured Glacier.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs DarthCaesar (T) - Akilon Wastes (2).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs WWMiniraser (Z) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-30 - WhiteRa (P) vs KroLu (P) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs MYMRiSK (P) - Daybreak LE (2).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-30 - WhiteRa (P) vs KroLu (P) - ESL ESV Sanshorn Mist AE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs DarthCaesar (T) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs MYMRiSK (P) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs WWSortOf (Z) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs MYMRiSK (P) - Shakuras Plateau.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs DarthCaesar (T) - Cloud Kingdom LE.SC2Replay
Unable to parse this replay:replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs DarthCaesar (T) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs DarthCaesar (T) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs MǂYoGo (Z) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-30 - WhiteRa (P) vs KroLu (P) - WCS Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs DarthCaesar (T) - Howling Peak (2).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs WWSortOf (Z) - Shakuras Plateau.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs Naugrim (Z) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs DarthCaesar (T) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs Naugrim (Z) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-05 - WhiteRa (P) vs Decy (P) - Fractured Glacier.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-30 - WhiteRa (P) vs makouni (P) - ESV Cloud  Kingdom.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-05 - WhiteRa (P) vs Destroyer (T) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-30 - WhiteRa (P) vs mTLDnE (P) - GSL_Whirlwind.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-05 - WhiteRa (P) vs Njial (T) - Fractured Glacier.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs NightEnD (P) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs DarthCaesar (T) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-30 - WhiteRa (P) vs SuperDanil (T) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-05 - WhiteRa (P) vs Zangetsu (P) - Fractured Glacier.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs Destiny (Z) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs SicKSpartaN (P) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-31 - WhiteRa (P) vs DaNa (Z) - ESL Daybreak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs EdgE (Z) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs SjoW (Z) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs dayvie (P) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs EGDeMusliMRC (T) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs EGIdra (P) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs LiquidNonY (P) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs GFThinasy (T) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs Slavious (T) - Korhal City (2).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs Slavious (T) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-31 - WhiteRa (P) vs ESCDaisy (P) - ESV Cloud  Kingdom.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs ILoveCandies (T) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs LuckyFool (T) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs Stephano (Z) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs Isochron (T) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs MechKing (T) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-31 - WhiteRa (P) vs ESCDaisy (P) - GSL_Atlantis Spaceship.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs mrSurprise (P) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs Levin (P) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs Ourk (T) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-07-31 - WhiteRa (P) vs ESCDaisy (P) - MLG Entombed Valley.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs NASL (P) - Fractured Glacier.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs Ourk (T) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs UkraineStar (Z) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs Player 2 (T) - Arid Plateau.SC2Replay
Unable to parse this replay:replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs Player 2 (T) - Arid Plateau.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs rANDY (Z) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-08-11 - WhiteRa (P) vs AlaStOr (Z) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs Vorgestellt (P) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs ReAson (P) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs Plexa (P) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-28_ext.LaurDMaCBeN(Z)_vs_WhiteRa(P)_-_WCS Ohana LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs roxkisLZ (Z) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs QuanticIllu (Z) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs roxkisLZ (Z) - Fractured Glacier.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-28_ext.Monster(T)_vs_WhiteRa(P)_-_WCS Shakuras Plateau.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs ROOTdrewbie (T) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs wiTy (P) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs DarthCaesar (T) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-06 - WhiteRa (P) vs roxkisLZ (Z) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs ROOTslush (Z) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs EGDeMusliMRC (T) - Fractured Glacier.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs FrozenImpact (T) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs EGDeMusliMRC (T) - Howling Peak (2).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs Shyguy (P) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs stY!AnzeloT (T) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs EGDeMusliMRC (T) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs HeadOverHeel (P) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-28_ext.TRsTk(T)_vs_WhiteRa(P)_-_WCS Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs Hitokiri (T) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs SyDe (Z) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs iLickPanties (Z) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs inFBlader (P) - Fractured Glacier.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs KEspada (P) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs TFunk (T) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs LGJason (P) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs Kaldi (Z) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-19 - WhiteRa (P) vs Dragon (T) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-07 - WhiteRa (P) vs ThreeOfSword (Z) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-28_WhiteRa(P)_vs_ext.SyDe(Z)_-_WCS Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs mYiNiroxs (Z) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-19 - WhiteRa (P) vs Dragon (T) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-19 - WhiteRa (P) vs DrBloomberg (Z) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs Nick (P) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs pal (P) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-19 - WhiteRa (P) vs MeltZy (Z) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs lIlIlIlIlIlI (T) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs Baz (T) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs MindBlowing (P) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs pal (P) - Newkirk City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs MindBlowing (Z) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs Braver (Z) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-29_llllllllllll(T)_vs_WhiteRa(P)_-_Entombed Valley.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs pal (P) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs Eagleburger (Z) - Newkirk City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs MindBlowing (Z) - Newkirk City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs èÓ¿óÙÑì«ú¿ (P) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-29_NrSkauP(T)_vs_WhiteRa(P)_-_Entombed Valley.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs rkv (P) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs MVP (T) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs Schceff (P) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs èÓ¿óÙÑì«ú¿ (Z) - Newkirk City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs XionS (P) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-28 - WhiteRa (P) vs Baz (T) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-29_WhiteRa(P)_vs_nBKimo(P)_-_Ohana LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-09-29_WhiteRa(P)_vs_NrSkauP(T)_-_Ohana LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs FruitDealer (T) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs NSHGolem (T) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-28 - WhiteRa (P) vs EGLordZergRC (Z) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs GornWood (T) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs ABomB (P) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs NSHGolem (T) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs Kaldi (Z) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs DarthPotato (T) - Newkirk City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs rkv (T) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs Kami (P) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs Dissonance (Z) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-28 - WhiteRa (P) vs Kami (P) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs SciagajMojty (P) - Newkirk City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-28 - WhiteRa (P) vs MisterWinter (P) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs dtGsCar (P) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-28 - WhiteRa (P) vs nfteamMate (T) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs ThEbEaST (Z) - Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs Kami (P) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-28 - WhiteRa (P) vs nfteamMate (T) - Newkirk City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs Filthy (P) - Howling Peak.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-27 - WhiteRa (P) vs mYiNiroxs (Z) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs ToXiC (P) - Newkirk City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-18 - WhiteRa (P) vs Filthy (P) - Korhal City.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-03-18 - WhiteRa (P) vs Beastyqt (T) - Antiga Shipyard.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2012-11-28 - WhiteRa (P) vs ThEbEaST (Z) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/a2.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Antiga Shipyard (20).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-03-18 - WhiteRa (P) vs Beastyqt (T) - Bel'Shir Vestige LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Daybreak LE (19).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-03-18 - WhiteRa (P) vs Beastyqt (T) - Cloud Kingdom LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Cloud Kingdom LE (34).SC2Replay
Parsing: replay-data/Whitera_replay_pack/a3.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Daybreak LE (32).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-03-18 - WhiteRa (P) vs Beastyqt (T) - Daybreak LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/a4.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Daybreak LE (34).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Cloud Kingdom LE (35).SC2Replay
Parsing: replay-data/Whitera_replay_pack/a5.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Daybreak LE (35).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Daybreak LE (36).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Cloud Kingdom LE (37).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Daybreak LE (37).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Cloud Kingdom LE (38).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Daybreak LE (38).SC2Replay
Parsing: replay-data/Whitera_replay_pack/a6.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Cloud Kingdom LE (39).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-03-18 - WhiteRa (P) vs Beastyqt (T) - Newkirk Precinct.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Cloud Kingdom LE (40).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Daybreak LE (39).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-03-18 - WhiteRa (P) vs Beastyqt (T) - Whirlwind LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Cloud Kingdom LE (41).SC2Replay
Parsing: replay-data/Whitera_replay_pack/d1.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Daybreak LE (40).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Akilon Wastes (18).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-03-19 - WhiteRa (P) vs Beastyqt (T) - Neo Planet S LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Akilon Wastes (56).SC2Replay
Parsing: replay-data/Whitera_replay_pack/d2.SC2Replay
Parsing: replay-data/Whitera_replay_pack/f1.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Akilon Wastes (59).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-04-26 - WhiteRa (P) vs HoBbe (Z) - DH Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/d3.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Akilon Wastes (60).SC2Replay
Parsing: replay-data/Whitera_replay_pack/d4.SC2Replay
Parsing: replay-data/Whitera_replay_pack/f2.SC2Replay
Parsing: replay-data/Whitera_replay_pack/d5.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-04-26 - WhiteRa (P) vs HoBbe (Z) - Whirlwind LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Akilon Wastes (61).SC2Replay
Parsing: replay-data/Whitera_replay_pack/f3.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Antiga Shipyard (15).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-04-26 - WhiteRa (P) vs SKMC (P) - Akilon Wastes.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Antiga Shipyard (16).SC2Replay
Parsing: replay-data/Whitera_replay_pack/d6.SC2Replay
Parsing: replay-data/Whitera_replay_pack/f4.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-04-26 - WhiteRa (P) vs SKMC (P) - Bel'Shir Vestige LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Antiga Shipyard (17).SC2Replay
Parsing: replay-data/Whitera_replay_pack/d7.SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-04-26 - WhiteRa (P) vs SKMC (P) - DH Star Station.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Antiga Shipyard (18).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Howling Peak (66).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-04-26 - WhiteRa (P) vs WWMCZSortOf (Z) - Bel'Shir Vestige LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Antiga Shipyard (19).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Korhal City (52).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Husky1.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Korhal City (53).SC2Replay
Parsing: replay-data/Whitera_replay_pack/2013-04-26 - WhiteRa (P) vs WWMCZSortOf (Z) - Whirlwind LE.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Macro pvz ).SC2Replay
Parsing: replay-data/Whitera_replay_pack/a1.SC2Replay
Parsing: replay-data/Whitera_replay_pack/Newkirk City (14).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Newkirk City (33).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Newkirk City (34).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Newkirk City (35).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Newkirk City (37).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Newkirk City (38).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Newkirk City (39).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Newkirk City (40).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Newkirk City (41).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Newkirk City (42).SC2Replay
Parsing: replay-data/Whitera_replay_pack/Star Station (73).SC2Replay
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.6
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.666666666667
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.666666666667
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.770833333333
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
1.0
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
1.0
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.505263157895
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.625
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.625
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.604166666667
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
1.0
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
1.0
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.473684210526
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.604166666667
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.541666666667
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.604166666667
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
1.0
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
1.0
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.536842105263
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.708333333333
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.75
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.770833333333
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
1.0
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
1.0
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.505263157895
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.625
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.666666666667
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.729166666667
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
1.0
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
1.0
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.6
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.75
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.666666666667
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
0.666666666667
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
1.0
Data read.
{'oob_score': False, 'random_state': None, 'min_samples_leaf': 1, 'max_features': None, 'criterion': 'gini', 'class_weight': None, 'bootstrap': True, 'warm_start': False, 'n_estimators': 10, 'min_weight_fraction_leaf': 0.0, 'min_samples_split': 2, 'verbose': 0, 'max_leaf_nodes': None, 'max_depth': None, 'n_jobs': 1}
1.0
[[0.59999999999999998, 0.66666666666666663, 0.66666666666666663, 0.77083333333333337, 1.0, 1.0], [0.50526315789473686, 0.625, 0.625, 0.60416666666666663, 1.0, 1.0], [0.47368421052631576, 0.60416666666666663, 0.54166666666666663, 0.60416666666666663, 1.0, 1.0], [0.5368421052631579, 0.70833333333333337, 0.75, 0.77083333333333337, 1.0, 1.0], [0.50526315789473686, 0.625, 0.66666666666666663, 0.72916666666666663, 1.0, 1.0], [0.59999999999999998, 0.75, 0.66666666666666663, 0.66666666666666663, 1.0, 1.0]]
%matplotlib inline
plt.contourf(minlabels, maxseconds, scores) # Dim: i, j, ixj
plt.colorbar()
plt.xlabel('Minimum number of games per player')
plt.ylabel('Max seconds taken into account')
plt.show()_____no_output_____
</code>


# Notebook from soumya-s3/platypus
Path: notebooks/ch-labs/Lab09_QuantumSimulationSearchAlgorithm.ipynb

# Lab 9 Quantum Simulation as a Search Algorithm_____no_output_____Prerequisites:
- [Ch.3.8 Grover's Algorithm](https://qiskit.org/textbook/ch-algorithms/grover.html)
- [Ch.2.5 Proving Universality](https://qiskit.org/textbook/ch-gates/proving-universality.html#2.2-Unitary-and-Hermitian-matrices-)

Other relevant materials:
- [Ch 6.2 in QCQI] Michael A. Nielsen and Isaac L. Chuang. Quantum Computation and Quantum Information, p255_____no_output_____

from qiskit import *
from qiskit.quantum_info import Statevector, partial_trace
from qiskit.visualization import plot_state_qsphere, plot_histogram

import numpy as np
import matplotlib.pyplot as plt
import scipy.linalg as la_____no_output_____sim = Aer.get_backend('qasm_simulator')_____no_output_____

Part 1: Hamiltonian Simulation

Goal

 In this lab, we consider changes to a quantum state veiwed as an evolution process generated by a given Hamiltonian. For a specified Hamiltonian, there is a corresponding unitary operator that determines the final state for any given initial state.

For an initial state, $|\psi(0)\rangle$ and a time independent Hamiltonian $H$ , the final state $|\psi(t)\rangle$ is $|\psi(t)\rangle = e^{-iHt}|\psi(0)\rangle$. Therefore, by constructing an appropriate gate for the unitary operator $e^{-iHt}$, we can build a quantum circuit that simulates the evolution of the quantum state $|\psi\rangle$._____no_output_____
1. Build a quantum circuit for a given Hamiltonian.
_____no_output_____When the hamiltonian $H$ and the initial state of the system, $|\psi(0)\rangle$, are given by

$H = |0\rangle\langle0| + |+\rangle\langle+|, ~~~~ |\psi(0)\rangle = |+\rangle = \frac{1}{\sqrt 2}(|0\rangle + |1\rangle)$.

Build the circuit with two qubits to evolve the state, $|\psi(0\rangle$, by $H$ for a time $\Delta t = \theta$, where the state of the system is encoded on the 0th qubit and the 1st qubit is an auxiliary.  Then, the final state $|\psi(\theta)\rangle$ is $|\psi(\theta)\rangle = e^{-i\theta ~ ( |0\rangle\langle0| ~ + ~ |+\rangle\langle+| )}~|\psi(0)\rangle$._____no_output_____
📓Step A. Show that the gate H1 from the following circuit performs the operation $e^{-i\frac{\pi}{9}|0\rangle\langle0|}$ on the 0th qubit when the state of the system is encoded on the 0th qubit and the 1st qubit, auxiliary, is set to the $|0\rangle$ state.
_____no_output_____

h1 = QuantumCircuit(2, name = 'H1')

h1.cnot(0, 1)
h1.p(np.pi/9, 1)
h1.cnot(0, 1)

H1 = h1.to_gate()

h1.draw()_____no_output_____

**Your Solution**:

_____no_output_____
📓Step B. Construct the gate H2 by completing the following code for the circuit `h2` to performs the operation $e^{-i\frac{\pi}{9}|+\rangle\langle+|}$ on the 0th qubit when the state of the system is encoded on the 0th qubit and the 1st qubit, auxiliary, is set to the $|0\rangle$ state.
_____no_output_____

h2 = QuantumCircuit(2, name='H2')

#### Your code goes here ###

#############################

H2 = h2.to_gate()

h2.draw()_____no_output_____

2. Execute the cell below to generate the state of the 0th qubit after every iteration._____no_output_____The circuit performs $(H1H2)^7|+\rangle = (~ e^{-i\frac{\pi}{9} ~ |0\rangle\langle0|}e^{-i\frac{\pi}{9}~|+\rangle\langle+|} ~)^7~|+\rangle$ on the 0th qubit.  The state of the 0th qubit after each `H1H2` operation is stored in the list variable 'myst'._____no_output_____

from qiskit.quantum_info import Statevector, partial_trace

def st_out(qc):
    out = Statevector.from_instruction(qc)
    out_red = partial_trace(out, [1])
    prob, st_all = la.eig(out_red.data)
    cond = (prob>0.99) & (prob<1.01)
    st = st_all[:, cond].ravel()

    return(st)

myst = []

circ = QuantumCircuit(2)
circ.h(0)
st = st_out(circ)
myst.append(Statevector(st))

for _ in range(7):
    circ.append(H1, range(2))
    circ.append(H2, range(2))
    st = st_out(circ)
    myst.append(Statevector(st))

circ.draw() _____no_output_____

The following Bloch sphere picture shows the evolution of the 0th qubit state. As it shows, the state starts from the $|+\rangle$ state rotate toward to and passes the $|0\rangle$ state.  Therefore, with appropriate the angle of the `H1` and `H2` operations, $|+\rangle$ state evolves to $|0\rangle$ state by applying $H1H2 = e^{-i\theta ~ |0\rangle\langle0|}e^{-i\theta~|+\rangle\langle+|}$ proper number of times. _____no_output__________no_output_____If you have installed `kaleidoscope` or run this lab on [IQX](https://quantum-computing.ibm.com), you can excute the cell below to visualize the state evolution through the interactive bloch sphere. _____no_output_____

from kaleidoscope import bloch_sphere
from matplotlib.colors import LinearSegmentedColormap, rgb2hex

cm = LinearSegmentedColormap.from_list('graypurple', ["#999999", "#AA00FF"])
vectors_color = [rgb2hex(cm(kk)) for kk in np.linspace(-1,1,len(myst))]
bloch_sphere(myst, vectors_color = vectors_color)_____no_output_____

Part 2: Quantum Search as a Quantum Simulation

Goal

 In this part of the lab, we solve a search problem through quantum simulation.

In Part1, we showed that the Hamiltonian, $H$, transforms the state, $|\psi_i\rangle$,  to $|\psi_j\rangle$ when its structure depends on both states as $ H =|\psi_j\rangle\langle\psi_j| + |\psi_i\rangle\langle\psi_i| $ with a proper time duration.

Considering a search problem with a unique solution, we should be able to find the solution with the form of the Hamiltonian, $ H = |x\rangle\langle x| + |\psi\rangle\langle\psi|, $ when all possible items are encoded in a superposition state $|\psi\rangle$ and given as the initial state, same as in Grover's algorithm, while $|x\rangle$ represents the unknown solution.

Applying the unitary operator, $U = e^{-iH\Delta t}$ on the initial state, $|\psi\rangle$, right number of times with the properly chosen $\Delta t$, should evolve the state $|\psi\rangle$ into the solution $|x\rangle$ or close enough to it. The following code constructs the oracle gate for the search problem.  Execute the cell below. _____no_output_____

n = 5
qc = QuantumCircuit(n+1, name='Oracle')
qc.mct(list(range(n)), n)

Oracle = qc.to_gate()_____no_output_____

The following circuit encodes the phase $\pi$ on the solution state and zero on the other items through phase kickback with the 5th qubit as an auxiliary. Therefore, the output state of the circuit is $(|\psi\rangle - |x\rangle) + e^{i\pi}|x\rangle$, which can be confirmed visually using a qsphere plot where the color indicates the phase of each basis state. Run the following two cells. _____no_output_____

test = QuantumCircuit(n+1)
test.x(n)
test.h(range(n+1))
test.append(Oracle, range(n+1))
test.h(n)

test.draw()_____no_output_____st = Statevector.from_instruction(test)
st_red = partial_trace(st, [5])

plot_state_qsphere(st_red)_____no_output_____

1. Construct a circuit to approximate the Hamiltonian, $H = |x\rangle\langle x| + |\psi\rangle\langle\psi|$, when all possible items are encoded in a superposition state $|\psi\rangle$ and given as the initial state while $|x\rangle$ represents the unique unknown solution.
_____no_output_____As we did in the Part1, we build the circuit for the simulation with the Hamiltonian, but with more qubits to examine all the items in the question. Regrad the search problem having one solution out of 32 items.  _____no_output_____
📓Step A. Construct the gate H1 performing the operation $e^{-i\Delta t|\psi\rangle\langle\psi|}$ by completing the following code.
_____no_output_____

def H1(delt, n=5):

    h1 = QuantumCircuit(n+1, name='H1')

    #### Your code goes here ######

    ###############################

    return h1.to_gate()_____no_output_____

📓Step B. Construct the gate H2 performing the operation $e^{-i\Delta t|x\rangle\langle x|}$ by completing the following code.
_____no_output_____

def H2(delt, n=5):

    h2 = QuantumCircuit(n+1, name='H2')

    #### Your code goes here ######

    ###############################

    return h2.to_gate()_____no_output_____

📓Step C. Create the circuit, 'sim_h', to compute $e^{-i \pi H_{app}}|\psi\rangle = (~e^{-i\pi~|x\rangle\langle x|}e^{-i\pi~|\psi\rangle\langle\psi|}~)|\psi\rangle $ which evolves the state $|\psi\rangle$ under the Hamiltonian $H = |x\rangle\langle x| + |\psi\rangle\langle\psi|$ approximately over the time duration $\Delta t = \pi$.
_____no_output_____Th state $|\psi\rangle$ represents the superposition state of all possible items.

Utilize the gates `H1` and `H2`. _____no_output_____

#### Your code goes here ####

############

sim_h.draw()_____no_output_____

2. Show that the search problem can be solved through quantum simulation with  $H_{appr}$ by verifying the two operations, Grover's algorithm and $U = e^{-i\Delta t~H_{appr}}$ with $\Delta t = \pi$, are equivalent.
_____no_output_____
Step A. The following circuit, `grover`, runs the Grover's algorithm for the problem to find a solution for the oracle that we built above. Run the cell below.
 _____no_output_____

qc = QuantumCircuit(n+1, name='Amp')
qc.h(range(n))
qc.x(range(n))
qc.mct(list(range(n)), n)
qc.x(range(n))
qc.h(range(n))

Amp = qc.to_gate()

grover = QuantumCircuit(n+1)
grover.x(n)
grover.h(range(n+1))
grover.append(Oracle, range(n+1))
grover.append(Amp, range(n+1))
grover.h(n)
grover.x(n)

grover.draw()_____no_output_____

Step B. Upon executing the cells below, the result shows that the circuits, 'grover' and 'sim_h' are identical up to a global phase.
_____no_output_____

st_simh = Statevector.from_instruction(sim_h)
st_grover = Statevector.from_instruction(grover)
print('grover circuit and sim_h circuit genrate the same output state: ' ,st_simh == st_grover)_____no_output_____plot_state_qsphere(st_simh)_____no_output_____plot_state_qsphere(st_grover)_____no_output_____

📓Step C. Find the number of the Grover interations, R, needed to find the solutions of the Oracle that we built.
_____no_output_____

#### your code goes here ####

######
print(R)_____no_output_____

Step D. Find the solution to the serach problem, for the Oracle that we built,  through Grover's algorithm and the simulation computing $e^{-i R\pi H_{app}}|\psi\rangle = (~e^{-i\pi~|x\rangle\langle x|}e^{-i\pi~|\psi\rangle\langle\psi|}~)^R|\psi\rangle $ where R is the number of iterations.
_____no_output_____

## The circuit to solve the search problem through Grover's algorithm.
n = 5

qc_grover = QuantumCircuit(n+1, n)
qc_grover.x(n)
qc_grover.h(range(n+1))
for _ in range(int(R)):
    qc_grover.append(Oracle, range(n+1))
    qc_grover.append(Amp, range(n+1))

qc_grover.h(n)
qc_grover.x(n)
qc_grover.barrier()
qc_grover.measure(range(n), range(n))

qc_grover.draw()_____no_output_____

📓 Complete the code to build the circuit, `qc_sim`,  to solve the search problem through the simulation._____no_output_____

qc_sim = QuantumCircuit(n+1, n)
qc_sim.h(range(n))

#### Your code goes here ####

_____no_output_____

Run the following cell to simulate both circuits, `qc_grover` and `qc_sim` and compare their solutions._____no_output_____

counts = execute([qc_grover, qc_sim], sim).result().get_counts()
plot_histogram(counts, legend=['Grover', 'Hamiltonian'])_____no_output_____

3. The following result shows an example where the solution can be found with probability exactly equal to one through quantum simulation by the choosing the proper time duration $\Delta t$.
_____no_output_____

n = 5

qc = QuantumCircuit(n+1, n)
qc.h(range(n))

delt, R = np.pi/2.1, 6

for _ in range(int(R)):
    qc.append(H1(delt), range(n+1))
    qc.append(H2(delt), range(n+1))

qc.measure(range(n) ,range(n))
qc.draw()_____no_output_____count = execute(qc, sim).result().get_counts()
plot_histogram(count)_____no_output_____