This notebook shows a traing process of Parallel Random Forest. For cluster training please check https://github.com/wasit7/parallel_forest
Import all necessary modules
In [1]:
import numpy as np
from matplotlib import pyplot as plt
import pickle
import os
%pylab inline
Populating the interactive namespace from numpy and matplotlib
In [2]:
clmax=5
spc=5e2
theta_range=2
#samples is list of labels
samples=np.zeros(spc*clmax,dtype=np.uint32)
#I is fessture vector
I=np.zeros((spc*clmax,theta_range),dtype=np.float32)
marker=['bo','co','go','ro','mo','yo','ko',
'bs','cs','gs','rs','ms','ys','ks']
# number of datasets being generated
# 8 for training
# another one for evaluation
N=9
path="train/"
if not os.path.exists(path):
os.makedirs(path)
for n in xrange(N):
for cl in xrange(clmax):
xo=cl*spc
#define label
samples[xo:xo+spc]=cl
phi = np.linspace(0, 2*np.pi, spc) + \
np.random.randn(spc)*0.4*np.pi/clmax + \
2*np.pi*cl/clmax
r = np.linspace(0.1, 1, spc)
I[xo:xo+spc,:]=np.transpose(np.array([r*np.cos(phi), r*np.sin(phi)]))
with open(path+'dataset%02d.pic'%(n), 'wb') as pickleFile:
#write label and feature vector
theta_dim=1
pickle.dump((clmax,theta_dim,theta_range,len(samples),samples,I,None), pickleFile, pickle.HIGHEST_PROTOCOL)
In [3]:
z=np.random.randint( 0,spc*clmax,1000)
for i in z:
#ax.plot(dset.I[i,0],dset.I[i,1],marker[dset2.samples[i]])
plt.plot(I[i,0],I[i,1],marker[samples[i]])
plt.hold(True)
In [4]:
from pforest.master import master
m=master()
m.reset()
m.train()
master>>init() dsetname: dataset
master>> create dview
master>> init engine
Found pforest
debug:master:__init__: ['train/dataset00.pic', 'train/dataset01.pic', 'train/dataset02.pic', 'train/dataset03.pic', 'train/dataset04.pic', 'train/dataset05.pic', 'train/dataset06.pic', 'train/dataset07.pic']
master>> init local variables
master>>reset()
master>>reset() H: 2.3219
master>>reset() Q: 20000
master::train() node20*-
master::train() node19R-
master::train() node18R-
master::train() node17R-
master::train() node16RQ
master::train() node16L-
master::train() node15R-
master::train() node14R-
master::train() node13R-
master::train() node12RQ
master::train() node12L-
master::train() node11RQ
master::train() node11LG
master::train() node13LQ
master::train() node14LQ
master::train() node15LQ
master::train() node17L-
master::train() node16R-
master::train() node15RQ
master::train() node15L-
master::train() node14RQ
master::train() node14L-
master::train() node13R-
master::train() node12RQ
master::train() node12L-
master::train() node11R-
master::train() node10RG
master::train() node10LQ
master::train() node11LQ
master::train() node13LQ
master::train() node16LQ
master::train() node18L-
master::train() node17R-
master::train() node16R-
master::train() node15RQ
master::train() node15L-
master::train() node14RQ
master::train() node14L-
master::train() node13R-
master::train() node12RQ
master::train() node12L-
master::train() node11R-
master::train() node10RQ
master::train() node10LQ
master::train() node11LQ
master::train() node13LQ
master::train() node16L-
master::train() node15RQ
master::train() node15L-
master::train() node14R-
master::train() node13RQ
master::train() node13L-
master::train() node12R-
master::train() node11R-
master::train() node10RG
master::train() node10LQ
master::train() node11LQ
master::train() node12LQ
master::train() node14LQ
master::train() node17L-
master::train() node16R-
master::train() node15R-
master::train() node14R-
master::train() node13RQ
master::train() node13L-
master::train() node12RQ
master::train() node12L-
master::train() node11R-
master::train() node10R-
master::train() node9RQ
master::train() node9L-
master::train() node8RQ
master::train() node8L-
master::train() node7RQ
master::train() node7LG
master::train() node10LQ
master::train() node11LQ
master::train() node14L-
master::train() node13RQ
master::train() node13L-
master::train() node12R-
master::train() node11RQ
master::train() node11L-
master::train() node10R-
master::train() node9RQ
master::train() node9L-
master::train() node8RG
master::train() node8LQ
master::train() node10LQ
master::train() node12LQ
master::train() node15L-
master::train() node14RQ
master::train() node14L-
master::train() node13RQ
master::train() node13LQ
master::train() node16L-
master::train() node15R-
master::train() node14R-
master::train() node13R-
master::train() node12RQ
master::train() node12L-
master::train() node11R-
master::train() node10RQ
master::train() node10L-
master::train() node9R-
master::train() node8RG
master::train() node8LQ
master::train() node9LQ
master::train() node11LQ
master::train() node13L-
master::train() node12RQ
master::train() node12L-
master::train() node11R-
master::train() node10R-
master::train() node9R-
master::train() node8RQ
master::train() node8L-
master::train() node7RQ
master::train() node7L-
master::train() node6R-
master::train() node5R-
master::train() node4RQ
master::train() node4LG
master::train() node5LQ
master::train() node6LQ
master::train() node9LQ
master::train() node10LQ
master::train() node11LQ
master::train() node14L-
master::train() node13RQ
master::train() node13LQ
master::train() node15L-
master::train() node14R-
master::train() node13R-
master::train() node12R-
master::train() node11RQ
master::train() node11L-
master::train() node10RQ
master::train() node10L-
master::train() node9R-
master::train() node8RG
master::train() node8LQ
master::train() node9LQ
master::train() node12L-
master::train() node11R-
master::train() node10R-
master::train() node9RQ
master::train() node9L-
master::train() node8R-
master::train() node7RQ
master::train() node7L-
master::train() node6R-
master::train() node5R-
master::train() node4RG
master::train() node4LQ
master::train() node5LQ
master::train() node6LQ
master::train() node8LQ
master::train() node10LQ
master::train() node11L-
master::train() node10R-
master::train() node9RQ
master::train() node9L-
master::train() node8R-
master::train() node7RQ
master::train() node7LQ
master::train() node8LQ
master::train() node10LQ
master::train() node13L-
master::train() node12R-
master::train() node11R-
master::train() node10R-
master::train() node9R-
master::train() node8R-
master::train() node7RQ
master::train() node7L-
master::train() node6RQ
master::train() node6LG
master::train() node8LQ
master::train() node9L-
master::train() node8RQ
master::train() node8LQ
master::train() node10L-
master::train() node9R-
master::train() node8RQ
master::train() node8L-
master::train() node7R-
master::train() node6RG
master::train() node6LQ
master::train() node7LQ
master::train() node9LQ
master::train() node11L-
master::train() node10RQ
master::train() node10L-
master::train() node9RG
master::train() node9LQ
master::train() node12L-
master::train() node11R-
master::train() node10R-
master::train() node9RQ
master::train() node9L-
master::train() node8R-
master::train() node7RQ
master::train() node7L-
master::train() node6R-
master::train() node5RG
master::train() node5LQ
master::train() node6LQ
master::train() node8LQ
master::train() node10LQ
master::train() node11L-
master::train() node10RQ
master::train() node10L-
master::train() node9R-
master::train() node8R-
master::train() node7RQ
master::train() node7L-
master::train() node6RG
master::train() node6LQ
master::train() node8LQ
master::train() node9LQ
master::train() node14L-
master::train() node13R-
master::train() node12R-
master::train() node11RQ
master::train() node11L-
master::train() node10R-
master::train() node9RQ
master::train() node9LG
master::train() node10LQ
master::train() node12LQ
master::train() node13L-
master::train() node12R-
master::train() node11R-
master::train() node10RQ
master::train() node10L-
master::train() node9R-
master::train() node8RQ
master::train() node8LG
master::train() node9LQ
master::train() node11LQ
master::train() node12L-
master::train() node11R-
master::train() node10R-
master::train() node9RQ
master::train() node9LG
master::train() node10LQ
master::train() node11LQ
master::train() node19L-
master::train() node18R-
master::train() node17R-
master::train() node16R-
master::train() node15RQ
master::train() node15L-
master::train() node14R-
master::train() node13RQ
master::train() node13L-
master::train() node12R-
master::train() node11R-
master::train() node10RQ
master::train() node10L-
master::train() node9RQ
master::train() node9LG
master::train() node11LQ
master::train() node12LQ
master::train() node14LQ
master::train() node16LQ
master::train() node17LQ
master::train() node18L-
master::train() node17R-
master::train() node16R-
master::train() node15RQ
master::train() node15L-
master::train() node14RQ
master::train() node14LG
master::train() node16LQ
master::train() node17L-
master::train() node16RQ
master::train() node16LQ
In [5]:
with open('out_tree.pic', 'wb') as pickleFile:
pickle.dump(m.root, pickleFile, pickle.HIGHEST_PROTOCOL)
with open('out_tree.pic', 'rb') as pickleFile:
root = pickle.load(pickleFile)
In [6]:
ls
Volume in drive C has no label.
Volume Serial Number is A8BF-C894
Directory of C:\Users\Wasit\Documents\GitHub\parallel_forest\nb
26/02/2016 11:31 <DIR> .
26/02/2016 11:31 <DIR> ..
11/02/2016 15:34 <DIR> .ipynb_checkpoints
07/12/2015 15:20 <DIR> dataset
26/02/2016 11:38 57,821 out_tree.pic
09/12/2015 15:47 167,942 parallel forest.ipynb
06/02/2016 20:23 16 run.bat
07/12/2015 15:20 <DIR> train
11/02/2016 15:34 78 Untitled.ipynb
4 File(s) 225,857 bytes
5 Dir(s) 91,810,349,056 bytes free
In [7]:
from pforest.dataset import dataset
from pforest.tree import tree
#init the test tree
t=tree()
t.settree(root)
t.show()
Found pforest
*- 20 H:2.322e+00,Q:020000 tau:-0.468381792307 theta:[ 1.]
L- 19 H:1.836e+00,Q:003015 tau:-0.701480388641 theta:[ 1.]
L- 18 H:1.108e+00,Q:001198 tau:-0.833405137062 theta:[ 1.]
L- 17 H:2.396e-01,Q:000451 tau:-0.870379090309 theta:[ 1.]
LQ 16 H:7.171e-02,Q:000358 (cl,P):(004,0.99) (003,0.01) (000,0.00)
RQ 16 H:5.149e-01,Q:000093 (cl,P):(004,0.84) (000,0.16) (003,0.00)
R- 17 H:9.473e-01,Q:000747 tau:-0.20331299305 theta:[ 0.]
LQ 16 H:8.995e-01,Q:000206 (cl,P):(004,0.80) (000,0.12) (003,0.09)
R- 16 H:1.698e-01,Q:000541 tau:0.485575705767 theta:[ 0.]
L- 15 H:1.536e-02,Q:000491 tau:-0.707981348038 theta:[ 1.]
LG 14 H:1.042e-37,Q:000476 (cl,P):(000,1.00) (004,0.00) (003,0.00)
RQ 14 H:2.163e-01,Q:000015 (cl,P):(000,0.93) (001,0.07) (004,0.00)
RQ 15 H:7.330e-01,Q:000050 (cl,P):(000,0.72) (004,0.28) (003,0.00)
R- 18 H:1.768e+00,Q:001817 tau:-0.457401335239 theta:[ 0.]
LQ 17 H:1.217e+00,Q:000333 (cl,P):(004,0.63) (003,0.28) (000,0.09)
R- 17 H:1.193e+00,Q:001484 tau:-0.247364670038 theta:[ 0.]
LQ 16 H:5.709e-01,Q:000283 (cl,P):(000,0.88) (001,0.10) (004,0.02)
R- 16 H:1.089e+00,Q:001201 tau:0.518829584122 theta:[ 0.]
L- 15 H:7.824e-01,Q:000927 tau:-0.667695939541 theta:[ 1.]
LQ 14 H:5.073e-01,Q:000078 (cl,P):(000,0.87) (001,0.13) (004,0.00)
R- 14 H:5.399e-01,Q:000849 tau:-0.512303173542 theta:[ 1.]
L- 13 H:2.641e-01,Q:000690 tau:-0.162528783083 theta:[ 0.]
LQ 12 H:8.363e-01,Q:000055 (cl,P):(001,0.67) (000,0.33) (004,0.00)
R- 12 H:1.325e-01,Q:000635 tau:-0.630093455315 theta:[ 1.]
LQ 11 H:3.942e-01,Q:000093 (cl,P):(001,0.90) (000,0.10) (004,0.00)
R- 11 H:4.169e-02,Q:000542 tau:-0.535420060158 theta:[ 1.]
L- 10 H:1.545e-02,Q:000478 tau:0.46362811327 theta:[ 0.]
LG 09 H:1.083e-37,Q:000458 (cl,P):(001,1.00) (004,0.00) (003,0.00)
RQ 09 H:1.000e-01,Q:000020 (cl,P):(001,0.95) (000,0.05) (004,0.00)
RQ 10 H:1.488e-01,Q:000064 (cl,P):(001,0.97) (002,0.03) (004,0.00)
RQ 13 H:9.010e-01,Q:000159 (cl,P):(001,0.68) (002,0.32) (004,0.00)
RQ 15 H:7.084e-01,Q:000274 (cl,P):(000,0.82) (001,0.18) (004,0.01)
R- 19 H:2.310e+00,Q:016985 tau:0.561077535152 theta:[ 0.]
L- 18 H:2.292e+00,Q:015028 tau:0.578972876072 theta:[ 1.]
L- 17 H:2.297e+00,Q:013092 tau:0.213422596455 theta:[ 0.]
L- 16 H:2.308e+00,Q:010246 tau:0.227328822017 theta:[ 1.]
L- 15 H:2.307e+00,Q:007710 tau:-0.481972843409 theta:[ 0.]
L- 14 H:1.600e+00,Q:001697 tau:-0.648903012276 theta:[ 0.]
L- 13 H:1.064e+00,Q:001016 tau:-0.824315488338 theta:[ 0.]
L- 12 H:1.096e-01,Q:000443 tau:-0.968888700008 theta:[ 0.]
LQ 11 H:6.141e-01,Q:000011 (cl,P):(003,0.64) (002,0.36) (004,0.00)
R- 11 H:4.962e-02,Q:000432 tau:-0.953859329224 theta:[ 0.]
LQ 10 H:2.893e-01,Q:000022 (cl,P):(003,0.91) (002,0.09) (004,0.00)
R- 10 H:1.732e-02,Q:000410 tau:-0.840804040432 theta:[ 0.]
LG 09 H:1.299e-37,Q:000381 (cl,P):(003,1.00) (004,0.00) (002,0.00)
RQ 09 H:6.897e-02,Q:000029 (cl,P):(003,0.97) (004,0.03) (002,0.00)
R- 12 H:2.589e-01,Q:000573 tau:-0.784686982632 theta:[ 0.]
LQ 11 H:8.847e-01,Q:000043 (cl,P):(004,0.63) (003,0.37) (002,0.00)
R- 11 H:9.536e-02,Q:000530 tau:-0.659810006618 theta:[ 0.]
L- 10 H:5.561e-02,Q:000497 tau:-0.764644563198 theta:[ 0.]
LQ 09 H:2.244e-01,Q:000045 (cl,P):(004,0.93) (003,0.07) (002,0.00)
R- 09 H:1.618e-02,Q:000452 tau:-0.672862946987 theta:[ 0.]
LG 08 H:1.226e-37,Q:000404 (cl,P):(004,1.00) (003,0.00) (002,0.00)
RQ 08 H:9.436e-02,Q:000048 (cl,P):(004,0.98) (000,0.02) (003,0.00)
RQ 10 H:3.171e-01,Q:000033 (cl,P):(004,0.91) (000,0.09) (003,0.00)
R- 13 H:3.876e-01,Q:000681 tau:-0.594174087048 theta:[ 0.]
LQ 12 H:9.454e-01,Q:000113 (cl,P):(000,0.61) (004,0.39) (003,0.00)
R- 12 H:1.033e-01,Q:000568 tau:0.142151668668 theta:[ 1.]
L- 11 H:2.889e-02,Q:000519 tau:-0.414594262838 theta:[ 1.]
LQ 10 H:1.148e-01,Q:000024 (cl,P):(000,0.96) (004,0.04) (003,0.00)
R- 10 H:1.492e-02,Q:000495 tau:-0.498673021793 theta:[ 0.]
LG 09 H:1.099e-37,Q:000451 (cl,P):(000,1.00) (004,0.00) (003,0.00)
RQ 09 H:9.883e-02,Q:000044 (cl,P):(000,0.98) (001,0.02) (004,0.00)
RQ 11 H:4.324e-01,Q:000049 (cl,P):(000,0.88) (004,0.12) (003,0.00)
R- 14 H:2.206e+00,Q:006013 tau:-0.0422190986574 theta:[ 1.]
L- 13 H:2.016e+00,Q:003412 tau:-0.116425700486 theta:[ 0.]
L- 12 H:1.342e+00,Q:001396 tau:-0.262941837311 theta:[ 0.]
L- 11 H:6.895e-01,Q:000669 tau:-0.302038580179 theta:[ 0.]
L- 10 H:4.252e-01,Q:000561 tau:-0.393153131008 theta:[ 1.]
LQ 09 H:9.241e-01,Q:000067 (cl,P):(001,0.51) (000,0.49) (004,0.00)
R- 09 H:1.710e-01,Q:000494 tau:-0.428557306528 theta:[ 0.]
LQ 08 H:5.659e-01,Q:000048 (cl,P):(001,0.81) (000,0.19) (004,0.00)
R- 08 H:6.564e-02,Q:000446 tau:-0.321455299854 theta:[ 0.]
L- 07 H:1.833e-02,Q:000399 tau:-0.329221338034 theta:[ 1.]
LQ 06 H:8.875e-02,Q:000049 (cl,P):(001,0.98) (000,0.02) (004,0.00)
RG 06 H:1.413e-37,Q:000350 (cl,P):(001,1.00) (004,0.00) (003,0.00)
RQ 07 H:2.453e-01,Q:000047 (cl,P):(001,0.94) (002,0.06) (004,0.00)
RQ 10 H:9.213e-01,Q:000108 (cl,P):(001,0.59) (002,0.41) (004,0.00)
R- 11 H:7.163e-01,Q:000727 tau:-0.406929314137 theta:[ 1.]
LQ 10 H:3.358e-01,Q:000049 (cl,P):(001,0.92) (002,0.08) (004,0.00)
R- 10 H:4.668e-01,Q:000678 tau:-0.139413490891 theta:[ 0.]
L- 09 H:1.983e-01,Q:000587 tau:-0.361614644527 theta:[ 1.]
LQ 08 H:7.925e-01,Q:000018 (cl,P):(002,0.56) (001,0.44) (004,0.00)
R- 08 H:1.126e-01,Q:000569 tau:-0.170809790492 theta:[ 0.]
L- 07 H:3.031e-02,Q:000480 tau:-0.299496382475 theta:[ 1.]
LQ 06 H:6.061e-02,Q:000033 (cl,P):(002,0.97) (001,0.03) (004,0.00)
R- 06 H:1.589e-02,Q:000447 tau:-0.257146418095 theta:[ 0.]
LQ 05 H:2.123e-01,Q:000017 (cl,P):(002,0.94) (001,0.06) (004,0.00)
RG 05 H:1.152e-37,Q:000430 (cl,P):(002,1.00) (004,0.00) (003,0.00)
RQ 07 H:3.516e-01,Q:000089 (cl,P):(002,0.92) (003,0.08) (004,0.00)
RQ 09 H:9.463e-01,Q:000091 (cl,P):(002,0.55) (003,0.45) (004,0.00)
R- 12 H:1.514e+00,Q:002016 tau:-0.313962757587 theta:[ 1.]
L- 11 H:3.273e-01,Q:000457 tau:-0.340876668692 theta:[ 1.]
L- 10 H:1.711e-02,Q:000408 tau:-0.0995360389352 theta:[ 0.]
LQ 09 H:1.312e-01,Q:000021 (cl,P):(002,0.95) (001,0.05) (004,0.00)
RG 09 H:1.279e-37,Q:000387 (cl,P):(002,1.00) (004,0.00) (003,0.00)
RQ 10 H:8.491e-01,Q:000049 (cl,P):(003,0.55) (002,0.45) (004,0.00)
R- 11 H:1.029e+00,Q:001559 tau:-0.181801304221 theta:[ 1.]
L- 10 H:1.655e-01,Q:000617 tau:-0.0817341506481 theta:[ 0.]
LQ 09 H:7.754e-01,Q:000030 (cl,P):(003,0.63) (002,0.37) (004,0.00)
R- 09 H:5.224e-02,Q:000587 tau:-0.199228107929 theta:[ 1.]
L- 08 H:2.840e-02,Q:000524 tau:-0.0798655077815 theta:[ 0.]
LQ 07 H:5.924e-36,Q:000002 (cl,P):(003,0.50) (002,0.50) (004,0.00)
R- 07 H:1.436e-02,Q:000522 tau:0.00809505488724 theta:[ 0.]
LQ 06 H:4.381e-02,Q:000129 (cl,P):(003,0.99) (002,0.01) (004,0.00)
RG 06 H:1.260e-37,Q:000393 (cl,P):(003,1.00) (004,0.00) (002,0.00)
RQ 08 H:1.489e-01,Q:000063 (cl,P):(003,0.97) (004,0.03) (002,0.00)
R- 10 H:9.961e-01,Q:000942 tau:0.029154304415 theta:[ 0.]
L- 09 H:5.178e-01,Q:000414 tau:-0.0364557094872 theta:[ 0.]
LQ 08 H:1.467e-37,Q:000337 (cl,P):(003,1.00) (004,0.00) (002,0.00)
RQ 08 H:9.232e-01,Q:000077 (cl,P):(004,0.64) (003,0.36) (002,0.00)
R- 09 H:1.199e-01,Q:000528 tau:-0.145697489381 theta:[ 1.]
LQ 08 H:3.477e-01,Q:000062 (cl,P):(004,0.92) (003,0.08) (002,0.00)
R- 08 H:5.793e-02,Q:000466 tau:-0.0571762435138 theta:[ 1.]
L- 07 H:1.630e-02,Q:000444 tau:-0.0785559415817 theta:[ 1.]
LG 06 H:1.266e-37,Q:000391 (cl,P):(004,1.00) (003,0.00) (002,0.00)
RQ 06 H:7.815e-02,Q:000053 (cl,P):(004,0.98) (000,0.02) (003,0.00)
RQ 07 H:3.636e-01,Q:000022 (cl,P):(004,0.86) (000,0.14) (003,0.00)
R- 13 H:1.567e+00,Q:002601 tau:0.0988777726889 theta:[ 0.]
L- 12 H:1.289e+00,Q:001946 tau:0.0942792221904 theta:[ 1.]
L- 11 H:1.099e+00,Q:000791 tau:-0.253261834383 theta:[ 0.]
LQ 10 H:2.883e-01,Q:000248 (cl,P):(001,0.95) (000,0.03) (002,0.02)
R- 10 H:4.241e-01,Q:000543 tau:-0.0754166916013 theta:[ 0.]
L- 09 H:1.929e-01,Q:000506 tau:-0.0149569595233 theta:[ 1.]
LQ 08 H:4.989e-01,Q:000072 (cl,P):(002,0.88) (003,0.12) (004,0.00)
R- 08 H:7.825e-02,Q:000434 tau:-0.186543479562 theta:[ 0.]
LQ 07 H:2.259e-01,Q:000097 (cl,P):(002,0.95) (001,0.05) (004,0.00)
RQ 07 H:1.467e-37,Q:000337 (cl,P):(002,1.00) (004,0.00) (003,0.00)
RQ 09 H:1.298e+00,Q:000037 (cl,P):(002,0.41) (001,0.38) (000,0.22)
R- 11 H:7.172e-01,Q:001155 tau:-0.378425836563 theta:[ 0.]
LQ 10 H:1.372e-01,Q:000120 (cl,P):(000,0.97) (001,0.03) (004,0.00)
R- 10 H:4.216e-01,Q:001035 tau:0.0607046075165 theta:[ 0.]
L- 09 H:2.813e-01,Q:000993 tau:0.112345091999 theta:[ 1.]
LQ 08 H:5.387e-01,Q:000133 (cl,P):(001,0.86) (002,0.14) (004,0.00)
R- 08 H:1.817e-01,Q:000860 tau:0.183188080788 theta:[ 1.]
L- 07 H:3.792e-02,Q:000607 tau:-0.339386373758 theta:[ 0.]
LQ 06 H:1.667e-01,Q:000012 (cl,P):(001,0.92) (000,0.08) (004,0.00)
R- 06 H:2.585e-02,Q:000595 tau:0.121004834771 theta:[ 1.]
LQ 05 H:8.812e-02,Q:000047 (cl,P):(001,0.98) (002,0.02) (004,0.00)
R- 05 H:1.372e-02,Q:000548 tau:0.140320837498 theta:[ 1.]
LQ 04 H:3.623e-02,Q:000156 (cl,P):(001,0.99) (002,0.01) (004,0.00)
RG 04 H:1.263e-37,Q:000392 (cl,P):(001,1.00) (004,0.00) (003,0.00)
RQ 07 H:3.863e-01,Q:000253 (cl,P):(001,0.92) (000,0.08) (004,0.00)
RQ 09 H:7.177e-01,Q:000042 (cl,P):(000,0.76) (001,0.24) (004,0.00)
R- 12 H:1.384e-01,Q:000655 tau:0.202046751976 theta:[ 0.]
L- 11 H:6.951e-02,Q:000642 tau:0.187701240182 theta:[ 0.]
L- 10 H:2.538e-02,Q:000609 tau:0.0107562718913 theta:[ 1.]
LQ 09 H:5.283e-02,Q:000094 (cl,P):(000,0.99) (004,0.01) (003,0.00)
R- 09 H:1.443e-02,Q:000515 tau:0.111956737936 theta:[ 0.]
LQ 08 H:5.231e-02,Q:000069 (cl,P):(000,0.99) (001,0.01) (004,0.00)
RG 08 H:1.112e-37,Q:000446 (cl,P):(000,1.00) (004,0.00) (003,0.00)
RQ 10 H:2.653e-01,Q:000033 (cl,P):(000,0.88) (004,0.12) (003,0.00)
RQ 11 H:6.811e-01,Q:000013 (cl,P):(004,0.54) (000,0.46) (003,0.00)
R- 15 H:1.687e+00,Q:002536 tau:-0.524926066399 theta:[ 0.]
L- 14 H:1.279e+00,Q:000561 tau:-0.701210737228 theta:[ 0.]
LQ 13 H:8.256e-01,Q:000238 (cl,P):(003,0.76) (002,0.24) (004,0.01)
RQ 13 H:9.956e-01,Q:000323 (cl,P):(003,0.50) (004,0.50) (002,0.00)
R- 14 H:1.257e+00,Q:001975 tau:0.399609148502 theta:[ 1.]
L- 13 H:7.479e-01,Q:001136 tau:0.147129222751 theta:[ 0.]
L- 12 H:5.996e-01,Q:001053 tau:-0.4568118155 theta:[ 0.]
LQ 11 H:4.751e-01,Q:000049 (cl,P):(004,0.82) (000,0.18) (003,0.00)
R- 11 H:4.519e-01,Q:001004 tau:0.263233065605 theta:[ 1.]
LQ 10 H:6.873e-01,Q:000202 (cl,P):(000,0.79) (001,0.21) (004,0.00)
R- 10 H:2.608e-01,Q:000802 tau:-0.376489371061 theta:[ 0.]
LQ 09 H:7.733e-01,Q:000049 (cl,P):(000,0.63) (004,0.37) (003,0.00)
R- 09 H:1.560e-01,Q:000753 tau:0.0765360891819 theta:[ 0.]
L- 08 H:5.727e-02,Q:000688 tau:0.386741638184 theta:[ 1.]
L- 07 H:3.579e-02,Q:000660 tau:0.27084249258 theta:[ 1.]
LQ 06 H:2.203e-36,Q:000019 (cl,P):(000,0.95) (001,0.05) (004,0.00)
R- 06 H:2.443e-02,Q:000641 tau:0.292202949524 theta:[ 1.]
LQ 05 H:4.984e-02,Q:000097 (cl,P):(000,0.99) (001,0.01) (004,0.00)
R- 05 H:1.390e-02,Q:000544 tau:0.012537621893 theta:[ 0.]
LG 04 H:1.040e-37,Q:000477 (cl,P):(000,1.00) (004,0.00) (003,0.00)
RQ 04 H:5.388e-02,Q:000067 (cl,P):(000,0.99) (004,0.01) (003,0.00)
RQ 07 H:2.143e-01,Q:000028 (cl,P):(000,0.93) (004,0.07) (003,0.00)
RQ 08 H:6.164e-01,Q:000065 (cl,P):(000,0.82) (004,0.18) (003,0.00)
RQ 12 H:7.532e-01,Q:000083 (cl,P):(004,0.76) (000,0.24) (003,0.00)
R- 13 H:4.557e-01,Q:000839 tau:0.5391497612 theta:[ 1.]
L- 12 H:2.462e-01,Q:000719 tau:0.421772927046 theta:[ 1.]
LQ 11 H:6.151e-01,Q:000083 (cl,P):(004,0.80) (000,0.20) (003,0.00)
R- 11 H:1.160e-01,Q:000636 tau:0.522571742535 theta:[ 1.]
L- 10 H:6.454e-02,Q:000552 tau:0.441008627415 theta:[ 1.]
LQ 09 H:2.454e-01,Q:000066 (cl,P):(004,0.94) (000,0.06) (003,0.00)
R- 09 H:1.494e-02,Q:000486 tau:-0.435770213604 theta:[ 0.]
LQ 08 H:1.475e-01,Q:000022 (cl,P):(004,0.95) (003,0.05) (002,0.00)
RG 08 H:1.069e-37,Q:000464 (cl,P):(004,1.00) (003,0.00) (002,0.00)
RQ 10 H:2.669e-01,Q:000084 (cl,P):(004,0.94) (003,0.06) (002,0.00)
RQ 12 H:8.394e-01,Q:000120 (cl,P):(004,0.68) (003,0.33) (002,0.00)
R- 16 H:1.628e+00,Q:002846 tau:-0.22276070714 theta:[ 1.]
L- 15 H:1.041e+00,Q:000596 tau:-0.301037818193 theta:[ 1.]
L- 14 H:5.313e-01,Q:000382 tau:0.482695400715 theta:[ 0.]
LQ 13 H:1.737e-01,Q:000332 (cl,P):(002,0.97) (001,0.02) (003,0.01)
RQ 13 H:7.237e-01,Q:000050 (cl,P):(001,0.70) (002,0.30) (004,0.00)
RQ 14 H:9.694e-01,Q:000214 (cl,P):(003,0.53) (002,0.47) (004,0.00)
R- 15 H:1.327e+00,Q:002250 tau:0.36508461833 theta:[ 0.]
L- 14 H:8.952e-01,Q:001242 tau:0.380538970232 theta:[ 1.]
L- 13 H:7.085e-01,Q:001043 tau:-0.0235525015742 theta:[ 1.]
LQ 12 H:9.934e-01,Q:000348 (cl,P):(004,0.52) (003,0.48) (002,0.00)
R- 12 H:1.903e-01,Q:000695 tau:0.323875874281 theta:[ 0.]
L- 11 H:9.926e-02,Q:000573 tau:0.24159643054 theta:[ 0.]
LQ 10 H:2.583e-01,Q:000097 (cl,P):(004,0.94) (000,0.06) (003,0.00)
R- 10 H:3.038e-02,Q:000476 tau:0.356256723404 theta:[ 1.]
L- 09 H:1.590e-02,Q:000463 tau:0.244989201427 theta:[ 0.]
LQ 08 H:2.123e-01,Q:000017 (cl,P):(004,0.94) (000,0.06) (003,0.00)
RG 08 H:1.112e-37,Q:000446 (cl,P):(004,1.00) (003,0.00) (002,0.00)
RQ 09 H:2.119e-01,Q:000013 (cl,P):(004,0.92) (003,0.08) (002,0.00)
RQ 11 H:3.797e-01,Q:000122 (cl,P):(004,0.91) (003,0.09) (002,0.00)
RQ 13 H:6.082e-01,Q:000199 (cl,P):(003,0.84) (004,0.16) (002,0.00)
R- 14 H:7.494e-01,Q:001008 tau:0.520330011845 theta:[ 0.]
L- 13 H:4.815e-01,Q:000869 tau:0.499652475119 theta:[ 1.]
L- 12 H:2.933e-01,Q:000820 tau:0.390436857939 theta:[ 0.]
LQ 11 H:4.544e-01,Q:000116 (cl,P):(003,0.89) (004,0.11) (002,0.00)
R- 11 H:2.060e-01,Q:000704 tau:-0.148109361529 theta:[ 1.]
LQ 10 H:6.670e-01,Q:000038 (cl,P):(003,0.68) (002,0.32) (004,0.00)
R- 10 H:1.255e-01,Q:000666 tau:0.431696951389 theta:[ 1.]
L- 09 H:4.509e-02,Q:000633 tau:0.376960426569 theta:[ 1.]
L- 08 H:2.566e-02,Q:000586 tau:0.509888648987 theta:[ 0.]
LG 07 H:8.891e-38,Q:000559 (cl,P):(003,1.00) (004,0.00) (002,0.00)
RQ 07 H:2.539e-01,Q:000027 (cl,P):(003,0.93) (002,0.07) (004,0.00)
RQ 08 H:5.861e-02,Q:000047 (cl,P):(003,0.96) (002,0.04) (004,0.00)
RQ 09 H:6.430e-01,Q:000033 (cl,P):(003,0.76) (002,0.24) (004,0.00)
RQ 12 H:5.021e-01,Q:000049 (cl,P):(002,0.84) (003,0.16) (004,0.00)
RQ 13 H:6.978e-01,Q:000139 (cl,P):(002,0.78) (003,0.22) (004,0.00)
R- 17 H:1.424e+00,Q:001936 tau:0.734311580658 theta:[ 1.]
L- 16 H:1.034e+00,Q:001015 tau:0.296144396067 theta:[ 0.]
L- 15 H:7.201e-01,Q:000818 tau:-0.489118397236 theta:[ 0.]
LQ 14 H:8.258e-01,Q:000163 (cl,P):(002,0.70) (003,0.30) (004,0.00)
R- 14 H:2.767e-01,Q:000655 tau:0.170863837004 theta:[ 0.]
L- 13 H:1.482e-01,Q:000571 tau:0.599226772785 theta:[ 1.]
LQ 12 H:5.978e-01,Q:000027 (cl,P):(003,0.63) (004,0.37) (002,0.00)
R- 12 H:4.816e-02,Q:000544 tau:-0.419204711914 theta:[ 0.]
LQ 11 H:1.020e-01,Q:000054 (cl,P):(003,0.96) (002,0.04) (004,0.00)
R- 11 H:2.592e-02,Q:000490 tau:0.626394808292 theta:[ 1.]
LQ 10 H:1.510e-01,Q:000040 (cl,P):(003,0.95) (004,0.05) (002,0.00)
RG 10 H:1.102e-37,Q:000450 (cl,P):(003,1.00) (004,0.00) (002,0.00)
RQ 13 H:6.004e-01,Q:000084 (cl,P):(003,0.82) (002,0.18) (004,0.00)
RQ 15 H:3.215e-01,Q:000197 (cl,P):(002,0.94) (001,0.05) (003,0.01)
R- 16 H:9.454e-01,Q:000921 tau:0.293377369642 theta:[ 0.]
L- 15 H:5.695e-01,Q:000717 tau:0.913785874844 theta:[ 1.]
L- 14 H:2.740e-01,Q:000633 tau:0.774737238884 theta:[ 1.]
LQ 13 H:6.382e-01,Q:000101 (cl,P):(002,0.79) (003,0.21) (004,0.00)
R- 13 H:1.053e-01,Q:000532 tau:0.893424153328 theta:[ 1.]
L- 12 H:7.191e-02,Q:000482 tau:0.808997809887 theta:[ 1.]
LQ 11 H:1.789e-01,Q:000106 (cl,P):(002,0.96) (003,0.04) (004,0.00)
R- 11 H:1.857e-02,Q:000376 tau:0.875819981098 theta:[ 1.]
LQ 10 H:1.619e-37,Q:000305 (cl,P):(002,1.00) (004,0.00) (003,0.00)
RQ 10 H:6.125e-02,Q:000071 (cl,P):(002,0.99) (001,0.01) (004,0.00)
RQ 12 H:1.972e-01,Q:000050 (cl,P):(002,0.94) (001,0.06) (004,0.00)
RQ 14 H:9.716e-01,Q:000084 (cl,P):(001,0.56) (002,0.44) (004,0.00)
RQ 15 H:6.813e-01,Q:000204 (cl,P):(001,0.81) (002,0.19) (004,0.00)
R- 18 H:1.481e+00,Q:001957 tau:0.710452675819 theta:[ 0.]
L- 17 H:9.657e-01,Q:000946 tau:-0.281441122293 theta:[ 1.]
LQ 16 H:1.154e-01,Q:000147 (cl,P):(001,0.98) (000,0.01) (002,0.01)
R- 16 H:7.878e-01,Q:000799 tau:0.573708951473 theta:[ 1.]
L- 15 H:4.022e-01,Q:000671 tau:0.662688851357 theta:[ 0.]
L- 14 H:2.064e-01,Q:000521 tau:-0.229025125504 theta:[ 1.]
LQ 13 H:4.503e-01,Q:000015 (cl,P):(002,0.60) (001,0.40) (004,0.00)
R- 13 H:1.492e-01,Q:000506 tau:0.454557180405 theta:[ 1.]
L- 12 H:5.725e-02,Q:000469 tau:0.577971100807 theta:[ 0.]
LQ 11 H:1.606e-01,Q:000055 (cl,P):(002,0.95) (003,0.05) (004,0.00)
R- 11 H:1.701e-02,Q:000414 tau:0.581248044968 theta:[ 0.]
LQ 10 H:1.837e-01,Q:000015 (cl,P):(002,0.93) (003,0.07) (004,0.00)
RG 10 H:1.241e-37,Q:000399 (cl,P):(002,1.00) (004,0.00) (003,0.00)
RQ 12 H:6.040e-01,Q:000037 (cl,P):(002,0.81) (001,0.19) (004,0.00)
RQ 14 H:6.990e-01,Q:000150 (cl,P):(002,0.77) (001,0.23) (004,0.00)
RQ 15 H:7.444e-02,Q:000128 (cl,P):(001,0.98) (002,0.02) (004,0.00)
R- 17 H:9.902e-01,Q:001011 tau:0.880418121815 theta:[ 0.]
L- 16 H:6.940e-01,Q:000763 tau:-0.346048891544 theta:[ 1.]
LQ 15 H:4.158e-01,Q:000102 (cl,P):(000,0.90) (001,0.10) (004,0.00)
R- 15 H:3.003e-01,Q:000661 tau:-0.208956748247 theta:[ 1.]
LQ 14 H:7.628e-01,Q:000072 (cl,P):(001,0.75) (000,0.25) (004,0.00)
R- 14 H:1.529e-01,Q:000589 tau:0.761425375938 theta:[ 0.]
LQ 13 H:3.405e-01,Q:000128 (cl,P):(001,0.92) (002,0.08) (004,0.00)
R- 13 H:4.758e-02,Q:000461 tau:0.487264096737 theta:[ 1.]
L- 12 H:1.648e-02,Q:000436 tau:0.873901426792 theta:[ 0.]
LG 11 H:1.155e-37,Q:000429 (cl,P):(001,1.00) (004,0.00) (003,0.00)
RQ 11 H:2.857e-01,Q:000007 (cl,P):(001,0.86) (000,0.14) (004,0.00)
RQ 12 H:2.546e-01,Q:000025 (cl,P):(001,0.92) (000,0.08) (004,0.00)
RQ 16 H:3.796e-01,Q:000248 (cl,P):(000,0.92) (001,0.08) (004,0.00)
In [8]:
#load the last dataset that never use for training
dset=dataset(8)
correct=0;
for x in xrange(dset.size):
L=t.getL(np.array([x]),dset)
if dset.getL(x) == L:
correct=correct+1
dset.setL(x,L)
print("recall rate: {}%".format(correct/float(dset.size)*100))
recall rate: 90.28%
In [9]:
#setup the new test-set
#load dataset
dset=dataset(8)
d=0.05
y, x = np.mgrid[slice(-1, 1+d, d), slice(-1, 1+d, d)]
#start labeling
L=np.zeros(x.shape,dtype=int)
for r in xrange(x.shape[0]):
for c in xrange(x.shape[1]):
u=( x[r,c],y[r,c] )
Prob=t.classify(u)
L[r,c]=np.argmax(Prob)
In [10]:
%matplotlib inline
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.axis([-1,1,-1,1])
ax.pcolor(x,y,L)
ax.hold(True)
In [11]:
z=np.random.randint(0,dset.size,1000)
for i in z:
ax.plot(dset.I[i,0],dset.I[i,1],marker[dset.samples[i]])
fig
Out[11]:
In [12]:
t.classify([0.75,0.0])
Out[12]:
array([ 0. , 0.921875, 0.078125, 0. , 0. ])
In [ ]:
Content source: wasit7/parallel_forest
Similar notebooks: