-
Notifications
You must be signed in to change notification settings - Fork 0
/
kmeans-ssl-pipe.py
36 lines (33 loc) · 1.04 KB
/
kmeans-ssl-pipe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from multipipetools import average
from pipe import Pipe
from pipetools import *
from ssltools import *
from utils import load_x, load_y
from wrapper import kmeans, knn
clusters_count = 10
# file = './datasets/iris/iris.data'
# file_test = './datasets/iris/iris.data'
file = './datasets/pendigits/pendigits.tra'
file_test = './datasets/pendigits/pendigits.tes'
def kmeans_ssl(clusters, neighbors):
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
return fn
p = Pipe() \
.x(load_x(file)) \
.y(load_y(file)) \
.x_test(load_x(file_test))\
.y_test(load_y(file_test))\
.connect(start_timer()) \
.connect(kmeans_ssl(clusters=clusters_count, neighbors=1)) \
.connect(stop_timer()) \
.pipe(dump('evaluation'))