def prepare_data():
    dataset = load_rutgers()
    print('Rutgers loaded ...')

    dataset = CustomInterpolation(source='rssi',
                                  strategy='constant',
                                  constant=0).fit_transform(dataset)
    print('Interpolation applied ...')

    dataset = SyntheticFeatures(source='rssi',
                                window_size=10).fit_transform(dataset)
    print('Synthetic features created ...')

    dataset = PRR(source='received', window_size=10, ahead=1,
                  target='prr').fit_transform(dataset)
    print('PRR created ...')

    for df in dataset:
        df['class_overall'] = prr_to_label(df['received'].astype(bool).sum() /
                                           300.)
    print('Created special feature `class_overall`')

    dataset = CustomMerger().fit_transform(dataset)
    print('Datasets merged ...')

    dataset['class'] = dataset['prr'].apply(prr_to_label)
    print('Classification applied ...')

    dataset = dataset.dropna()
    dataset = dataset.drop(['noise', 'src', 'dst', 'received', 'prr'], axis=1)
    print('Drop useless features, drop lines with NaN')

    return dataset
def prepare_data():
    dataset = load_rutgers()
    print('Rutgers loaded ...')

    dataset = CustomInterpolation(source='rssi',
                                  strategy='constant',
                                  constant=0).fit_transform(dataset)
    print('Interpolation applied ...')

    dataset = SyntheticFeatures(source='rssi',
                                window_size=10).fit_transform(dataset)
    print('Synthetic features created ...')

    dataset = PRR(source='received', window_size=10, ahead=1,
                  target='prr').fit_transform(dataset)
    print('PRR created ...')

    print('Apply discrete derivation (backward difference)')
    for i in range(len(dataset)):
        dataset[i]['drssi'] = dataset[i]['rssi'].diff()

    dataset = CustomMerger().fit_transform(dataset)
    print('Datasets merged ...')

    dataset['class'] = dataset['prr'].apply(prr_to_label)
    print('Classification applied ...')

    dataset = dataset.dropna()
    dataset = dataset.drop(['noise', 'src', 'dst', 'received', 'prr'], axis=1)
    print('Drop useless features, drop lines with NaN')

    dataset = poly_features(dataset,
                            include=['rssi', 'rssi_avg', 'rssi_std'],
                            degree=4,
                            include_bias=True)
    print('Polynomials applied ...')

    # Special synthetic features
    dataset['rssi^-1'] = 1. / dataset['rssi']
    dataset['rssi^-2'] = 1. / dataset['rssi^2']
    dataset['rssi^-3'] = 1. / dataset['rssi^3']
    dataset['rssi^-4'] = 1. / dataset['rssi^4']

    dataset['rssi_avg^-1'] = 1. / dataset['rssi_avg']
    dataset['rssi_avg^-2'] = 1. / dataset['rssi_avg^2']
    dataset['rssi_avg^-3'] = 1. / dataset['rssi_avg^3']
    dataset['rssi_avg^-4'] = 1. / dataset['rssi_avg^4']

    dataset['rssi_std^-1'] = 1. / dataset['rssi_std']
    dataset['rssi_std^-2'] = 1. / dataset['rssi_std^2']
    dataset['rssi_std^-3'] = 1. / dataset['rssi_std^3']
    dataset['rssi_std^-4'] = 1. / dataset['rssi_std^4']

    return dataset