-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.py
66 lines (42 loc) · 1.31 KB
/
sample.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
"""
usage for shogun-toolbox
explained in detail http://qiita.com/ysak/items/20cd4e7db9a7c3f79f10
"""
"""
generate and set/get values to Labels
"""
def label_function():
from modshogun import BinaryLabels
from modshogun import CSVFile
#generate random labels
label = BinaryLabels(5)
print label.get_num_labels()
#→ 5
print label.get_values()
#→ array([5 label values])
#Labels from CSVFile
label_from_csv = BinaryLabels(CSVFile("csv/label.csv"))
"""
generate and set/get values to Features
"""
def feature_function():
from modshogun import RealFeatures
from modshogun import CSVFile
import numpy as np
#3x3 random matrix
feat_arr = np.random.rand(3, 3)
#initialize RealFeatures from numpy array
features = RealFeatures(feat_arr)
#get matrix value function
print features.get_feature_matrix(features)
#get selected column of matrix
print features.get_feature_vector(1)
#get number of columns
print features.get_num_features()
#get number of rows
print features.get_num_vectors()
feats_from_csv = RealFeatures(CSVFile("csv/feature.csv"))
print "csv is ", feats_from_csv.get_feature_matrix()
if __name__ == "__main__":
feature_function()