def fn(pipe):
     p = pipe \
         .split(5) \
             .pipe(kmeans(clusters)) \
             .y(seeding_centroids(0.1)) \
             .y(label_consensus()) \
             .pipe(knn(neighbors)) \
             .pipe(predict()) \
             .pipe(evaluate()) \
         .merge('evaluation', average('evaluation'))
     return p
 def fn(pipe):
     p = pipe \
         .split(5) \
             .pipe(agglomerative_l_method()) \
             .pipe(copy('y', 'y_bak')) \
             .y(seeding_random(0.1)) \
             .y(label_consensus()) \
             .pipe(knn(neighbors)) \
             .pipe(predict()) \
             .pipe(copy('y_bak', 'y')) \
             .pipe(evaluate()) \
         .merge('evaluation', average('evaluation'))
     return p
Exemplo n.º 3
0
from pipe import Pipe
from wrapper import knn
from pipetools import predict, dump, load_y, copy, evaluate, echo
from utils import load_x, load_y
from multipipetools import average
from splitter import cross

file = './datasets/iris/iris.data'

a = Pipe() \
    .x(load_x(file)) \
    .y(load_y(file))\
    .split(5, cross()) \
        .pipe(knn(1)) \
        .pipe(copy('x_test', 'x')) \
        .pipe(copy('y_test', 'y')) \
        .pipe(predict()) \
        .pipe(evaluate()) \
    .merge('evaluation', average('evaluation'))\
    .pipe(dump('evaluation'))