rfho/datasets.py
def load_iris(partitions_proportions=None, classes=3):
    """Loads Iris dataset divided as training and test set (by default)"""
    training_set = tf.contrib.learn.datasets.base.load_csv_with_header(
        filename=IRIS_TRAINING,
        target_dtype=np.int,
        features_dtype=np.float32)
    test_set = tf.contrib.learn.datasets.base.load_csv_with_header(
        filename=IRIS_TEST,
        target_dtype=np.int,
        features_dtype=np.float32)

    tr_set = training_set.data
    tr_targets = to_one_hot_enc(training_set.target)

    tr_dst = Dataset(data=tr_set, target=tr_targets)

    tst_set = test_set.data
    tst_targets = to_one_hot_enc(test_set.target)
    tst_dst = Dataset(data=tst_set, target=tst_targets)

    if partitions_proportions:
        if classes == 2:
            # noinspection PyUnusedLocal
            def filter_class(x, y, info, i):
                return np.argmax(y) != 0  # discard first class

            filter_list = [filter_class]

            # noinspection PyUnusedLocal
            def project_map(x, y, info, i):
                return x, y[1:], info

        else:
            filter_list, project_map = (None, None)

        res = redivide_data([tr_dst, tst_dst], partitions_proportions, filters=filter_list, maps=project_map)
        res += [None] * (3 - len(res))
        return Datasets(train=res[0], validation=res[1], test=res[2])

    return Datasets(train=tr_dst, test=tst_dst, validation=None)
Loads Iris dataset divided as training and test set (by default)
Loads Iris dataset divided as training and test set (by default)
Loads Iris dataset divided as training and test set ( by default )
def load_iris(partitions_proportions=None, classes=3):
    training_set = tf.contrib.learn.datasets.base.load_csv_with_header(
        filename=IRIS_TRAINING,
        target_dtype=np.int,
        features_dtype=np.float32)
    test_set = tf.contrib.learn.datasets.base.load_csv_with_header(
        filename=IRIS_TEST,
        target_dtype=np.int,
        features_dtype=np.float32)
    tr_set = training_set.data
    tr_targets = to_one_hot_enc(training_set.target)
    tr_dst = Dataset(data=tr_set, target=tr_targets)
    tst_set = test_set.data
    tst_targets = to_one_hot_enc(test_set.target)
    tst_dst = Dataset(data=tst_set, target=tst_targets)
    if partitions_proportions:
        if classes == 2:
            def filter_class(x, y, info, i):
                return np.argmax(y) != 0  
            filter_list = [filter_class]
            def project_map(x, y, info, i):
                return x, y[1:], info
        else:
            filter_list, project_map = (None, None)
        res = redivide_data([tr_dst, tst_dst], partitions_proportions, filters=filter_list, maps=project_map)
        res += [None] * (3 - len(res))
        return Datasets(train=res[0], validation=res[1], test=res[2])
    return Datasets(train=tr_dst, test=tst_dst, validation=None)
def load_iris ( partitions_proportions = None , classes = 3 ) : training_set = tf . contrib . learn . datasets . base . load_csv_with_header ( filename = IRIS_TRAINING , target_dtype = np . int , features_dtype = np . float32 ) test_set = tf . contrib . learn . datasets . base . load_csv_with_header ( filename = IRIS_TEST , target_dtype = np . int , features_dtype = np . float32 ) tr_set = training_set . data tr_targets = to_one_hot_enc ( training_set . target ) tr_dst = Dataset ( data = tr_set , target = tr_targets ) tst_set = test_set . data tst_targets = to_one_hot_enc ( test_set . target ) tst_dst = Dataset ( data = tst_set , target = tst_targets ) if partitions_proportions : if classes == 2 : def filter_class ( x , y , info , i ) : return np . argmax ( y ) != 0 filter_list = [ filter_class ] def project_map ( x , y , info , i ) : return x , y [ 1 : ] , info else : filter_list , project_map = ( None , None ) res = redivide_data ( [ tr_dst , tst_dst ] , partitions_proportions , filters = filter_list , maps = project_map ) res += [ None ] * ( 3 - len ( res ) ) return Datasets ( train = res [ 0 ] , validation = res [ 1 ] , test = res [ 2 ] ) return Datasets ( train = tr_dst , test = tst_dst , validation = None )
Loads Iris dataset divided as training and test set (by default)
Loads Iris dataset divided as training and test set ( by default )
"""Loads Iris dataset divided as training and test set (by default)""" # noinspection PyUnusedLocal # discard first class # noinspection PyUnusedLocal
partitions_proportions
classes