Python sklearn.datasets 模块,fetch_olivetti_faces() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用sklearn.datasets.fetch_olivetti_faces()

项目:gcForest    作者:kingfengji    | 项目源码 | 文件源码
def load_data(train_num, train_repeat):
    test_size = (10. - train_num) / 10
    data = fetch_olivetti_faces()
    X = data.images
    y = data.target
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=test_size, random_state=3, stratify=y)
    if train_repeat > 1:
        X_train = X_train.repeat(train_repeat, axis=0)
        y_train = y_train.repeat(train_repeat)
    return X_train, y_train, X_test, y_test
项目:pylmnn    作者:johny-c    | 项目源码 | 文件源码
def fetch_from_config(cfg):
    data_set_name = cfg['fetch']['name']
    if cfg['fetch'].getboolean('sklearn'):
        if data_set_name == 'OLIVETTI':
            data_set = skd.fetch_olivetti_faces(shuffle=True)
        else:
            data_set = skd.fetch_mldata(data_set_name)
        X, y = data_set.data, data_set.target
        if data_set_name == 'MNIST original':
            if cfg['pre_process'].getboolean('normalize'):
                X = X / 255.
    else:
        if data_set_name == 'LETTERS':
            X, y = fetch_load_letters()
        elif data_set_name == 'ISOLET':
            x_tr, x_te, y_tr, y_te = fetch_load_isolet()
        elif data_set_name == 'SHREC14':
            X, y = load_shrec14(real=cfg['fetch']['real'], desc=cfg['fetch']['desc'])
            X = prep.normalize(X, norm=cfg['pre_process']['norm'])
        else:
            raise NameError('No data set {} found!'.format(data_set_name))

    # Separate training and testing set
    if data_set_name == 'MNIST original':
        x_tr, x_te, y_tr, y_te = X[:60000], X[60000:], y[:60000], y[60000:]
    elif data_set_name != 'ISOLET':
        test_size = cfg['train_test'].getfloat('test_size')
        x_tr, x_te, y_tr, y_te = train_test_split(X, y, test_size=test_size, stratify=y)

    return x_tr, x_te, y_tr, y_te
项目:gcforest    作者:w821881341    | 项目源码 | 文件源码
def load_data(train_num, train_repeat):
    test_size = (10. - train_num) / 10
    data = fetch_olivetti_faces()
    X = data.images
    y = data.target
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=test_size, random_state=3, stratify=y)
    if train_repeat > 1:
        X_train = X_train.repeat(train_repeat, axis=0)
        y_train = y_train.repeat(train_repeat)
    return X_train, y_train, X_test, y_test