示例#1
0
import time
import json
import logging
import os
logging.basicConfig(format='%(asctime)s   %(levelname)s   %(message)s',
                    level=logging.DEBUG)
seed = 2016
plot = True
imputer = Imputer()
scaler = StandardScaler()

activity_names = json.load(open('../input/public_data/annotations.json', 'r'))
class_weights = np.asarray(
    json.load(open('../input/public_data/class_weights.json', 'r')))
plotter = SequenceVisualisation('../input/public_data',
                                '../input/public_data/train/00001')
annotation_names = plotter.targets.columns.difference(['start', 'end'])


def brier_score(given, predicted):
    global class_weights
    return np.power(given - predicted, 2.0).dot(class_weights).mean()


def xgb_brier_score(preds, dtrain):
    global train_y
    idx = dtrain.get_float_info("true_label")
    labels = train_y[idx]
    predicted = preds.reshape(labels.shape[0], 20)
    return 'brier', brier_score(labels, predicted)
示例#2
0
import sys

from visualise_data import SequenceVisualisation

sns.set_context('poster')
sns.set_style('darkgrid')
current_palette = cycle(sns.color_palette())

nb_dir = os.path.split(os.getcwd())[0]
if nb_dir not in sys.path:
    sys.path.append(nb_dir)

public_data_path = './public_data'
metadata_path = './public_data/metadata'

plotter = SequenceVisualisation(metadata_path,
                                public_data_path + '/train/00001')
sequence_window = (plotter.meta['start'], plotter.meta['end'])

# plotter.plot_pir(sequence_window, sharey=True)
# plotter.plot_rssi(sequence_window)
# plotter.plot_acceleration((sequence_window[0] + 180, sequence_window[0] + 300))
# plotter.plot_video(plotter.centre_2d, sequence_window)
# pl.gcf().suptitle('2D bounding box')

# plotter.plot_video(plotter.centre_3d, sequence_window)
# pl.gcf().suptitle('3D bounding box')

# pl.show()

##### plot annotations