``````

In :

import helper as hp
from IPython.display import HTML
from IPython.html import widgets
from IPython.display import display, clear_output

``````
``````

In :

%pylab inline

``````
``````

Populating the interactive namespace from numpy and matplotlib

``````
``````

In :

``````
``````

In :

'''
paramenters for 3D plotting, represent the 3 possible poses adopted
'''

red = 'STAND_POINTING_RIGHT'
blue = 'STAND_POINTING_LEFT'
green = 'STAND_POINTING_FORWARD'

'''
K_GMM_n, K_KMeans_n are the noise curiosity factors for each algorithm
K_GMM_s, K_KMeans_s are the strangeness curiosity factors for each algorithm
Ks is a list containing the 4 above mentioned parameters

'''

global K_GMM_n, K_KMeans_n, K_GMM_s, K_KMeans_s, Ks
K_GMM_n, K_KMeans_n, K_GMM_s, K_KMeans_s = [0,0,0,0]

``````

### Recovering similar values from queue

``````

In :

'''
Sliders functions for curiosity factors
'''
def K_GMM_noise(name, value):
global K_GMM_n, Ks

K_GMM_n = value*10000

#Rewrite the curiosity factors list
Ks = [K_GMM_n, K_KMeans_n, K_GMM_s, K_KMeans_s]

def K_Km_noise(name, value):
global K_KMeans_n, Ks
K_KMeans_n = value
#Rewrite the curiosity factors list
Ks = [K_GMM_n, K_KMeans_n, K_GMM_s, K_KMeans_s]

def K_GMM_strange(name, value):
global K_GMM_s, Ks
K_GMM_s = value*100000
#Rewrite the curiosity factors list
Ks = [K_GMM_n, K_KMeans_n, K_GMM_s, K_KMeans_s]

def K_Km_strange(name, value):
global K_KMeans_s, Ks
K_KMeans_s = value
#Rewrite the curiosity factors list
Ks = [K_GMM_n, K_KMeans_n, K_GMM_s, K_KMeans_s]
'''
Button functions to Add users to the system
'''

indexes = [i for i in np.arange(30)]
indexes.pop(indexes.index(0)) # There is no 'user00' data, so we remove it
indexes.pop(indexes.index(6))  # There is no 'user06' data, so we remove it
indexes.pop(indexes.index(12)) # There is no 'user12' data in POINTING LEFT, so we remove it

red_users = indexes
blue_users = indexes
green_users = indexes

def click_right(widget):
j = random.choice(red_users) # Choose a random user from the users list
red_users.pop(red_users.index(j)) # Remove the taken user from the list
global queue
queue = hp.add_user_median(queue,j, red) #Add the median for that user to the queue list
users.append([j, red])

def click_left(widget):
j = random.choice(blue_users) # Choose a random user from the users list
blue_users.pop(blue_users.index(j)) # Remove the taken user from the list
global queue
queue = hp.add_user_median(queue,j, blue) #Add the median for that user to the queue list
users.append([j, blue])

def click_forward(widget):
j = random.choice(green_users) # Choose a random user from the users list
green_users.pop(green_users.index(j)) # Remove the taken user from the list
global queue
queue = hp.add_user_median(queue,j, green) #Add the median for that user to the queue list
users.append([j, green])
#hp.compute_and_reload_figures('') # The figures could be reloaded here, but they would stack up, instead its run separately

'''
Button function to add the last entry to the normal dataset and to users_normal
'''

def learn_pose(widget):
new_pose = queue[-1]
new_pose_index = users[-1]
global normal_users
normal_users.append(new_pose)
if new_pose_index not in users_normal:
users_normal.append(new_pose_index)

``````
``````

In :

number_users = 6
initial_pose = red

'''
Start the system with using a number of users, number_users  all posing in the same direction, initial_pose
users and users_normal have a [number_user, pose] form
normal_users and queue are lists of users in data form

'''

users, normal_users, queue = hp.start_users(number_users, initial_pose)
users_normal = list(users)

``````
``````

In :

'''
Display sliders for curiosity factors
'''

int_range = widgets.FloatSliderWidget(min=0.5, max=10, step=0.5, description = 'K_GMM_noise')
int_range.on_trait_change(K_GMM_noise, 'value')
int_range2 = widgets.IntSliderWidget(min=0, max=10, step=1,description = 'K_KMeans_noise')
int_range2.on_trait_change(K_Km_noise, 'value')
int_range3 = widgets.FloatSliderWidget(min=0.5, max=10, step=0.5, description = 'K_GMM_strangeness')
int_range3.on_trait_change(K_GMM_strange, 'value')
int_range4 = widgets.IntSliderWidget(min=0, max=10, step=1,description = 'K_KMeans_strangeness')
int_range4.on_trait_change(K_Km_strange, 'value')

display(int_range, int_range2,int_range3, int_range4)

``````
``````

In :

'''
Display buttons to add users
'''

b = widgets.ButtonWidget(description='Add POINTING RIGHT')
b.on_click(click_right)
b2 = widgets.ButtonWidget(description='Add POINTING LEFT')
b2.on_click(click_left)
b3 = widgets.ButtonWidget(description='Add POINTING FORWARD')
b3.on_click(click_forward)
display(b, b2, b3)

``````
``````

In :

'''
Compute the classification for the last added entry and display the results
noise = red, interesting = green
known = red, strange = green
If the entry is detected as not interesting by all algorithms, the strangeness score is not displayed

'''
hp.compute_and_reload_figures(normal_users,queue, users_normal, users,Ks )

``````
``````

``````
``````

In :

'''
Display button to Learn the last entry
'''
b_learn = widgets.ButtonWidget(description='Learn Last Entry')
b_learn.on_click(learn_pose)
display(b_learn)

``````
``````

In [ ]:

``````