How to use the larray.reindex function in larray

To help you get started, we’ve selected a few larray examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jaberg / skdata / skdata / tasks.py View on Github external
X, y = dataset.classification_task()

    # construct the standard splits by convention of the .meta attribute
    splits = [m['split'] for m in dataset.meta]
    train_idxs = [i for i, s in enumerate(splits) if s == 'train']
    valid_idxs = [i for i, s in enumerate(splits) if s == 'valid']
    test_idxs = [i for i, s in enumerate(splits) if s == 'test']

    if len(splits) != len(X):
        raise ValueError('Length of X does not match length of meta data')

    if len(train_idxs) + len(valid_idxs) + len(test_idxs) != len(splits):
        raise ValueError('meta contains splits other than train, valid, test.')

    X_train = larray.reindex(X, train_idxs)
    X_valid = larray.reindex(X, valid_idxs)
    X_test = larray.reindex(X, test_idxs)

    y_train = larray.reindex(y, train_idxs)
    y_valid = larray.reindex(y, valid_idxs)
    y_test = larray.reindex(y, test_idxs)

    return (X_train, y_train), (X_valid, y_valid), (X_test, y_test)
github jaberg / skdata / skdata / tasks.py View on Github external
valid_idxs = [i for i, s in enumerate(splits) if s == 'valid']
    test_idxs = [i for i, s in enumerate(splits) if s == 'test']

    if len(splits) != len(X):
        raise ValueError('Length of X does not match length of meta data')

    if len(train_idxs) + len(valid_idxs) + len(test_idxs) != len(splits):
        raise ValueError('meta contains splits other than train, valid, test.')

    X_train = larray.reindex(X, train_idxs)
    X_valid = larray.reindex(X, valid_idxs)
    X_test = larray.reindex(X, test_idxs)

    y_train = larray.reindex(y, train_idxs)
    y_valid = larray.reindex(y, valid_idxs)
    y_test = larray.reindex(y, test_idxs)

    return (X_train, y_train), (X_valid, y_valid), (X_test, y_test)
github jaberg / skdata / skdata / tasks.py View on Github external
X, y = dataset.classification_task()

    # construct the standard splits by convention of the .meta attribute
    splits = [m['split'] for m in dataset.meta]
    train_idxs = [i for i, s in enumerate(splits) if s == 'train']
    valid_idxs = [i for i, s in enumerate(splits) if s == 'valid']
    test_idxs = [i for i, s in enumerate(splits) if s == 'test']

    if len(splits) != len(X):
        raise ValueError('Length of X does not match length of meta data')

    if len(train_idxs) + len(valid_idxs) + len(test_idxs) != len(splits):
        raise ValueError('meta contains splits other than train, valid, test.')

    X_train = larray.reindex(X, train_idxs)
    X_valid = larray.reindex(X, valid_idxs)
    X_test = larray.reindex(X, test_idxs)

    y_train = larray.reindex(y, train_idxs)
    y_valid = larray.reindex(y, valid_idxs)
    y_test = larray.reindex(y, test_idxs)

    return (X_train, y_train), (X_valid, y_valid), (X_test, y_test)
github jaberg / skdata / skdata / tasks.py View on Github external
splits = [m['split'] for m in dataset.meta]
    train_idxs = [i for i, s in enumerate(splits) if s == 'train']
    valid_idxs = [i for i, s in enumerate(splits) if s == 'valid']
    test_idxs = [i for i, s in enumerate(splits) if s == 'test']

    if len(splits) != len(X):
        raise ValueError('Length of X does not match length of meta data')

    if len(train_idxs) + len(valid_idxs) + len(test_idxs) != len(splits):
        raise ValueError('meta contains splits other than train, valid, test.')

    X_train = larray.reindex(X, train_idxs)
    X_valid = larray.reindex(X, valid_idxs)
    X_test = larray.reindex(X, test_idxs)

    y_train = larray.reindex(y, train_idxs)
    y_valid = larray.reindex(y, valid_idxs)
    y_test = larray.reindex(y, test_idxs)

    return (X_train, y_train), (X_valid, y_valid), (X_test, y_test)
github jaberg / skdata / skdata / tasks.py View on Github external
# construct the standard splits by convention of the .meta attribute
    splits = [m['split'] for m in dataset.meta]
    train_idxs = [i for i, s in enumerate(splits) if s == 'train']
    valid_idxs = [i for i, s in enumerate(splits) if s == 'valid']
    test_idxs = [i for i, s in enumerate(splits) if s == 'test']

    if len(splits) != len(X):
        raise ValueError('Length of X does not match length of meta data')

    if len(train_idxs) + len(valid_idxs) + len(test_idxs) != len(splits):
        raise ValueError('meta contains splits other than train, valid, test.')

    X_train = larray.reindex(X, train_idxs)
    X_valid = larray.reindex(X, valid_idxs)
    X_test = larray.reindex(X, test_idxs)

    y_train = larray.reindex(y, train_idxs)
    y_valid = larray.reindex(y, valid_idxs)
    y_test = larray.reindex(y, test_idxs)

    return (X_train, y_train), (X_valid, y_valid), (X_test, y_test)
github jaberg / skdata / skdata / tasks.py View on Github external
train_idxs = [i for i, s in enumerate(splits) if s == 'train']
    valid_idxs = [i for i, s in enumerate(splits) if s == 'valid']
    test_idxs = [i for i, s in enumerate(splits) if s == 'test']

    if len(splits) != len(X):
        raise ValueError('Length of X does not match length of meta data')

    if len(train_idxs) + len(valid_idxs) + len(test_idxs) != len(splits):
        raise ValueError('meta contains splits other than train, valid, test.')

    X_train = larray.reindex(X, train_idxs)
    X_valid = larray.reindex(X, valid_idxs)
    X_test = larray.reindex(X, test_idxs)

    y_train = larray.reindex(y, train_idxs)
    y_valid = larray.reindex(y, valid_idxs)
    y_test = larray.reindex(y, test_idxs)

    return (X_train, y_train), (X_valid, y_valid), (X_test, y_test)