├── Makefile ├── README.md ├── btest.conf ├── main.cpp ├── smo-svm.pdf ├── svm_common.cpp ├── svm_common.h ├── svm_option.cpp ├── svm_option.h ├── svm_solver.cpp ├── svm_solver.h ├── test ├── Makefile ├── analysis.conf ├── data │ ├── .svn │ │ └── entries │ ├── heart_scale.shuffle │ ├── heart_scale.test │ ├── heart_scale.train │ └── test_batch_read_sample.dat ├── test_svm_common.cpp ├── test_svm_option.cpp └── test_svm_solver.cpp └── tools ├── install_gtest.html ├── install_gtest.html~ ├── install_gtest.md └── install_gtest.md~ /Makefile: -------------------------------------------------------------------------------- 1 | CC = g++ 2 | CFLAGS = -shared -fPIC -Wno-deprecated 3 | 4 | main : main.o libsvm.so 5 | $(CC) -o light-svm main.o -L. -lsvm 6 | cp libsvm.so test/ 7 | libsvm.so: svm_option.o svm_solver.o svm_common.o 8 | $(CC) $(CFLAGS) svm_option.o svm_solver.o svm_common.o -o libsvm.so 9 | svm_option.o : svm_option.h svm_option.cpp 10 | $(CC) $(CFLAGS) -c svm_option.cpp 11 | svm_solver.o : svm_solver.h svm_solver.cpp 12 | $(CC) $(CFLAGS) -c svm_solver.cpp 13 | svm_common.o : svm_common.h svm_common.cpp 14 | $(CC) $(CFLAGS) -c svm_common.cpp 15 | main.o: main.cpp svm_option.h svm_solver.h svm_common.h 16 | $(CC) $(CFLAGS) -c main.cpp 17 | clean: 18 | rm -rf *.o *.so light-svm test/libsvm.so 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Light-SVM 2 | ========= 3 | 4 | The code implement the SMO (Sequential Minimal Optimization) algorithm for traning SVMs 5 | 6 | Platt, J., "Sequential Minimal Optimization: A Fast Algorithm for Training Support Vector Machines." (1998). 7 | 8 | ## Installation 9 | 10 | If GoogleTest package is missing you must install that to run the test 11 | packages. 12 | 13 | You can find the installation instructions here. 14 | 15 | [Install GTest](tools/install_gtest.md) 16 | 17 | -------------------------------------------------------------------------------- /btest.conf: -------------------------------------------------------------------------------- 1 | gen_mode:function to class 2 | no_test_dir:false 3 | lib_mode: 4 | nonmakefile:0 5 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * 4 | * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved 5 | * 6 | ******************************************************************************* 7 | * 8 | * @file: main.cpp 9 | * @author: mazefeng(mazefeng01@baidu.com) 10 | * @date: 2015/06/30 11:10:00 11 | * 12 | */ 13 | 14 | #include "svm_common.h" 15 | #include "svm_option.h" 16 | #include "svm_solver.h" 17 | 18 | const int RET_OK = 0; 19 | const int RET_SVM_OPTION_ERR = 1; 20 | const int RET_SVM_SOLVER_ERR = 2; 21 | 22 | using std::cerr; 23 | using std::endl; 24 | 25 | void help(){ 26 | cerr << "Usage: light-svm -train ${train} -model ${model} " 27 | << "-valid ${valid} [-linear_kernel] [-C ${cost}] " 28 | << "[-epsilon ${eps}] [-sigma ${sig}] [-help]" 29 | << endl; 30 | } 31 | 32 | int main(int argc, char *argv[]){ 33 | 34 | int ret = RET_OK; 35 | 36 | SVMOption *option = new SVMOption(); 37 | ret = option->parse_command_line(argc, argv); 38 | if (ret != 0){ 39 | help(); 40 | return RET_SVM_OPTION_ERR; 41 | } 42 | 43 | option->print(); 44 | 45 | SVMSolver *solver = new SVMSolver(option); 46 | 47 | solver->train(); 48 | solver->predict(); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /smo-svm.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazefeng/svm/708eba85d41ac19790848523594b4a7df1355f71/smo-svm.pdf -------------------------------------------------------------------------------- /svm_common.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * 4 | * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved 5 | * 6 | ******************************************************************************* 7 | * 8 | * @file: svm_common.cpp 9 | * @author: mazefeng(mazefeng01@baidu.com) 10 | * @date: 2015/06/30 11:10:00 11 | * 12 | */ 13 | 14 | #include "svm_common.h" 15 | 16 | using std::ifstream; 17 | using std::ofstream; 18 | using std::cerr; 19 | using std::cout; 20 | using std::endl; 21 | using std::ostringstream; 22 | 23 | int split(const TString& s, char c, TStringArray& v){ 24 | TString::size_type i = 0; 25 | TString::size_type j = s.find(c); 26 | if (j != TString::npos){ 27 | while (j != TString::npos){ 28 | v.push_back(s.substr(i, j - i)); 29 | i = ++j; 30 | j = s.find(c, j); 31 | if (j == TString::npos){ 32 | v.push_back(s.substr(i, s.length())); 33 | } 34 | } 35 | } 36 | else{ 37 | v.push_back(s); 38 | } 39 | return 0; 40 | } 41 | 42 | bool cmp(const TVectorDim& p1, const TVectorDim& p2){ 43 | return p1.first < p2.first; 44 | } 45 | 46 | float dot_product(const TVector& v1, const TVector& v2){ 47 | float dot = 0.0; 48 | int p1 = 0; 49 | int p2 = 0; 50 | int a1 = -1; 51 | int a2 = -1; 52 | while (p1 < v1.size() && p2 < v2.size()){ 53 | a1 = v1[p1].first; 54 | a2 = v2[p2].first; 55 | if (a1 == a2){ 56 | dot += v1[p1].second * v2[p2].second; 57 | p1++; 58 | p2++; 59 | } 60 | else if (a1 > a2){ 61 | p2++; 62 | } 63 | else{ 64 | p1++; 65 | } 66 | } 67 | return dot; 68 | } 69 | 70 | void print_TVector(const TVector& v){ 71 | for (int i = 0; i < v.size(); i++){ 72 | cerr << v[i].first << ':' << v[i].second << endl; 73 | } 74 | } 75 | 76 | TVector operator*(const TVector& v, float f){ 77 | TVector p; 78 | for (int i = 0; i < v.size(); i++){ 79 | p.push_back(TVectorDim(v[i].first, v[i].second * f)); 80 | } 81 | return p; 82 | } 83 | 84 | TVector operator*(float f, const TVector& v){ 85 | return v * f; 86 | } 87 | 88 | TVector operator+(const TVector& v1, const TVector& v2){ 89 | TVector s; 90 | int p1 = 0; 91 | int p2 = 0; 92 | int a1 = -1; 93 | int a2 = -1; 94 | while (p1 < v1.size() && p2 < v2.size()){ 95 | a1 = v1[p1].first; 96 | a2 = v2[p2].first; 97 | if (a1 == a2){ 98 | TVectorDim p(a1, v1[p1].second + v2[p2].second); 99 | s.push_back(p); 100 | p1++; 101 | p2++; 102 | } 103 | else if (a1 > a2){ 104 | s.push_back(v2[p2]); 105 | p2++; 106 | } 107 | else{ 108 | s.push_back(v1[p1]); 109 | p1++; 110 | } 111 | } 112 | for (; p1 < v1.size(); p1++){ 113 | s.push_back(v1[p1]); 114 | } 115 | for (; p2 < v2.size(); p2++){ 116 | s.push_back(v2[p2]); 117 | } 118 | return s; 119 | } 120 | 121 | int batch_read_sample(ifstream& is, TVectorArray& x_array, TFloatArray& y_array, int& n){ 122 | TString s; 123 | TVector x; 124 | float y = 0.0; 125 | n = 0; 126 | while (getline(is, s, '\n')){ 127 | read_sample(s, x, y); 128 | x_array.push_back(x); 129 | y_array.push_back(y); 130 | n += 1; 131 | } 132 | return 0; 133 | } 134 | 135 | int batch_write_sample(ofstream& os, TVectorArray& x_array, TFloatArray& y_array, int& n){ 136 | TString s; 137 | n = 0; 138 | for (int i = 0; i < x_array.size(); i++){ 139 | write_sample(s, x_array[i], y_array[i]); 140 | os << s << endl; 141 | n += 1; 142 | } 143 | return 0; 144 | } 145 | 146 | int read_sample(TString& s, TVector& x, float& y){ 147 | int key = -1; 148 | float val = 0.0; 149 | TStringArray s_arr; 150 | split(s, ' ', s_arr); 151 | 152 | y = atof(s_arr[0].c_str()); 153 | x.clear(); 154 | for (int i = 1; i < s_arr.size(); i++){ 155 | TStringArray kv; 156 | split(s_arr[i], ':', kv); 157 | key = atoi(kv[0].c_str()); 158 | val = atof(kv[1].c_str()); 159 | TVectorDim p(key, val); 160 | x.push_back(p); 161 | } 162 | sort(x.begin(), x.end(), cmp); 163 | return 0; 164 | } 165 | 166 | int write_sample(TString& s, TVector& x, float& y){ 167 | ostringstream oss; 168 | oss << y; 169 | for (int i = 0; i < x.size(); i++){ 170 | oss << ' ' << x[i].first << ':' << x[i].second; 171 | } 172 | s = oss.str(); 173 | return 0; 174 | } 175 | 176 | -------------------------------------------------------------------------------- /svm_common.h: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * 4 | * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved 5 | * 6 | ******************************************************************************* 7 | * 8 | * @file: svm_common.h 9 | * @author: mazefeng(mazefeng01@baidu.com) 10 | * @date: 2015/06/30 11:10:00 11 | * 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #ifndef SVM_COMMON_H 28 | #define SVM_COMMON_H 29 | 30 | #define MAX_PATH_LENGTH 256 31 | 32 | typedef std::string TString; 33 | typedef std::vector TStringArray; 34 | 35 | typedef std::pair TVectorDim; 36 | typedef std::vector TVector; 37 | typedef std::vector TVectorArray; 38 | 39 | typedef std::vector TFloatArray; 40 | 41 | int split(const TString& s, char c, TStringArray& v); 42 | bool cmp(const TVectorDim& p1, const TVectorDim& p2); 43 | 44 | int read_sample(TString& s, TVector& x, float& y); 45 | int write_sample(TString& s, TVector& x, float& y); 46 | int batch_read_sample(std::ifstream& is, TVectorArray& x_array, TFloatArray& y_array, int& n); 47 | int batch_write_sample(std::ofstream& os, TVectorArray& x_array, TFloatArray& y_array, int& n); 48 | 49 | void print_vector(const TVector& v); 50 | 51 | float dot_product(const TVector& v1, const TVector& v2); 52 | TVector operator*(const TVector& v, float f); 53 | TVector operator*(float f, const TVector& v); 54 | TVector operator+(const TVector& v1, const TVector& v2); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /svm_option.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * 4 | * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved 5 | * 6 | ******************************************************************************* 7 | * 8 | * @file: svm_option.cpp 9 | * @author: mazefeng(mazefeng01@baidu.com) 10 | * @date: 2015/06/30 11:10:00 11 | * 12 | */ 13 | 14 | #include "svm_common.h" 15 | #include "svm_option.h" 16 | 17 | using std::cout; 18 | using std::cerr; 19 | using std::endl; 20 | 21 | SVMOption::SVMOption(){ 22 | _c = SVM_OPTION_C; 23 | _eps = SVM_OPTION_EPSILON; 24 | _sig = SVM_OPTION_SIGMA; 25 | _is_linear_kernel = false; 26 | _fname_train[0] = '\0'; 27 | _fname_valid[0] = '\0'; 28 | _fname_model[0] = '\0'; 29 | _flags = 0; 30 | } 31 | 32 | SVMOption::~SVMOption(){} 33 | 34 | void SVMOption::print(){ 35 | cerr << 36 | "#========================================================\n" 37 | "# SVM Option: \n" 38 | "#========================================================\n" 39 | "# [c = " << _c << "]\n" 40 | "# [epsilon = " << _eps << "]\n" 41 | "# [sigma = " << _sig << "]\n" 42 | "# [is_linear_kernel = " << _is_linear_kernel << "]\n" 43 | "# [fname_train = " << _fname_train << "]\n" 44 | "# [fname_model = " << _fname_model << "]\n" 45 | "# [fname_valid = " << _fname_valid << "]\n" 46 | "#========================================================\n" 47 | << endl; 48 | } 49 | 50 | int SVMOption::parse_command_line(int argc, char *argv[]){ 51 | int option; 52 | const char *opt_string = ""; 53 | struct option long_opts[] = { 54 | {"train", 1, NULL, 0}, 55 | {"model", 1, NULL, 1}, 56 | {"validate", 1, NULL, 2}, 57 | {"linear_kernel", 0, NULL, 3}, 58 | {"c", 1, NULL, 4}, 59 | {"epsilon", 1, NULL, 5}, 60 | {"sigma", 1, NULL, 6}, 61 | {"help", 0, NULL, 7}, 62 | {0, 0, 0, 0} 63 | }; 64 | 65 | while ((option = getopt_long_only(argc, argv, opt_string, long_opts, NULL)) != -1){ 66 | switch (option) { 67 | case 0: 68 | _flags |= FLAG_TRAIN; 69 | memcpy(_fname_train, optarg, strlen(optarg)); 70 | _fname_train[strlen(optarg)] = '\0'; 71 | break; 72 | case 1: 73 | _flags |= FLAG_MODEL; 74 | memcpy(_fname_model, optarg, strlen(optarg)); 75 | _fname_model[strlen(optarg)] = '\0'; 76 | break; 77 | case 2: 78 | _flags |= FLAG_VALID; 79 | memcpy(_fname_valid, optarg, strlen(optarg)); 80 | _fname_valid[strlen(optarg)] = '\0'; 81 | break; 82 | case 3: 83 | _flags |= FLAG_LINEAR_KERNEL; 84 | _is_linear_kernel = true; 85 | break; 86 | case 4: 87 | _flags |= FLAG_C; 88 | _c = atof(optarg); 89 | break; 90 | case 5: 91 | _flags |= FLAG_EPSILON; 92 | _eps = atof(optarg); 93 | break; 94 | case 6: 95 | _flags |= FLAG_SIGMA; 96 | _sig = atof(optarg); 97 | break; 98 | case 7: 99 | _flags |= FLAG_HELP; 100 | break; 101 | } 102 | } 103 | 104 | if (!(_flags & FLAG_TRAIN)) return FLAG_TRAIN; 105 | if (!(_flags & FLAG_VALID)) return FLAG_VALID; 106 | if (!(_flags & FLAG_MODEL)) return FLAG_MODEL; 107 | return 0; 108 | } 109 | -------------------------------------------------------------------------------- /svm_option.h: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * 4 | * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved 5 | * 6 | ******************************************************************************* 7 | * 8 | * @file: svm_option.h 9 | * @author: mazefeng(mazefeng01@baidu.com) 10 | * @date: 2015/06/30 11:10:00 11 | * 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "svm_common.h" 28 | 29 | #ifndef SVM_OPTION_H 30 | #define SVM_OPTION_H 31 | 32 | #define FLAG_TRAIN (1<<0) 33 | #define FLAG_MODEL (1<<1) 34 | #define FLAG_VALID (1<<2) 35 | #define FLAG_LINEAR_KERNEL (1<<3) 36 | #define FLAG_C (1<<4) 37 | #define FLAG_EPSILON (1<<5) 38 | #define FLAG_SIGMA (1<<6) 39 | #define FLAG_HELP (1<<7) 40 | 41 | #define SVM_OPTION_C 1.0 42 | #define SVM_OPTION_EPSILON 0.001 43 | #define SVM_OPTION_SIGMA 4.0 44 | 45 | class SVMOption{ 46 | 47 | public: 48 | SVMOption(); 49 | ~SVMOption(); 50 | int parse_command_line(int argc, char *argv[]); 51 | void print(); 52 | 53 | public: 54 | float _c; 55 | float _eps; 56 | float _sig; 57 | bool _is_linear_kernel; 58 | char _fname_train[MAX_PATH_LENGTH]; 59 | char _fname_valid[MAX_PATH_LENGTH]; 60 | char _fname_model[MAX_PATH_LENGTH]; 61 | 62 | protected: 63 | int _flags; 64 | 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /svm_solver.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * 4 | * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved 5 | * 6 | ******************************************************************************* 7 | * 8 | * @file: svm_solver.cpp 9 | * @author: mazefeng(mazefeng01@baidu.com) 10 | * @date: 2015/06/30 11:10:00 11 | * 12 | */ 13 | 14 | #include "svm_common.h" 15 | #include "svm_solver.h" 16 | 17 | // using std::string; 18 | // using std::pair; 19 | // using std::vector; 20 | using std::ifstream; 21 | using std::ofstream; 22 | using std::setprecision; 23 | using std::cerr; 24 | using std::cout; 25 | using std::endl; 26 | 27 | SVMSolver::SVMSolver(SVMOption *opt){ 28 | this->_c = opt->_c; 29 | this->_eps = opt->_eps; 30 | this->_sig = opt->_sig; 31 | this->_is_linear_kernel = opt->_is_linear_kernel; 32 | this->_fname_train = opt->_fname_train; 33 | this->_fname_valid = opt->_fname_valid; 34 | this->_fname_model = opt->_fname_model; 35 | 36 | _n = 0; 37 | _n_sv = 0; 38 | _b = 0.0; 39 | _delta_b = 0.0; 40 | } 41 | 42 | SVMSolver::~SVMSolver(){} 43 | 44 | float SVMSolver::kernel(int i1, int i2){ 45 | float k = dot_product(_x_array[i1], _x_array[i2]); 46 | if (!_is_linear_kernel){ 47 | k *= -2.0; 48 | k += _d[i1] + _d[i2]; 49 | k /= -(2.0 * _sig * _sig); 50 | k = exp(k); 51 | } 52 | return k; 53 | } 54 | 55 | float SVMSolver::learned_func(int k){ 56 | float s = 0.0; 57 | if (_is_linear_kernel){ 58 | s = dot_product(_w, _x_array[k]); 59 | } 60 | else{ 61 | for (int i = 0; i < _n; i++){ 62 | if (_alpha[i] > 0){ 63 | s += _alpha[i] * _y_array[i] * kernel(i, k); 64 | } 65 | } 66 | } 67 | s -= _b; 68 | return s; 69 | } 70 | 71 | int SVMSolver::predict(){ 72 | 73 | _x_array.clear(); 74 | _y_array.clear(); 75 | _w.clear(); 76 | _alpha.clear(); 77 | 78 | ifstream is_model(_fname_model); 79 | load_model(is_model); 80 | 81 | ifstream is_valid(_fname_valid); 82 | batch_read_sample(is_valid, _x_array, _y_array, _n); 83 | 84 | _n += _n_sv; 85 | 86 | if (!_is_linear_kernel){ 87 | _d.resize(_n); 88 | for (int i = 0; i < _n; i++){ 89 | _d[i] = dot_product(_x_array[i], _x_array[i]); 90 | } 91 | } 92 | 93 | int n_correct = 0; 94 | float y_pred = 0.0; 95 | 96 | for (int i = _n_sv; i < _n; i++){ 97 | float s = 0.0; 98 | if (_is_linear_kernel){ 99 | s = dot_product(_w, _x_array[i]); 100 | } 101 | else{ 102 | for (int j = 0; j < _n_sv; j++){ 103 | s += _alpha[j] * _y_array[j] * kernel(i, j); 104 | } 105 | } 106 | s -= _b; 107 | y_pred = s >= 0.0? 1.0 : -1.0; 108 | cout << y_pred << endl; 109 | if ((y_pred > 0 and _y_array[i] > 0) || (y_pred < 0 and _y_array[i] < 0)){ 110 | n_correct++; 111 | } 112 | } 113 | 114 | cerr << setprecision(5) 115 | << "Accuracy: " << 100.0 * n_correct / (_n - _n_sv) 116 | << "% (" << n_correct << "/" << (_n - _n_sv) << ")" 117 | << endl; 118 | 119 | return 0; 120 | } 121 | 122 | int SVMSolver::train(){ 123 | 124 | _x_array.clear(); 125 | _y_array.clear(); 126 | _w.clear(); 127 | _d.clear(); 128 | 129 | ifstream is_train(_fname_train); 130 | batch_read_sample(is_train, _x_array, _y_array, _n); 131 | 132 | _alpha.resize(_n, 0.0); 133 | _b = 0.0; 134 | _error_cache.resize(_n, 0.0); 135 | 136 | if (!_is_linear_kernel){ 137 | _d.resize(_n); 138 | for (int i = 0; i < _n; i++){ 139 | _d[i] = dot_product(_x_array[i], _x_array[i]); 140 | } 141 | } 142 | 143 | int num_changed = 0; 144 | int examine_all = 1; 145 | while (num_changed > 0 || examine_all){ 146 | num_changed = 0; 147 | if (examine_all){ 148 | for (int k = 0; k < _n; k++){ 149 | num_changed += examine_example(k); 150 | } 151 | } 152 | else{ 153 | for (int k = 0; k < _n; k++){ 154 | if (_alpha[k] != 0 && _alpha[k] != _c){ 155 | num_changed += examine_example(k); 156 | } 157 | } 158 | } 159 | 160 | if (examine_all == 1){ 161 | examine_all = 0; 162 | } 163 | else if (num_changed == 0){ 164 | examine_all = 1; 165 | } 166 | 167 | float s = 0.0; 168 | float t = 0.0; 169 | float obj = 0.0; 170 | for (int i = 0; i < _n; i++){ 171 | s += _alpha[i]; 172 | } 173 | 174 | for (int i = 0; i < _n; i++){ 175 | for (int j = 0; j < _n; j++){ 176 | t += _alpha[i] * _alpha[j] * _y_array[i] * _y_array[j] * kernel(i, j); 177 | } 178 | } 179 | 180 | obj = s - 0.5 * t; 181 | cerr << setprecision(5) 182 | << "Objective func : " << obj << "\t\t\t" 183 | << "Error rate : " << error_rate() 184 | << endl; 185 | 186 | for (int i = 0; i < _n; i++){ 187 | if (_alpha[i] < 1e-6){ 188 | _alpha[i] = 0.0; 189 | } 190 | } 191 | } 192 | 193 | ofstream os_model(_fname_model); 194 | dump_model(os_model); 195 | 196 | return 0; 197 | } 198 | 199 | int SVMSolver::dump_model(ofstream& os){ 200 | TString s; 201 | 202 | os << _is_linear_kernel << endl; 203 | os << _b << endl; 204 | if (_is_linear_kernel){ 205 | os << _w.size() << endl; 206 | for (int i = 0; i < _w.size(); i++){ 207 | os << _w[i].first << ' ' << _w[i].second << endl; 208 | } 209 | } 210 | else{ 211 | os << _sig << endl; 212 | _n_sv = 0; 213 | for (int i = 0; i < _n; i++){ 214 | if (_alpha[i] > 0){ 215 | _n_sv += 1; 216 | } 217 | } 218 | os << _n_sv << endl; 219 | 220 | for (int i = 0; i < _n; i++){ 221 | if (_alpha[i] > 0){ 222 | os << _alpha[i] << endl; 223 | } 224 | } 225 | 226 | for (int i = 0; i < _n; i++){ 227 | if (_alpha[i] > 0){ 228 | write_sample(s, _x_array[i], _y_array[i]); 229 | os << s << endl; 230 | } 231 | } 232 | } 233 | } 234 | 235 | int SVMSolver::load_model(ifstream& is){ 236 | 237 | int d = 0; 238 | int m = 0; 239 | TString s; 240 | 241 | is >> _is_linear_kernel; 242 | is >> _b; 243 | if (_is_linear_kernel){ 244 | is >> d; 245 | for (int i = 0; i < d; i++){ 246 | TVectorDim p; 247 | is >> p.first >> p.second; 248 | _w.push_back(p); 249 | } 250 | sort(_w.begin(), _w.end(), cmp); 251 | } 252 | else{ 253 | is >> _sig; 254 | is >> _n_sv; 255 | _alpha.resize(_n_sv, 0.0); 256 | for (int i = 0; i < _n_sv; i++){ 257 | is >> _alpha[i]; 258 | } 259 | getline(is, s, '\n'); 260 | batch_read_sample(is, _x_array, _y_array, m); 261 | 262 | } 263 | return 0; 264 | } 265 | 266 | float SVMSolver::error_rate(){ 267 | int n_error = 0; 268 | for (int i = 0; i < _n; i++){ 269 | if ((learned_func(i) >= 0 && _y_array[i] < 0) || (learned_func(i) < 0 && _y_array[i] > 0)){ 270 | n_error++; 271 | } 272 | } 273 | return 1.0 * n_error / _n; 274 | } 275 | 276 | int SVMSolver::examine_example(int i1) { 277 | float y1 = 0.0; 278 | float _alpha1 = 0.0; 279 | float e1 = 0.0; 280 | float r1 = 0.0; 281 | 282 | y1 = _y_array[i1]; 283 | _alpha1 = _alpha[i1]; 284 | if (_alpha1 > 0 && _alpha1 < _c){ 285 | e1 = _error_cache[i1]; 286 | } 287 | else{ 288 | e1 = learned_func(i1) - y1; 289 | } 290 | 291 | r1 = y1 * e1; 292 | if ((r1 < -TOLERANCE && _alpha1 < _c) || (r1 > TOLERANCE && _alpha1 > 0)) { 293 | int k0 = 0; 294 | int k = 0; 295 | int i2 = -1; 296 | float tmax = 0.0; 297 | for (i2 = -1, tmax = 0, k = 0; k < _n; k++) { 298 | if (_alpha[k] > 0 && _alpha[k] < _c){ 299 | float e2 = 0.0; 300 | float temp = 0.0; 301 | e2 = _error_cache[k]; 302 | temp = fabs(e1 - e2); 303 | if (temp > tmax) { 304 | tmax = temp; 305 | i2 = k; 306 | } 307 | } 308 | if (i2 >= 0) { 309 | if (take_step(i1, i2)){ 310 | return 1; 311 | } 312 | } 313 | } 314 | for (k0 = (int)(drand48() * _n), k = k0; k < _n + k0; k++) { 315 | i2 = k % _n; 316 | if (_alpha[i2] > 0 && _alpha[i2] < _c) { 317 | if (take_step(i1, i2)){ 318 | return 1; 319 | } 320 | } 321 | } 322 | for (k0 = (int)(drand48() * _n), k = k0; k < _n + k0; k++){ 323 | i2 = k % _n; 324 | if (take_step(i1, i2)){ 325 | return 1; 326 | } 327 | } 328 | } 329 | return 0; 330 | } 331 | 332 | int SVMSolver::take_step(int i1, int i2){ 333 | int y1 = 0; 334 | int y2 = 0; 335 | int s = 0; 336 | float _alpha1 = 0.0; 337 | float _alpha2 = 0.0; 338 | float a1 = 0.0; 339 | float a2 = 0.0; 340 | float e1 = 0.0; 341 | float e2 = 0.0; 342 | float low = 0.0; 343 | float high = 0.0; 344 | float k11 = 0.0; 345 | float k22 = 0.0; 346 | float k12 = 0.0; 347 | float eta = 0.0; 348 | float low_obj = 0.0; 349 | float high_obj = 0.0; 350 | if (i1 == i2){ 351 | return 0; 352 | } 353 | 354 | _alpha1 = _alpha[i1]; 355 | _alpha2 = _alpha[i2]; 356 | y1 = _y_array[i1]; 357 | y2 = _y_array[i2]; 358 | 359 | if (_alpha1 > 0 && _alpha1 < _c){ 360 | e1 = _error_cache[i1]; 361 | } 362 | else{ 363 | e1 = learned_func(i1) - y1; 364 | } 365 | if (_alpha2 > 0 && _alpha2 < _c){ 366 | e2 = _error_cache[i2]; 367 | } 368 | else{ 369 | e2 = learned_func(i2) - y2; 370 | } 371 | s = y1 * y2; 372 | if (y1 == y2) { 373 | float gamma = _alpha1 + _alpha2; 374 | if (gamma > _c) { 375 | low = gamma - _c; 376 | high = _c; 377 | } 378 | else { 379 | low = 0; 380 | high = gamma; 381 | } 382 | } 383 | else{ 384 | float gamma = _alpha1 - _alpha2; 385 | if (gamma > 0){ 386 | low = 0; 387 | high = _c - gamma; 388 | } 389 | else{ 390 | low = -gamma; 391 | high = _c; 392 | } 393 | } 394 | 395 | if (fabs(low - high) < 1e-6){ 396 | return 0; 397 | } 398 | 399 | k11 = kernel(i1, i1); 400 | k12 = kernel(i1, i2); 401 | k22 = kernel(i2, i2); 402 | eta = 2 * k12 - k11 - k22; 403 | 404 | if (eta < 0) { 405 | a2 = _alpha2 + y2 * (e2 - e1) / eta; 406 | if (a2 < low){ 407 | a2 = low; 408 | } 409 | else if (a2 > high){ 410 | a2 = high; 411 | } 412 | } 413 | else { 414 | float c1 = eta / 2.0; 415 | float c2 = y2 * (e1 - e2) - eta * _alpha2; 416 | low_obj = c1 * low * low + c2 * low; 417 | high_obj = c1 * high * high + c2 * high; 418 | if (low_obj > high_obj + _eps){ 419 | a2 = low; 420 | } 421 | else if (low_obj < high_obj - _eps){ 422 | a2 = high; 423 | } 424 | else{ 425 | a2 = _alpha2; 426 | } 427 | } 428 | 429 | if (fabs(a2 - _alpha2) < _eps * (a2 + _alpha2 + _eps)){ 430 | return 0; 431 | } 432 | a1 = _alpha1 - s * (a2 - _alpha2); 433 | if (a1 < 0) { 434 | a2 += s * a1; 435 | a1 = 0; 436 | } 437 | else if (a1 > _c){ 438 | float t = a1 - _c; 439 | a2 += s * t; 440 | a1 = _c; 441 | } 442 | 443 | float b1 = 0.0; 444 | float b2 = 0.0; 445 | float bnew = 0.0; 446 | if (a1 > 0 && a1 < _c){ 447 | bnew = _b + e1 + y1 * (a1 - _alpha1) * k11 + y2 * (a2 - _alpha2) * k12; 448 | } 449 | else if (a2 > 0 && a2 < _c){ 450 | bnew = _b + e2 + y1 * (a1 - _alpha1) * k12 + y2 * (a2 - _alpha2) * k22; 451 | } 452 | else{ 453 | b1 = _b + e1 + y1 * (a1 - _alpha1) * k11 + y2 * (a2 - _alpha2) * k12; 454 | b2 = _b + e2 + y1 * (a1 - _alpha1) * k12 + y2 * (a2 - _alpha2) * k22; 455 | bnew = (b1 + b2) / 2.0; 456 | } 457 | 458 | _delta_b = bnew - _b; 459 | _b = bnew; 460 | 461 | float t1 = y1 * (a1 - _alpha1); 462 | float t2 = y2 * (a2 - _alpha2); 463 | 464 | if (_is_linear_kernel){ 465 | _w = _w + t1 * _x_array[i1] + t2 * _x_array[i2]; 466 | } 467 | 468 | for (int i = 0; i < _n; i++){ 469 | if (_alpha[i] > 0 && _alpha[i] < _c){ 470 | _error_cache[i] += t1 * kernel(i1, i) + t2 * kernel(i2, i) - _delta_b; 471 | } 472 | } 473 | 474 | _error_cache[i1] = 0.0; 475 | _error_cache[i2] = 0.0; 476 | 477 | _alpha[i1] = a1; 478 | _alpha[i2] = a2; 479 | return 1; 480 | } 481 | 482 | -------------------------------------------------------------------------------- /svm_solver.h: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * 4 | * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved 5 | * 6 | ******************************************************************************* 7 | * 8 | * @file: svm_solver.h 9 | * @author: mazefeng(mazefeng01@baidu.com) 10 | * @date: 2015/06/30 11:10:00 11 | * 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "svm_common.h" 29 | #include "svm_option.h" 30 | 31 | #ifndef SVM_SOLVER_H 32 | #define SVM_SOLVER_H 33 | 34 | #define TOLERANCE 1e-6 35 | 36 | class SVMSolver{ 37 | public: 38 | SVMSolver(SVMOption *opt); 39 | ~SVMSolver(); 40 | int train(); 41 | int predict(); 42 | 43 | protected: 44 | 45 | float error_rate(); 46 | 47 | int load_model(std::ifstream& is); 48 | int dump_model(std::ofstream& os); 49 | 50 | float kernel(int i1, int i2); 51 | float learned_func(int k); 52 | 53 | int examine_example(int i1); 54 | int take_step(int i1, int i2); 55 | 56 | protected: 57 | 58 | // input options 59 | float _c; 60 | float _eps; 61 | float _sig; 62 | bool _is_linear_kernel; 63 | const char *_fname_train; 64 | const char *_fname_valid; 65 | const char *_fname_model; 66 | 67 | // internal options 68 | int _n; 69 | int _n_sv; 70 | TVectorArray _x_array; 71 | TFloatArray _y_array; 72 | TVector _w; 73 | 74 | TFloatArray _alpha; 75 | TFloatArray _d; 76 | TFloatArray _error_cache; 77 | float _b; 78 | float _delta_b; 79 | 80 | }; 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | LOCAL_CVS_ROOT=../.. 2 | 3 | MAC_BIT := $(shell /usr/bin/getconf LONG_BIT) 4 | ifeq ($(MAC_BIT),64) 5 | LIB2_DIR=$(LOCAL_CVS_ROOT)/lib2-64 6 | THIRD_DIR=$(LOCAL_CVS_ROOT)/third-64 7 | else 8 | LIB2_DIR=$(LOCAL_CVS_ROOT)/lib2 9 | THIRD_DIR=$(LOCAL_CVS_ROOT)/third 10 | endif 11 | BTEST_BASE := $(THIRD_DIR)/btest 12 | 13 | CXXFLAGS=-fPIC -g -finline-functions -Wall -W -Winline -pipe -Wreturn-type -Wtrigraphs -Wformat -Wparentheses -Wpointer-arith -Werror -Wno-unused-parameter -D_GNU_SOURCE -Wno-deprecated 14 | CFLAGS=$(CXXFLAGS) 15 | INCPATH= -I.. -I$(LOCAL_CVS_ROOT)/com/btest/gtest/output/include -I. 16 | DEP_LDFLAGS= -L.. -L$(LOCAL_CVS_ROOT)/com/btest/gtest/output/lib -L. 17 | DEP_LDLIBS= -lsvm -lgtest -lgtest_main -lpthread 18 | CXX=g++ 19 | CC = gcc 20 | 21 | PATTERN=test*.cpp 22 | TESTFILES=$(wildcard $(PATTERN)) 23 | EXE=$(basename $(TESTFILES)) 24 | all : $(EXE) 25 | $(EXE) : % : %.cpp 26 | $(CXX) $^ -o $@ $(CXXFLAGS) $(CFLAGS) $(INCPATH) $(DEP_LDFLAGS) $(DEP_LDLIBS) 27 | .PHONY: list clean 28 | list: 29 | @echo $(EXE) 30 | clean: 31 | rm -f $(EXE) 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/analysis.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazefeng/svm/708eba85d41ac19790848523594b4a7df1355f71/test/analysis.conf -------------------------------------------------------------------------------- /test/data/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 0 5 | https://svn.baidu.com/goodcoder/trunk/mazefeng01/C++-id-7127/test/data 6 | https://svn.baidu.com/goodcoder 7 | add 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 688347a3-1a7e-4d08-b7af-20cad322083a 28 | 29 | test_batch_read_sample.dat 30 | file 31 | 32 | 33 | 34 | add 35 | 36 | heart_scale.shuffle 37 | file 38 | 39 | 40 | 41 | add 42 | 43 | heart_scale.train 44 | file 45 | 46 | 47 | 48 | add 49 | 50 | heart_scale.test 51 | file 52 | 53 | 54 | 55 | add 56 | 57 | heart_scale.model 58 | file 59 | 60 | 61 | 62 | add 63 | 64 | -------------------------------------------------------------------------------- /test/data/heart_scale.shuffle: -------------------------------------------------------------------------------- 1 | -1 1:-0.5 2:-1 3:-0.333333 4:-0.396226 5:-0.178082 6:-1 7:-1 8:0.40458 9:-1 10:-1 11:-1 12:-1 13:-1 2 | +1 1:0.208333 2:1 3:0.333333 4:-0.283019 5:-0.552511 6:-1 7:1 8:0.557252 9:-1 10:0.0322581 11:-1 12:0.333333 13:1 3 | -1 2:1 3:0.333333 4:-0.320755 5:-0.675799 6:1 7:1 8:0.236641 9:-1 10:-0.612903 11:1 12:-1 13:-1 4 | +1 1:0.0833333 2:1 3:1 4:-0.283019 5:0.0365297 6:-1 7:-1 8:-0.0687023 9:1 10:-0.612903 12:-0.333333 13:1 5 | +1 1:0.5 2:1 3:-1 4:-0.169811 5:-0.287671 6:1 7:1 8:0.572519 9:-1 10:-0.548387 12:-0.333333 13:-1 6 | -1 1:-0.333333 2:-1 3:-0.333333 4:-0.320755 5:-0.506849 6:-1 7:1 8:0.587786 9:-1 10:-0.806452 12:-1 13:-1 7 | +1 1:-0.75 2:1 3:1 4:-0.509434 5:-0.671233 6:-1 7:-1 8:-0.0992366 9:1 10:-0.483871 12:-1 13:1 8 | -1 1:0.416667 2:-1 3:0.333333 4:-0.226415 5:-0.424658 6:-1 7:1 8:0.541985 9:-1 10:-1 11:-1 12:-1 13:-1 9 | +1 1:0.166667 2:1 3:1 4:0.0566038 5:-0.315068 6:-1 7:1 8:-0.374046 9:1 10:-0.806452 12:-0.333333 13:0.5 10 | -1 1:-0.333333 2:-1 3:1 4:-0.169811 5:-0.497717 6:-1 7:1 8:0.236641 9:1 10:-0.935484 12:-1 13:-1 11 | +1 1:-0.125 2:1 3:1 4:-0.0566038 5:-0.6621 6:-1 7:1 8:-0.160305 9:1 10:-0.709677 12:-1 13:1 12 | +1 1:0.125 2:1 3:1 4:-0.283019 5:-0.73516 6:-1 7:1 8:-0.480916 9:1 10:-0.322581 12:-0.333333 13:0.5 13 | -1 1:0.416667 2:1 3:-1 4:-0.0377358 5:-0.511416 6:1 7:1 8:0.206107 9:-1 10:-0.258065 11:1 12:-1 13:0.5 14 | -1 1:0.458333 2:-1 3:1 4:-0.320755 5:-0.191781 6:-1 7:-1 8:-0.221374 9:-1 10:-0.354839 12:0.333333 13:-1 15 | -1 1:-0.5 2:1 3:0.333333 4:-0.660377 5:-0.43379 6:-1 7:-1 8:0.648855 9:-1 10:-1 11:-1 12:-1 13:-1 16 | +1 1:-0.416667 2:1 3:1 4:-0.509434 5:-0.767123 6:-1 7:1 8:-0.251908 9:1 10:-0.193548 12:-1 13:1 17 | +1 1:0.166667 2:1 3:1 4:0.339623 5:-0.255708 6:1 7:1 8:-0.19084 9:-1 10:-0.677419 12:1 13:1 18 | +1 1:0.375 2:1 3:-0.333333 4:-0.509434 5:-0.292237 6:-1 7:1 8:-0.51145 9:-1 10:-0.548387 12:-0.333333 13:1 19 | -1 1:0.416667 2:-1 3:-0.333333 4:-0.132075 5:-0.684932 6:-1 7:-1 8:0.648855 9:-1 10:-1 11:-1 12:0.333333 13:-1 20 | -1 1:-0.125 2:-1 3:-0.333333 4:-0.509434 5:-0.461187 6:-1 7:-1 8:0.389313 9:-1 10:-0.645161 11:-1 12:-1 13:-1 21 | +1 1:0.0416667 2:1 3:1 4:-0.471698 5:-0.269406 6:-1 7:1 8:-0.312977 9:1 10:0.0322581 12:0.333333 13:-1 22 | -1 1:0.541667 2:1 3:1 4:0.245283 5:-0.534247 6:-1 7:1 8:0.0229008 9:-1 10:-0.258065 11:-1 12:-1 13:0.5 23 | -1 1:-0.5 2:-1 3:0.333333 4:-0.660377 5:-0.351598 6:-1 7:1 8:0.541985 9:1 10:-1 11:-1 12:-1 13:-1 24 | +1 1:0.125 2:1 3:0.333333 4:-0.320755 5:-0.406393 6:1 7:1 8:0.0839695 9:1 10:-0.806452 12:-0.333333 13:0.5 25 | +1 1:0.333333 2:-1 3:1 4:-0.320755 5:-0.0684932 6:-1 7:1 8:0.496183 9:-1 10:-1 11:-1 12:-1 13:-1 26 | +1 1:0.208333 2:1 3:1 4:-0.415094 5:-0.205479 6:-1 7:1 8:0.526718 9:-1 10:-1 11:-1 12:0.333333 13:1 27 | -1 1:-0.333333 2:1 3:1 4:-0.811321 5:-0.625571 6:-1 7:1 8:0.175573 9:1 10:-0.0322581 12:-1 13:-1 28 | -1 1:0.625 2:1 3:0.333333 4:-0.54717 5:-0.310502 6:-1 7:-1 8:0.221374 9:-1 10:-0.677419 11:-1 12:-0.333333 13:1 29 | +1 1:0.333333 2:-1 3:1 4:-0.0377358 5:-0.173516 6:-1 7:1 8:0.145038 9:1 10:-0.677419 12:-1 13:1 30 | +1 1:0.375 2:-1 3:1 4:0.245283 5:-0.826484 6:-1 7:1 8:0.129771 9:-1 10:1 11:1 12:1 13:1 31 | -1 1:0.208333 2:-1 3:0.333333 4:-0.509434 5:-0.0228311 6:-1 7:-1 8:0.541985 9:-1 10:-1 11:-1 12:-1 13:-1 32 | +1 1:-0.333333 2:1 3:1 4:-0.0943396 5:-0.164384 6:-1 7:1 8:0.160305 9:1 10:-1 12:1 13:1 33 | +1 1:-0.291667 2:1 3:1 4:-0.132075 5:-0.155251 6:-1 7:-1 8:-0.251908 9:1 10:-0.419355 12:0.333333 13:1 34 | -1 1:-0.208333 2:-1 3:0.333333 4:-0.320755 5:-0.319635 6:-1 7:-1 8:0.0381679 9:-1 10:-0.935484 11:-1 12:-1 13:-1 35 | -1 1:0.166667 2:1 3:0.333333 4:0.0566038 5:-1 6:1 7:-1 8:0.557252 9:-1 10:-0.935484 11:-1 12:-0.333333 13:1 36 | +1 1:-0.0833333 2:1 3:1 4:-0.132075 5:-0.214612 6:-1 7:-1 8:-0.221374 9:1 10:0.354839 12:1 13:1 37 | +1 1:0.666667 2:1 3:0.333333 4:-0.132075 5:-0.415525 6:-1 7:1 8:0.145038 9:-1 10:-0.354839 12:1 13:1 38 | -1 1:-0.0416667 2:1 3:-1 4:0.0943396 5:-0.214612 6:1 7:-1 8:0.633588 9:-1 10:-0.612903 12:-1 13:1 39 | +1 1:0.416667 2:1 3:1 4:-0.320755 5:-0.415525 6:-1 7:1 8:0.160305 9:-1 10:-0.548387 12:-0.333333 13:1 40 | +1 1:0.25 2:1 3:-1 4:0.245283 5:-0.328767 6:-1 7:1 8:-0.175573 9:-1 10:-1 11:-1 12:-1 13:-1 41 | -1 1:0.166667 2:1 3:1 4:-0.283019 5:-0.630137 6:-1 7:-1 8:0.480916 9:1 10:-1 11:-1 12:-1 13:1 42 | -1 1:0.875 2:-1 3:-0.333333 4:-0.509434 5:-0.347032 6:-1 7:1 8:-0.236641 9:1 10:-0.935484 11:-1 12:-0.333333 13:-1 43 | +1 1:0.541667 2:1 3:1 4:-0.660377 5:-0.607306 6:-1 7:1 8:-0.0687023 9:1 10:-0.967742 11:-1 12:-0.333333 13:-1 44 | +1 1:-0.0833333 2:-1 3:1 4:-0.320755 5:-0.182648 6:-1 7:-1 8:0.0839695 9:1 10:-0.612903 12:-1 13:1 45 | +1 1:0.291667 2:1 3:1 4:-0.132075 5:-0.237443 6:-1 7:1 8:0.51145 9:-1 10:-0.612903 12:0.333333 13:1 46 | +1 1:0.375 2:1 3:1 4:-0.509434 5:-0.356164 6:-1 7:-1 8:-0.572519 9:1 10:-0.419355 12:0.333333 13:1 47 | +1 1:-0.166667 2:1 3:0.333333 4:-0.509434 5:-0.716895 6:-1 7:-1 8:0.0381679 9:-1 10:-0.354839 12:1 13:1 48 | -1 1:-0.208333 2:1 3:1 4:-0.471698 5:-0.561644 6:-1 7:1 8:0.755725 9:-1 10:-1 11:-1 12:-1 13:-1 49 | +1 1:0.25 2:1 3:1 4:-0.698113 5:-0.484018 6:-1 7:1 8:0.0839695 9:1 10:-0.612903 12:-0.333333 13:1 50 | -1 1:0.541667 2:1 3:1 4:-0.509434 5:-0.196347 6:-1 7:1 8:0.221374 9:-1 10:-0.870968 12:-1 13:-1 51 | -1 1:-0.0416667 2:1 3:1 4:-0.735849 5:-0.511416 6:1 7:-1 8:0.160305 9:-1 10:-0.967742 11:-1 12:1 13:1 52 | +1 1:0.291667 2:1 3:1 4:-0.0377358 5:-0.287671 6:-1 7:1 8:0.0839695 9:1 10:-0.0967742 12:0.333333 13:1 53 | -1 1:0.625 2:-1 3:0.333333 4:-0.509434 5:-0.611872 6:-1 7:1 8:-0.328244 9:-1 10:-0.516129 12:-1 13:-1 54 | +1 1:0.708333 2:1 3:0.333333 4:0.245283 5:-0.347032 6:-1 7:-1 8:-0.374046 9:1 10:-0.0645161 12:-0.333333 13:1 55 | -1 2:1 3:1 4:-0.0943396 5:-0.543379 6:-1 7:1 8:-0.389313 9:1 10:-1 11:-1 12:-1 13:1 56 | -1 1:0.208333 2:1 3:0.333333 4:-0.132075 5:-0.611872 6:1 7:1 8:0.435115 9:-1 10:-1 11:-1 12:-1 13:-1 57 | +1 1:0.166667 2:1 3:1 4:0.0943396 5:-0.324201 6:-1 7:-1 8:-0.740458 9:1 10:-0.612903 12:-0.333333 13:1 58 | -1 1:0.125 2:-1 3:-0.333333 4:-0.132075 5:-0.232877 6:-1 7:1 8:0.251908 9:-1 10:-0.580645 12:-1 13:-1 59 | +1 1:0.25 2:1 3:-1 4:0.433962 5:-0.260274 6:-1 7:1 8:0.343511 9:-1 10:-0.935484 12:-1 13:1 60 | -1 1:0.0416667 2:-1 3:0.333333 4:-0.735849 5:-0.356164 6:-1 7:1 8:0.465649 9:-1 10:-1 11:-1 12:-1 13:-1 61 | -1 1:-0.458333 2:-1 3:1 4:-0.849057 5:-0.365297 6:-1 7:1 8:-0.221374 9:-1 10:-0.806452 12:-1 13:-1 62 | -1 1:0.0416667 2:1 3:0.333333 4:-0.415094 5:-0.328767 6:-1 7:1 8:0.236641 9:-1 10:-0.83871 11:1 12:-0.333333 13:-1 63 | -1 1:0.708333 2:1 3:-0.333333 4:0.169811 5:-0.456621 6:-1 7:1 8:0.0992366 9:-1 10:-1 11:-1 12:-1 13:-1 64 | -1 1:0.25 2:1 3:-0.333333 4:-0.132075 5:-0.56621 6:-1 7:-1 8:0.419847 9:1 10:-1 11:-1 12:-1 13:-1 65 | +1 1:0.458333 2:1 3:1 4:-0.0377358 5:-0.607306 6:-1 7:1 8:-0.0687023 9:-1 10:-0.354839 12:0.333333 13:0.5 66 | +1 1:0.416667 2:1 3:1 4:-0.320755 5:-0.0684932 6:1 7:1 8:-0.0687023 9:1 10:-0.419355 11:-1 12:1 13:1 67 | -1 1:0.5 2:-1 3:0.333333 4:-0.132075 5:0.328767 6:1 7:1 8:0.312977 9:-1 10:-0.741935 11:-1 12:-0.333333 13:-1 68 | +1 1:0.583333 2:1 3:1 4:-0.415094 5:-0.415525 6:1 7:-1 8:0.40458 9:-1 10:-0.935484 12:0.333333 13:1 69 | -1 1:0.583333 2:-1 3:1 4:-0.773585 5:-0.557078 6:-1 7:-1 8:0.0839695 9:-1 10:-0.903226 11:-1 12:0.333333 13:-1 70 | -1 1:-0.0833333 2:1 3:0.333333 4:-1 5:-0.538813 6:-1 7:-1 8:0.267176 9:1 10:-1 11:-1 12:-0.333333 13:1 71 | -1 1:0.666667 2:1 3:-1 4:0.245283 5:-0.506849 6:1 7:1 8:-0.0839695 9:-1 10:-0.967742 12:-0.333333 13:-1 72 | -1 1:-0.5 2:1 3:-0.333333 4:-0.698113 5:-0.502283 6:-1 7:-1 8:0.251908 9:-1 10:-1 11:-1 12:-1 13:-1 73 | +1 1:0.583333 2:1 3:1 4:0.245283 5:-0.269406 6:-1 7:1 8:-0.435115 9:1 10:-0.516129 12:1 13:-1 74 | -1 1:-0.0833333 2:-1 3:0.333333 4:-0.320755 5:-0.406393 6:-1 7:1 8:0.19084 9:-1 10:-0.83871 11:-1 12:-1 13:-1 75 | -1 1:-0.166667 2:-1 3:1 4:-0.320755 5:-0.347032 6:-1 7:-1 8:0.40458 9:-1 10:-1 11:-1 12:-1 13:-1 76 | -1 1:-0.583333 2:-1 3:0.333333 4:-1 5:-0.666667 6:-1 7:-1 8:0.648855 9:-1 10:-1 11:-1 12:-1 13:-1 77 | -1 1:0.458333 2:1 3:1 4:-0.358491 5:-0.374429 6:-1 7:-1 8:-0.480916 9:1 10:-0.935484 12:-0.333333 13:1 78 | -1 1:0.208333 2:-1 3:1 4:-0.886792 5:-0.442922 6:-1 7:1 8:-0.221374 9:-1 10:-0.677419 12:-1 13:-1 79 | -1 1:-0.0416667 2:-1 3:0.333333 4:-0.207547 5:-0.680365 6:-1 7:1 8:0.496183 9:-1 10:-0.967742 12:-1 13:-1 80 | +1 1:0.333333 2:1 3:1 4:-0.169811 5:-0.817352 6:-1 7:1 8:-0.175573 9:1 10:0.16129 12:-0.333333 13:-1 81 | +1 1:-0.208333 2:1 3:1 4:-0.433962 5:-0.324201 6:-1 7:1 8:0.450382 9:-1 10:-0.83871 12:-1 13:1 82 | +1 1:0.125 2:-1 3:1 4:-0.245283 5:0.292237 6:-1 7:1 8:0.206107 9:1 10:-0.387097 12:0.333333 13:1 83 | +1 1:-0.125 2:1 3:1 4:0.0566038 5:-0.465753 6:-1 7:1 8:-0.129771 9:-1 10:-0.16129 12:-1 13:1 84 | +1 1:0.25 2:1 3:0.333333 4:-0.396226 5:-0.579909 6:1 7:-1 8:-0.0381679 9:-1 10:-0.290323 12:-0.333333 13:0.5 85 | +1 1:0.208333 2:-1 3:-0.333333 4:-0.207547 5:-0.118721 6:1 7:1 8:0.236641 9:-1 10:-1 11:-1 12:0.333333 13:-1 86 | -1 1:0.0416667 2:-1 3:0.333333 4:-0.698113 5:-0.598174 6:-1 7:-1 8:0.328244 9:-1 10:-0.483871 12:-1 13:-1 87 | +1 1:-0.375 2:1 3:1 4:-0.660377 5:-0.251142 6:-1 7:1 8:0.251908 9:-1 10:-1 11:-1 12:-0.333333 13:-1 88 | +1 1:0.416667 2:-1 3:1 4:-0.735849 5:-0.347032 6:-1 7:-1 8:0.496183 9:1 10:-0.419355 12:0.333333 13:-1 89 | +1 1:-0.125 2:1 3:0.333333 4:-0.132075 5:-0.511416 6:-1 7:-1 8:0.40458 9:-1 10:-0.806452 12:-0.333333 13:1 90 | -1 2:-1 3:1 4:-0.320755 5:-0.369863 6:-1 7:1 8:0.0992366 9:-1 10:-0.870968 12:-1 13:-1 91 | -1 1:-0.458333 2:1 3:1 4:-0.132075 5:-0.543379 6:-1 7:-1 8:0.633588 9:-1 10:-1 11:-1 12:-1 13:-1 92 | +1 1:0.375 2:-1 3:1 4:-0.132075 5:-0.351598 6:-1 7:1 8:0.358779 9:-1 10:0.16129 11:1 12:0.333333 13:-1 93 | -1 1:0.0416667 2:1 3:0.333333 4:0.0566038 5:-0.515982 6:-1 7:1 8:0.435115 9:-1 10:-0.483871 11:-1 12:-1 13:1 94 | +1 1:-0.583333 2:1 3:1 4:-0.54717 5:-0.575342 6:-1 7:-1 8:0.0534351 9:-1 10:-0.612903 12:-1 13:1 95 | -1 1:0.75 2:-1 3:1 4:-0.660377 5:-0.894977 6:-1 7:-1 8:-0.175573 9:-1 10:-0.483871 12:-1 13:-1 96 | +1 1:0.0833333 2:1 3:1 4:-0.132075 5:-0.584475 6:-1 7:-1 8:-0.389313 9:1 10:0.806452 11:1 12:-1 13:1 97 | +1 1:0.208333 2:1 3:-0.333333 4:-0.509434 5:-0.278539 6:-1 7:1 8:0.358779 9:-1 10:-0.419355 12:-1 13:-1 98 | -1 1:-0.375 2:1 3:-0.333333 4:-0.509434 5:-0.570776 6:-1 7:-1 8:0.51145 9:-1 10:-1 11:-1 12:-1 13:-1 99 | +1 1:-0.0416667 2:1 3:1 4:-0.415094 5:-0.607306 6:-1 7:-1 8:0.480916 9:-1 10:-0.677419 11:-1 12:0.333333 13:1 100 | -1 1:-0.208333 2:1 3:0.333333 4:-0.433962 5:-0.410959 6:1 7:-1 8:0.587786 9:-1 10:-1 11:-1 12:0.333333 13:-1 101 | -1 1:0.291667 2:-1 3:-1 4:0.0566038 5:-0.479452 6:-1 7:-1 8:0.526718 9:-1 10:-0.709677 11:-1 12:-1 13:-1 102 | -1 1:0.666667 2:-1 3:-1 4:-0.132075 5:-0.484018 6:-1 7:-1 8:0.221374 9:-1 10:-0.419355 11:-1 12:0.333333 13:-1 103 | -1 1:0.125 2:1 3:-0.333333 4:-0.509434 5:-0.497717 6:-1 7:-1 8:0.633588 9:-1 10:-0.741935 11:-1 12:-1 13:-1 104 | +1 1:0.416667 2:-1 3:1 4:0.0566038 5:0.283105 6:-1 7:1 8:0.267176 9:-1 10:0.290323 12:1 13:1 105 | -1 1:-0.0833333 2:1 3:0.333333 4:-0.886792 5:-0.561644 6:-1 7:-1 8:0.0992366 9:1 10:-0.612903 12:-1 13:-1 106 | -1 1:0.5 2:1 3:1 4:-0.509434 5:-0.767123 6:-1 7:-1 8:0.0534351 9:-1 10:-0.870968 11:-1 12:-1 13:1 107 | -1 2:1 3:0.333333 4:-0.320755 5:-0.452055 6:1 7:1 8:0.557252 9:-1 10:-1 11:-1 12:1 13:-1 108 | -1 1:-0.291667 2:-1 3:-0.333333 4:-0.792453 5:-0.643836 6:-1 7:-1 8:0.541985 9:-1 10:-1 11:-1 12:-1 13:-1 109 | -1 1:0.208333 2:1 3:0.333333 4:-0.792453 5:-0.479452 6:-1 7:1 8:0.267176 9:1 10:-0.806452 12:-1 13:1 110 | +1 1:0.0416667 2:1 3:1 4:-0.509434 5:-0.716895 6:-1 7:-1 8:-0.358779 9:-1 10:-0.548387 12:-0.333333 13:1 111 | -1 1:0.166667 2:1 3:1 4:-0.698113 5:-0.657534 6:-1 7:-1 8:-0.160305 9:1 10:-0.516129 12:-1 13:0.5 112 | -1 1:0.0416667 2:-1 3:0.333333 4:-0.226415 5:-0.187215 6:1 7:-1 8:0.51145 9:-1 10:-1 11:-1 12:-1 13:-1 113 | -1 1:0.0416667 2:-1 3:-0.333333 4:-0.283019 5:-0.260274 6:1 7:1 8:0.343511 9:1 10:-1 11:-1 12:-0.333333 13:-1 114 | -1 1:0.25 2:1 3:-1 4:0.584906 5:-0.342466 6:-1 7:1 8:0.129771 9:-1 10:0.354839 11:1 12:-1 13:1 115 | -1 1:0.583333 2:-1 3:0.333333 4:0.0943396 5:-0.310502 6:-1 7:-1 8:0.541985 9:-1 10:-1 11:-1 12:-0.333333 13:-1 116 | -1 1:-0.791667 2:1 3:-1 4:-0.54717 5:-0.744292 6:-1 7:1 8:0.572519 9:-1 10:-1 11:-1 12:-1 13:-1 117 | +1 1:0.208333 2:1 3:1 4:-0.886792 5:-0.506849 6:-1 7:-1 8:0.29771 9:-1 10:-0.967742 11:-1 12:-0.333333 13:1 118 | +1 1:0.291667 2:-1 3:1 4:0.0566038 5:-0.39726 6:-1 7:1 8:0.312977 9:-1 10:-0.16129 12:0.333333 13:1 119 | -1 1:0.458333 2:-1 3:0.333333 4:-0.132075 5:-0.146119 6:-1 7:-1 8:-0.0534351 9:-1 10:-0.935484 11:-1 12:-1 13:1 120 | -1 1:-0.5 2:1 3:0.333333 4:-0.320755 5:-0.598174 6:-1 7:1 8:0.480916 9:-1 10:-0.354839 12:-1 13:-1 121 | -1 1:-0.375 2:-1 3:0.333333 4:-0.54717 5:-0.47032 6:-1 7:-1 8:0.19084 9:-1 10:-0.903226 12:-0.333333 13:-1 122 | +1 1:-0.75 2:1 3:1 4:-0.396226 5:-0.287671 6:-1 7:1 8:0.29771 9:1 10:-1 11:-1 12:-1 13:1 123 | -1 1:0.958333 2:-1 3:0.333333 4:-0.132075 5:-0.675799 6:-1 8:-0.312977 9:-1 10:-0.645161 12:-1 13:-1 124 | +1 1:-0.375 2:1 3:1 4:-0.698113 5:-0.675799 6:-1 7:1 8:0.618321 9:-1 10:-1 11:-1 12:-0.333333 13:-1 125 | -1 1:-0.75 2:-1 3:1 4:-0.169811 5:-0.739726 6:-1 7:-1 8:0.694656 9:-1 10:-0.548387 11:-1 12:-1 13:-1 126 | -1 1:-0.666667 2:1 3:0.333333 4:-0.320755 5:-0.43379 6:-1 7:-1 8:0.770992 9:-1 10:0.129032 11:1 12:-1 13:-1 127 | +1 1:0.291667 2:1 3:1 4:-0.320755 5:-0.634703 6:-1 7:1 8:-0.0687023 9:1 10:-0.225806 12:0.333333 13:1 128 | -1 1:0.0416667 2:-1 3:0.333333 4:0.245283 5:-0.657534 6:-1 7:-1 8:0.40458 9:-1 10:-1 11:-1 12:-0.333333 13:-1 129 | +1 1:0.208333 2:1 3:1 4:-0.358491 5:-0.392694 6:-1 7:1 8:-0.0992366 9:1 10:-0.0322581 12:0.333333 13:1 130 | -1 1:-0.375 2:1 3:0.333333 4:-0.320755 5:-0.511416 6:-1 7:-1 8:0.648855 9:1 10:-0.870968 11:-1 12:-1 13:-1 131 | -1 1:-0.166667 2:1 3:-0.333333 4:-0.320755 5:-0.360731 6:-1 7:-1 8:0.526718 9:-1 10:-0.806452 11:-1 12:-1 13:-1 132 | +1 1:-0.541667 2:1 3:1 4:0.0943396 5:-0.557078 6:-1 7:-1 8:0.679389 9:-1 10:-1 11:-1 12:-1 13:1 133 | +1 1:0.583333 2:1 3:1 4:-0.509434 5:-0.52968 6:-1 7:1 8:-0.114504 9:1 10:-0.16129 12:0.333333 13:1 134 | -1 1:-0.291667 2:-1 3:0.333333 4:-0.0943396 5:-0.767123 6:-1 7:1 8:0.358779 9:1 10:-0.548387 11:1 12:-1 13:-1 135 | +1 1:0.583333 2:1 3:1 4:-0.509434 5:-0.493151 6:-1 7:-1 8:-1 9:-1 10:-0.677419 12:-1 13:-1 136 | -1 1:-0.291667 2:1 3:-0.333333 4:-0.867925 5:-0.675799 6:1 7:-1 8:0.29771 9:-1 10:-1 11:-1 12:-1 13:1 137 | +1 1:0.166667 2:1 3:-0.333333 4:-0.433962 5:-0.383562 6:-1 7:-1 8:0.0687023 9:-1 10:-0.903226 11:-1 12:-1 13:1 138 | +1 1:0.375 2:-1 3:0.333333 4:-0.320755 5:-0.374429 6:-1 7:-1 8:-0.603053 9:-1 10:-0.612903 12:-0.333333 13:1 139 | +1 1:-0.25 2:1 3:0.333333 4:-0.735849 5:-0.465753 6:-1 7:-1 8:0.236641 9:-1 10:-1 11:-1 12:-1 13:-1 140 | -1 1:-0.333333 2:1 3:-0.333333 4:-0.358491 5:-0.16895 6:-1 7:1 8:0.51145 9:-1 10:-1 11:-1 12:-1 13:-1 141 | -1 1:-0.5 2:-1 3:-0.333333 4:-0.792453 5:-0.671233 6:-1 7:-1 8:0.480916 9:-1 10:-1 11:-1 12:-0.333333 13:-1 142 | +1 1:0.5 2:1 3:1 4:-0.226415 5:-0.415525 6:-1 7:1 8:-0.145038 9:-1 10:-0.0967742 12:-0.333333 13:1 143 | +1 1:0.291667 2:1 3:1 4:-0.320755 5:-0.420091 6:-1 7:-1 8:0.114504 9:1 10:-0.548387 11:-1 12:-0.333333 13:1 144 | +1 1:0.125 2:1 3:1 4:-0.415094 5:-0.438356 6:1 7:1 8:0.114504 9:1 10:-0.612903 12:-0.333333 13:-1 145 | -1 1:0.0416667 2:1 3:1 4:-0.132075 5:-0.484018 6:-1 7:-1 8:0.358779 9:-1 10:-0.612903 11:-1 12:-1 13:-1 146 | -1 1:-0.416667 2:-1 3:0.333333 4:-0.471698 5:-0.60274 6:-1 7:-1 8:0.435115 9:-1 10:-0.935484 12:-1 13:-1 147 | -1 1:0.208333 2:-1 3:-1 4:0.0566038 5:-0.283105 6:1 7:1 8:0.389313 9:-1 10:-0.677419 11:-1 12:-1 13:-1 148 | -1 1:0.125 2:1 3:-1 4:-0.509434 5:-0.694064 6:-1 7:1 8:0.389313 9:-1 10:-0.387097 12:-1 13:1 149 | -1 1:-0.458333 2:1 3:0.333333 4:-0.320755 5:-0.753425 6:-1 7:-1 8:0.206107 9:-1 10:-1 11:-1 12:-1 13:-1 150 | -1 1:-0.458333 2:1 3:-1 4:0.0188679 5:-0.461187 6:-1 7:1 8:0.633588 9:-1 10:-0.741935 11:-1 12:0.333333 13:-1 151 | -1 1:0.5 2:-1 3:0.333333 4:0.245283 5:0.0684932 6:-1 7:1 8:0.221374 9:-1 10:-0.741935 11:-1 12:-1 13:-1 152 | -1 1:-0.333333 2:-1 3:-0.333333 4:-0.660377 5:-0.844749 6:-1 7:-1 8:0.0229008 9:-1 10:-1 12:-1 13:-1 153 | +1 1:0.25 2:1 3:1 4:0.433962 5:-0.086758 6:-1 7:1 8:0.0534351 9:1 10:0.0967742 11:1 12:-1 13:1 154 | +1 1:-0.0416667 2:1 3:1 4:-0.358491 5:-0.410959 6:-1 7:-1 8:0.374046 9:1 10:-1 11:-1 12:-0.333333 13:1 155 | -1 1:0.166667 2:-1 3:1 4:-0.358491 5:-0.191781 6:-1 7:1 8:0.343511 9:-1 10:-1 11:-1 12:-0.333333 13:-1 156 | +1 1:0.208333 2:1 3:1 4:-0.358491 5:-0.589041 6:-1 7:1 8:-0.0839695 9:1 10:-0.290323 12:1 13:1 157 | -1 1:0.0833333 2:-1 3:-0.333333 4:-0.226415 5:-0.43379 6:-1 7:1 8:0.374046 9:-1 10:-0.548387 12:-1 13:-1 158 | -1 1:-0.375 2:1 3:0.333333 4:-0.132075 5:-0.502283 6:-1 7:1 8:0.664122 9:-1 10:-1 11:-1 12:-1 13:-1 159 | -1 1:-0.0416667 2:1 3:-1 4:-0.54717 5:-0.726027 6:-1 7:1 8:0.816794 9:-1 10:-1 12:-1 13:0.5 160 | -1 1:0.166667 2:-1 3:1 4:-0.509434 5:0.0410959 6:-1 7:-1 8:0.40458 9:1 10:-0.806452 11:-1 12:-1 13:-1 161 | +1 1:-0.541667 2:1 3:1 4:-0.698113 5:-0.812785 6:-1 7:1 8:-0.343511 9:1 10:-0.354839 12:-1 13:1 162 | +1 1:-0.25 2:1 3:1 4:-0.698113 5:-0.319635 6:-1 7:1 8:-0.282443 9:1 10:-0.677419 12:-0.333333 13:-1 163 | -1 1:-0.458333 2:1 3:-0.333333 4:-0.509434 5:-0.228311 6:-1 7:-1 8:0.389313 9:-1 10:-1 11:-1 12:-1 13:-1 164 | -1 1:-0.0833333 2:1 3:0.333333 4:-0.698113 5:-0.776256 6:-1 7:-1 8:-0.206107 9:-1 10:-0.806452 11:-1 12:-1 13:-1 165 | -1 1:-0.416667 2:1 3:1 4:-0.698113 5:-0.611872 6:-1 7:-1 8:0.374046 9:-1 10:-1 11:-1 12:-1 13:1 166 | -1 1:0.333333 2:1 3:0.333333 4:0.0566038 5:-0.465753 6:1 7:-1 8:0.00763359 9:1 10:-0.677419 12:-1 13:-1 167 | +1 1:0.208333 2:1 3:1 4:0.0566038 5:-0.342466 6:-1 7:1 8:-0.389313 9:1 10:-0.741935 11:-1 12:-1 13:1 168 | -1 1:0.375 2:-1 3:1 4:-0.433962 5:-0.621005 6:-1 7:-1 8:0.40458 9:-1 10:-1 11:-1 12:-1 13:-1 169 | -1 1:-0.25 2:1 3:0.333333 4:-0.169811 5:-0.401826 6:-1 7:1 8:0.29771 9:-1 10:-1 11:-1 12:-1 13:-1 170 | -1 1:-0.0416667 2:1 3:-0.333333 4:-0.245283 5:-0.657534 6:-1 7:-1 8:0.328244 9:-1 10:-0.741935 11:-1 12:-0.333333 13:-1 171 | +1 1:-0.416667 2:-1 3:1 4:-0.283019 5:-0.0182648 6:1 7:1 8:-0.00763359 9:1 10:-0.0322581 12:-1 13:1 172 | +1 1:0.208333 2:1 3:0.333333 4:-0.660377 5:-0.525114 6:-1 7:1 8:0.435115 9:-1 10:-0.193548 12:-0.333333 13:1 173 | +1 1:0.458333 2:1 3:0.333333 4:-0.415094 5:-0.164384 6:-1 7:-1 8:-0.0839695 9:1 10:-0.419355 12:-1 13:1 174 | -1 1:-0.791667 2:-1 3:-0.333333 4:-0.54717 5:-0.616438 6:-1 7:-1 8:0.847328 9:-1 10:-0.774194 11:-1 12:-1 13:-1 175 | -1 1:-0.375 2:1 3:-0.333333 4:-0.320755 5:-0.575342 6:-1 7:1 8:0.78626 9:-1 10:-1 11:-1 12:-1 13:-1 176 | -1 1:-0.0416667 2:1 3:0.333333 4:0.471698 5:-0.666667 6:1 7:-1 8:0.389313 9:-1 10:-0.83871 11:-1 12:-1 13:1 177 | +1 1:0.541667 2:-1 3:1 4:0.584906 5:-0.534247 6:1 7:-1 8:0.435115 9:1 10:-0.677419 12:0.333333 13:1 178 | -1 1:0.291667 2:-1 3:0.333333 4:-0.509434 5:-0.762557 6:1 7:-1 8:-0.618321 9:-1 10:-1 11:-1 12:-1 13:-1 179 | +1 1:-0.208333 2:1 3:-0.333333 4:-0.698113 5:-0.52968 6:-1 7:-1 8:0.480916 9:-1 10:-0.677419 11:1 12:-1 13:1 180 | +1 2:1 3:1 4:-0.45283 5:-0.287671 6:-1 7:-1 8:-0.633588 9:1 10:-0.354839 12:0.333333 13:1 181 | +1 1:0.0416667 2:1 3:-0.333333 4:0.849057 5:-0.283105 6:-1 7:1 8:0.89313 9:-1 10:-1 11:-1 12:-0.333333 13:1 182 | +1 1:0.375 2:-1 3:1 4:0.0566038 5:-0.461187 6:-1 7:-1 8:0.267176 9:1 10:-0.548387 12:-1 13:-1 183 | +1 1:1 2:1 3:1 4:-0.415094 5:-0.187215 6:-1 7:1 8:0.389313 9:1 10:-1 11:-1 12:1 13:-1 184 | +1 1:0.0833333 2:-1 3:1 4:0.622642 5:-0.0821918 6:-1 8:-0.29771 9:1 10:0.0967742 12:-1 13:-1 185 | +1 1:0.0416667 2:1 3:1 4:-0.433962 5:-0.360731 6:-1 7:1 8:-0.419847 9:1 10:-0.290323 12:-0.333333 13:1 186 | -1 1:-0.0833333 2:-1 3:0.333333 4:-0.132075 5:-0.16895 6:-1 7:1 8:0.0839695 9:-1 10:-0.516129 11:-1 12:-0.333333 13:-1 187 | +1 1:0.708333 2:1 3:1 4:-0.0377358 5:-0.780822 6:-1 7:-1 8:-0.175573 9:1 10:-0.16129 11:1 12:-1 13:1 188 | -1 1:0.5 2:-1 3:0.333333 4:0.150943 5:-0.347032 6:-1 7:-1 8:0.175573 9:-1 10:-0.741935 11:-1 12:-1 13:-1 189 | -1 1:-0.0833333 2:-1 3:0.333333 4:-0.509434 5:-0.228311 6:-1 7:1 8:0.312977 9:-1 10:-0.806452 11:-1 12:-1 13:-1 190 | +1 1:0.0833333 2:1 3:1 4:0.245283 5:-0.255708 6:-1 7:1 8:0.129771 9:1 10:-0.741935 12:-0.333333 13:1 191 | +1 2:1 3:1 4:-0.132075 5:-0.648402 6:1 7:1 8:0.282443 9:1 11:1 12:-1 13:1 192 | -1 1:0.25 2:1 3:0.333333 4:0.0566038 5:-0.607306 6:1 7:-1 8:0.312977 9:-1 10:-0.483871 11:-1 12:-1 13:-1 193 | -1 1:0.375 2:1 3:0.333333 4:-0.320755 5:-0.520548 6:-1 7:-1 8:0.145038 9:-1 10:-0.419355 12:1 13:1 194 | +1 1:0.625 2:1 3:0.333333 4:0.622642 5:-0.324201 6:1 7:1 8:0.206107 9:1 10:-0.483871 12:-1 13:1 195 | +1 1:-0.5 2:1 3:1 4:-0.698113 5:-0.789954 6:-1 7:1 8:0.328244 9:-1 10:-1 11:-1 12:-1 13:1 196 | +1 1:0.166667 2:1 3:0.333333 4:-0.358491 5:-0.52968 6:-1 7:1 8:0.206107 9:-1 10:-0.870968 12:-0.333333 13:1 197 | +1 1:-0.208333 2:1 3:1 4:-0.320755 5:-0.406393 6:1 7:1 8:0.206107 9:1 10:-1 11:-1 12:0.333333 13:1 198 | +1 1:-0.291667 2:1 3:0.333333 4:0.0566038 5:-0.520548 6:-1 7:-1 8:0.160305 9:-1 10:0.16129 12:-1 13:-1 199 | -1 1:0.25 2:1 3:1 4:-0.169811 5:-0.3379 6:-1 7:1 8:0.694656 9:-1 10:-1 11:-1 12:-1 13:-1 200 | -1 1:0.75 2:-1 3:0.333333 4:-0.698113 5:-0.365297 6:1 7:1 8:-0.0992366 9:-1 10:-1 11:-1 12:-0.333333 13:-1 201 | +1 1:0.375 2:-1 3:1 4:-0.169811 5:-0.232877 6:1 7:-1 8:-0.465649 9:-1 10:-0.387097 12:1 13:-1 202 | +1 1:-0.0416667 2:1 3:1 4:-0.660377 5:-0.525114 6:-1 7:-1 8:0.358779 9:-1 10:-1 11:-1 12:-0.333333 13:-1 203 | -1 1:-0.416667 2:1 3:1 4:-0.603774 5:-0.191781 6:-1 7:-1 8:0.679389 9:-1 10:-0.612903 12:-1 13:-1 204 | +1 1:0.708333 2:1 3:1 4:-0.320755 5:-0.105023 6:-1 7:1 8:-0.419847 9:-1 10:-0.225806 12:1 13:-1 205 | -1 1:-0.0416667 2:1 3:-0.333333 4:-0.358491 5:-0.639269 6:1 7:-1 8:0.725191 9:-1 10:-1 11:-1 12:-1 13:-1 206 | -1 1:0.375 2:1 3:-0.333333 4:-0.358491 5:-0.625571 6:1 7:1 8:0.0534351 9:-1 10:-1 11:-1 12:-1 13:-1 207 | -1 1:0.166667 2:1 3:1 4:-0.132075 5:-0.69863 6:-1 7:-1 8:0.175573 9:-1 10:-0.870968 12:-1 13:0.5 208 | +1 1:0.0416667 2:1 3:1 4:-0.698113 5:-0.484018 6:-1 7:-1 8:-0.160305 9:1 10:-0.0967742 12:-0.333333 13:1 209 | -1 1:-0.5 2:1 3:-0.333333 4:-0.226415 5:-0.648402 6:-1 7:-1 8:-0.0687023 9:-1 10:-1 12:-1 13:0.5 210 | -1 2:-1 3:1 4:-0.169811 5:-0.506849 6:-1 7:1 8:0.358779 9:-1 10:-1 11:-1 12:-1 13:-1 211 | -1 1:-0.0416667 2:1 3:-0.333333 4:-0.509434 5:-0.0913242 6:-1 7:-1 8:0.541985 9:-1 10:-0.935484 11:-1 12:-1 13:-1 212 | -1 1:-1 2:1 3:-0.333333 4:-0.320755 5:-0.643836 6:-1 7:1 8:1 9:-1 10:-1 11:-1 12:-1 13:-1 213 | +1 1:0.541667 2:1 3:-0.333333 4:0.245283 5:-0.452055 6:-1 7:-1 8:-0.251908 9:1 10:-1 12:1 13:0.5 214 | -1 1:-0.541667 2:1 3:-1 4:-0.132075 5:-0.666667 6:-1 7:-1 8:0.633588 9:1 10:-0.548387 11:-1 12:-1 13:1 215 | -1 1:0.75 2:-1 3:-0.333333 4:0.245283 5:-0.196347 6:-1 7:-1 8:0.389313 9:-1 10:-0.870968 11:-1 12:0.333333 13:-1 216 | +1 1:0.333333 2:1 3:-1 4:-0.245283 5:-0.506849 6:-1 7:-1 8:0.129771 9:-1 10:-0.16129 12:0.333333 13:-1 217 | +1 1:0.291667 2:-1 3:1 4:0.207547 5:-0.182648 6:-1 7:1 8:0.374046 9:-1 10:-1 11:-1 12:-1 13:-1 218 | -1 1:0.0833333 2:1 3:-0.333333 4:-0.320755 5:-0.378995 6:-1 7:-1 8:0.282443 9:-1 10:-1 11:-1 12:-1 13:-1 219 | -1 1:-0.375 2:-1 3:0.333333 4:-0.735849 5:-0.931507 6:-1 7:-1 8:0.587786 9:-1 10:-0.806452 12:-1 13:-1 220 | -1 1:-0.333333 2:1 3:1 4:-0.603774 5:-0.388128 6:-1 7:1 8:0.740458 9:-1 10:-1 11:-1 12:-1 13:-1 221 | +1 1:0.208333 2:1 3:1 4:-0.0188679 5:-0.579909 6:-1 7:-1 8:-0.480916 9:-1 10:-0.354839 12:-0.333333 13:1 222 | -1 1:0.25 2:1 3:1 4:-0.226415 5:-0.506849 6:-1 7:-1 8:0.374046 9:-1 10:-0.83871 12:-1 13:1 223 | -1 1:0.541667 2:-1 3:-1 4:0.0566038 5:-0.543379 6:-1 7:-1 8:-0.343511 9:-1 10:-0.16129 11:1 12:-1 13:-1 224 | +1 1:0.458333 2:1 3:1 4:-0.509434 5:-0.452055 6:-1 7:1 8:-0.618321 9:1 10:-0.290323 11:1 12:-0.333333 13:-1 225 | -1 1:-0.0833333 2:1 3:0.333333 4:-0.415094 5:-0.456621 6:1 7:1 8:0.450382 9:-1 10:-0.225806 12:-1 13:-1 226 | -1 1:0.458333 2:-1 3:1 4:0.622642 5:-0.0913242 6:-1 7:-1 8:0.267176 9:1 10:-1 11:-1 12:-1 13:-1 227 | -1 1:-0.125 2:-1 3:0.333333 4:-0.509434 5:-0.575342 6:-1 7:-1 8:0.328244 9:-1 10:-0.483871 12:-1 13:-1 228 | -1 1:-0.458333 2:1 3:0.333333 4:-0.509434 5:-0.479452 6:1 7:-1 8:0.877863 9:-1 10:-0.741935 11:1 12:-1 13:1 229 | -1 1:-0.166667 2:-1 3:-0.333333 4:-0.245283 5:-0.3379 6:-1 7:-1 8:0.389313 9:-1 10:-1 12:-1 13:-1 230 | -1 1:0.375 2:-1 3:1 4:-0.132075 5:0.223744 6:-1 7:1 8:0.312977 9:-1 10:-0.612903 12:-1 13:-1 231 | -1 1:-0.666667 2:-1 3:0.333333 4:-0.509434 5:-0.593607 6:-1 7:-1 8:0.51145 9:-1 10:-1 11:-1 12:-1 13:-1 232 | +1 1:0.125 2:1 3:1 4:-0.320755 5:-0.283105 6:1 7:1 8:-0.51145 9:1 10:-0.483871 11:1 12:-1 13:1 233 | +1 1:0.125 2:-1 3:1 4:1 5:-0.260274 6:1 7:1 8:-0.0534351 9:1 10:0.290323 11:1 12:0.333333 13:1 234 | -1 1:0.166667 2:1 3:0.333333 4:0.0566038 5:-0.808219 6:-1 7:-1 8:0.572519 9:-1 10:-0.483871 11:-1 12:-1 13:-1 235 | -1 1:0.0416667 2:1 3:0.333333 4:-0.509434 5:-0.39726 6:-1 7:1 8:0.160305 9:-1 10:-0.870968 12:-1 13:1 236 | +1 1:0.291667 2:1 3:1 4:-0.415094 5:-0.39726 6:-1 7:1 8:0.0687023 9:1 10:-0.0967742 12:-0.333333 13:1 237 | +1 1:-0.458333 2:1 3:1 4:-0.207547 5:-0.136986 6:-1 7:-1 8:-0.175573 9:1 10:-0.419355 12:-1 13:0.5 238 | -1 1:-0.208333 2:1 3:-0.333333 4:-0.320755 5:-0.456621 6:-1 7:1 8:0.664122 9:-1 10:-0.935484 12:-1 13:-1 239 | -1 1:-0.0833333 2:1 3:1 4:-0.132075 5:-0.383562 6:-1 7:1 8:0.755725 9:1 10:-1 11:-1 12:-1 13:-1 240 | +1 1:-0.291667 2:1 3:1 4:-0.509434 5:-0.438356 6:-1 7:1 8:0.114504 9:-1 10:-0.741935 11:-1 12:-1 13:1 241 | +1 1:-0.0833333 2:1 3:1 4:-0.132075 5:-0.210046 6:-1 7:-1 8:0.557252 9:1 10:-0.483871 11:-1 12:-1 13:1 242 | -1 1:0.583333 2:-1 3:0.333333 4:-0.603774 5:1 6:-1 7:1 8:0.358779 9:-1 10:-0.483871 12:-1 13:1 243 | +1 1:0.333333 2:1 3:1 4:-0.132075 5:-0.630137 6:-1 7:1 8:0.0229008 9:1 10:-0.387097 11:-1 12:-0.333333 13:1 244 | -1 1:-0.416667 2:1 3:0.333333 4:-0.320755 5:-0.136986 6:-1 7:-1 8:0.389313 9:-1 10:-0.387097 11:-1 12:-0.333333 13:-1 245 | +1 1:0.0416667 2:1 3:1 4:-0.698113 5:-0.634703 6:-1 7:1 8:-0.435115 9:1 10:-1 12:-0.333333 13:-1 246 | +1 1:0.291667 2:1 3:1 4:-0.566038 5:-0.525114 6:1 7:-1 8:0.358779 9:1 10:-0.548387 11:-1 12:0.333333 13:1 247 | -1 1:-0.458333 2:-1 3:0.333333 4:-0.509434 5:-0.621005 6:-1 7:-1 8:0.557252 9:-1 10:-1 12:-1 13:-1 248 | +1 1:0.5 2:-1 3:1 4:0.0566038 5:-0.547945 6:-1 7:1 8:-0.343511 9:-1 10:-0.677419 12:1 13:1 249 | -1 1:-0.375 2:1 3:0.333333 4:-0.509434 5:-0.543379 6:-1 7:-1 8:0.496183 9:-1 10:-1 11:-1 12:-1 13:-1 250 | -1 1:-0.583333 2:1 3:0.333333 4:-0.132075 5:-0.109589 6:-1 7:1 8:0.694656 9:-1 10:-1 11:-1 12:-1 13:-1 251 | +1 1:-0.625 2:1 3:-1 4:-0.509434 5:-0.520548 6:-1 7:-1 8:0.694656 9:1 10:0.225806 12:-1 13:1 252 | +1 1:0.25 2:1 3:1 4:-0.132075 5:-0.767123 6:-1 7:-1 8:0.389313 9:1 10:-1 11:-1 12:-0.333333 13:1 253 | -1 1:-0.5 2:-1 3:-0.333333 4:-0.320755 5:-0.643836 6:-1 7:1 8:0.541985 9:-1 10:-0.548387 11:-1 12:-1 13:-1 254 | -1 1:-0.375 2:1 3:-0.333333 4:-0.509434 5:-0.374429 6:-1 7:-1 8:0.557252 9:-1 10:-1 11:-1 12:-1 13:1 255 | -1 1:-0.0833333 2:1 3:-1 4:-0.415094 5:-0.60274 6:-1 7:1 8:-0.175573 9:1 10:-0.548387 11:-1 12:-0.333333 13:-1 256 | +1 1:0.25 2:-1 3:1 4:0.509434 5:-0.438356 6:-1 7:-1 8:0.0992366 9:1 10:-1 12:-1 13:-1 257 | +1 1:0.5 2:1 3:1 4:-0.698113 5:-0.442922 6:-1 7:1 8:0.328244 9:-1 10:-0.806452 11:-1 12:0.333333 13:0.5 258 | -1 1:-0.125 2:1 3:0.333333 4:-0.339623 5:-0.680365 6:-1 7:-1 8:0.40458 9:-1 10:-1 11:-1 12:-1 13:-1 259 | +1 1:0.458333 2:1 3:0.333333 4:-0.132075 5:-0.0456621 6:-1 7:-1 8:0.328244 9:-1 10:-1 11:-1 12:-1 13:-1 260 | -1 1:-0.25 2:1 3:1 4:-0.660377 5:-0.643836 6:-1 7:-1 8:0.0992366 9:-1 10:-0.967742 11:-1 12:-1 13:-1 261 | +1 1:-0.166667 2:1 3:0.333333 4:-0.54717 5:-0.894977 6:-1 7:1 8:-0.160305 9:-1 10:-0.741935 11:-1 12:1 13:-1 262 | +1 1:0.291667 2:1 3:0.333333 4:-0.132075 5:-0.730594 6:-1 7:1 8:0.282443 9:-1 10:-0.0322581 12:-1 13:-1 263 | -1 1:0.0416667 2:1 3:-0.333333 4:-0.735849 5:-0.164384 6:-1 7:-1 8:0.29771 9:-1 10:-1 11:-1 12:-1 13:1 264 | +1 1:0.333333 2:1 3:1 4:-0.509434 5:-0.388128 6:-1 7:-1 8:0.0534351 9:1 10:0.16129 12:-0.333333 13:1 265 | -1 1:-0.291667 2:-1 3:1 4:-0.169811 5:-0.465753 6:-1 7:1 8:0.236641 9:1 10:-1 12:-1 13:-1 266 | +1 1:0.583333 2:1 3:1 4:-0.886792 5:-0.210046 6:-1 7:1 8:-0.175573 9:1 10:-0.709677 12:0.333333 13:-1 267 | -1 1:0.458333 2:1 3:-1 4:-0.698113 5:-0.611872 6:-1 7:1 8:0.114504 9:1 10:-0.419355 12:-1 13:-1 268 | -1 1:-0.416667 2:1 3:1 4:0.0566038 5:-0.447489 6:-1 7:-1 8:0.526718 9:-1 10:-0.516129 11:-1 12:-1 13:-1 269 | -1 1:-0.125 2:-1 3:1 4:-0.698113 5:-0.415525 6:-1 7:1 8:0.343511 9:-1 10:-1 11:-1 12:-1 13:-1 270 | -1 1:0.291667 2:-1 3:0.333333 4:-0.849057 5:-0.123288 6:-1 7:-1 8:0.358779 9:-1 10:-1 11:-1 12:-0.333333 13:-1 271 | -------------------------------------------------------------------------------- /test/data/heart_scale.test: -------------------------------------------------------------------------------- 1 | -1 1:-0.5 2:-1 3:-0.333333 4:-0.396226 5:-0.178082 6:-1 7:-1 8:0.40458 9:-1 10:-1 11:-1 12:-1 13:-1 2 | +1 1:0.208333 2:1 3:0.333333 4:-0.283019 5:-0.552511 6:-1 7:1 8:0.557252 9:-1 10:0.0322581 11:-1 12:0.333333 13:1 3 | -1 2:1 3:0.333333 4:-0.320755 5:-0.675799 6:1 7:1 8:0.236641 9:-1 10:-0.612903 11:1 12:-1 13:-1 4 | +1 1:0.0833333 2:1 3:1 4:-0.283019 5:0.0365297 6:-1 7:-1 8:-0.0687023 9:1 10:-0.612903 12:-0.333333 13:1 5 | +1 1:0.5 2:1 3:-1 4:-0.169811 5:-0.287671 6:1 7:1 8:0.572519 9:-1 10:-0.548387 12:-0.333333 13:-1 6 | -1 1:-0.333333 2:-1 3:-0.333333 4:-0.320755 5:-0.506849 6:-1 7:1 8:0.587786 9:-1 10:-0.806452 12:-1 13:-1 7 | +1 1:-0.75 2:1 3:1 4:-0.509434 5:-0.671233 6:-1 7:-1 8:-0.0992366 9:1 10:-0.483871 12:-1 13:1 8 | -1 1:0.416667 2:-1 3:0.333333 4:-0.226415 5:-0.424658 6:-1 7:1 8:0.541985 9:-1 10:-1 11:-1 12:-1 13:-1 9 | +1 1:0.166667 2:1 3:1 4:0.0566038 5:-0.315068 6:-1 7:1 8:-0.374046 9:1 10:-0.806452 12:-0.333333 13:0.5 10 | -1 1:-0.333333 2:-1 3:1 4:-0.169811 5:-0.497717 6:-1 7:1 8:0.236641 9:1 10:-0.935484 12:-1 13:-1 11 | +1 1:-0.125 2:1 3:1 4:-0.0566038 5:-0.6621 6:-1 7:1 8:-0.160305 9:1 10:-0.709677 12:-1 13:1 12 | +1 1:0.125 2:1 3:1 4:-0.283019 5:-0.73516 6:-1 7:1 8:-0.480916 9:1 10:-0.322581 12:-0.333333 13:0.5 13 | -1 1:0.416667 2:1 3:-1 4:-0.0377358 5:-0.511416 6:1 7:1 8:0.206107 9:-1 10:-0.258065 11:1 12:-1 13:0.5 14 | -1 1:0.458333 2:-1 3:1 4:-0.320755 5:-0.191781 6:-1 7:-1 8:-0.221374 9:-1 10:-0.354839 12:0.333333 13:-1 15 | -1 1:-0.5 2:1 3:0.333333 4:-0.660377 5:-0.43379 6:-1 7:-1 8:0.648855 9:-1 10:-1 11:-1 12:-1 13:-1 16 | +1 1:-0.416667 2:1 3:1 4:-0.509434 5:-0.767123 6:-1 7:1 8:-0.251908 9:1 10:-0.193548 12:-1 13:1 17 | +1 1:0.166667 2:1 3:1 4:0.339623 5:-0.255708 6:1 7:1 8:-0.19084 9:-1 10:-0.677419 12:1 13:1 18 | +1 1:0.375 2:1 3:-0.333333 4:-0.509434 5:-0.292237 6:-1 7:1 8:-0.51145 9:-1 10:-0.548387 12:-0.333333 13:1 19 | -1 1:0.416667 2:-1 3:-0.333333 4:-0.132075 5:-0.684932 6:-1 7:-1 8:0.648855 9:-1 10:-1 11:-1 12:0.333333 13:-1 20 | -1 1:-0.125 2:-1 3:-0.333333 4:-0.509434 5:-0.461187 6:-1 7:-1 8:0.389313 9:-1 10:-0.645161 11:-1 12:-1 13:-1 21 | +1 1:0.0416667 2:1 3:1 4:-0.471698 5:-0.269406 6:-1 7:1 8:-0.312977 9:1 10:0.0322581 12:0.333333 13:-1 22 | -1 1:0.541667 2:1 3:1 4:0.245283 5:-0.534247 6:-1 7:1 8:0.0229008 9:-1 10:-0.258065 11:-1 12:-1 13:0.5 23 | -1 1:-0.5 2:-1 3:0.333333 4:-0.660377 5:-0.351598 6:-1 7:1 8:0.541985 9:1 10:-1 11:-1 12:-1 13:-1 24 | +1 1:0.125 2:1 3:0.333333 4:-0.320755 5:-0.406393 6:1 7:1 8:0.0839695 9:1 10:-0.806452 12:-0.333333 13:0.5 25 | +1 1:0.333333 2:-1 3:1 4:-0.320755 5:-0.0684932 6:-1 7:1 8:0.496183 9:-1 10:-1 11:-1 12:-1 13:-1 26 | +1 1:0.208333 2:1 3:1 4:-0.415094 5:-0.205479 6:-1 7:1 8:0.526718 9:-1 10:-1 11:-1 12:0.333333 13:1 27 | -1 1:-0.333333 2:1 3:1 4:-0.811321 5:-0.625571 6:-1 7:1 8:0.175573 9:1 10:-0.0322581 12:-1 13:-1 28 | -1 1:0.625 2:1 3:0.333333 4:-0.54717 5:-0.310502 6:-1 7:-1 8:0.221374 9:-1 10:-0.677419 11:-1 12:-0.333333 13:1 29 | +1 1:0.333333 2:-1 3:1 4:-0.0377358 5:-0.173516 6:-1 7:1 8:0.145038 9:1 10:-0.677419 12:-1 13:1 30 | +1 1:0.375 2:-1 3:1 4:0.245283 5:-0.826484 6:-1 7:1 8:0.129771 9:-1 10:1 11:1 12:1 13:1 31 | -1 1:0.208333 2:-1 3:0.333333 4:-0.509434 5:-0.0228311 6:-1 7:-1 8:0.541985 9:-1 10:-1 11:-1 12:-1 13:-1 32 | +1 1:-0.333333 2:1 3:1 4:-0.0943396 5:-0.164384 6:-1 7:1 8:0.160305 9:1 10:-1 12:1 13:1 33 | +1 1:-0.291667 2:1 3:1 4:-0.132075 5:-0.155251 6:-1 7:-1 8:-0.251908 9:1 10:-0.419355 12:0.333333 13:1 34 | -1 1:-0.208333 2:-1 3:0.333333 4:-0.320755 5:-0.319635 6:-1 7:-1 8:0.0381679 9:-1 10:-0.935484 11:-1 12:-1 13:-1 35 | -1 1:0.166667 2:1 3:0.333333 4:0.0566038 5:-1 6:1 7:-1 8:0.557252 9:-1 10:-0.935484 11:-1 12:-0.333333 13:1 36 | +1 1:-0.0833333 2:1 3:1 4:-0.132075 5:-0.214612 6:-1 7:-1 8:-0.221374 9:1 10:0.354839 12:1 13:1 37 | +1 1:0.666667 2:1 3:0.333333 4:-0.132075 5:-0.415525 6:-1 7:1 8:0.145038 9:-1 10:-0.354839 12:1 13:1 38 | -1 1:-0.0416667 2:1 3:-1 4:0.0943396 5:-0.214612 6:1 7:-1 8:0.633588 9:-1 10:-0.612903 12:-1 13:1 39 | +1 1:0.416667 2:1 3:1 4:-0.320755 5:-0.415525 6:-1 7:1 8:0.160305 9:-1 10:-0.548387 12:-0.333333 13:1 40 | +1 1:0.25 2:1 3:-1 4:0.245283 5:-0.328767 6:-1 7:1 8:-0.175573 9:-1 10:-1 11:-1 12:-1 13:-1 41 | -1 1:0.166667 2:1 3:1 4:-0.283019 5:-0.630137 6:-1 7:-1 8:0.480916 9:1 10:-1 11:-1 12:-1 13:1 42 | -1 1:0.875 2:-1 3:-0.333333 4:-0.509434 5:-0.347032 6:-1 7:1 8:-0.236641 9:1 10:-0.935484 11:-1 12:-0.333333 13:-1 43 | +1 1:0.541667 2:1 3:1 4:-0.660377 5:-0.607306 6:-1 7:1 8:-0.0687023 9:1 10:-0.967742 11:-1 12:-0.333333 13:-1 44 | +1 1:-0.0833333 2:-1 3:1 4:-0.320755 5:-0.182648 6:-1 7:-1 8:0.0839695 9:1 10:-0.612903 12:-1 13:1 45 | +1 1:0.291667 2:1 3:1 4:-0.132075 5:-0.237443 6:-1 7:1 8:0.51145 9:-1 10:-0.612903 12:0.333333 13:1 46 | +1 1:0.375 2:1 3:1 4:-0.509434 5:-0.356164 6:-1 7:-1 8:-0.572519 9:1 10:-0.419355 12:0.333333 13:1 47 | +1 1:-0.166667 2:1 3:0.333333 4:-0.509434 5:-0.716895 6:-1 7:-1 8:0.0381679 9:-1 10:-0.354839 12:1 13:1 48 | -1 1:-0.208333 2:1 3:1 4:-0.471698 5:-0.561644 6:-1 7:1 8:0.755725 9:-1 10:-1 11:-1 12:-1 13:-1 49 | +1 1:0.25 2:1 3:1 4:-0.698113 5:-0.484018 6:-1 7:1 8:0.0839695 9:1 10:-0.612903 12:-0.333333 13:1 50 | -1 1:0.541667 2:1 3:1 4:-0.509434 5:-0.196347 6:-1 7:1 8:0.221374 9:-1 10:-0.870968 12:-1 13:-1 51 | -1 1:-0.0416667 2:1 3:1 4:-0.735849 5:-0.511416 6:1 7:-1 8:0.160305 9:-1 10:-0.967742 11:-1 12:1 13:1 52 | +1 1:0.291667 2:1 3:1 4:-0.0377358 5:-0.287671 6:-1 7:1 8:0.0839695 9:1 10:-0.0967742 12:0.333333 13:1 53 | -1 1:0.625 2:-1 3:0.333333 4:-0.509434 5:-0.611872 6:-1 7:1 8:-0.328244 9:-1 10:-0.516129 12:-1 13:-1 54 | +1 1:0.708333 2:1 3:0.333333 4:0.245283 5:-0.347032 6:-1 7:-1 8:-0.374046 9:1 10:-0.0645161 12:-0.333333 13:1 55 | -1 2:1 3:1 4:-0.0943396 5:-0.543379 6:-1 7:1 8:-0.389313 9:1 10:-1 11:-1 12:-1 13:1 56 | -1 1:0.208333 2:1 3:0.333333 4:-0.132075 5:-0.611872 6:1 7:1 8:0.435115 9:-1 10:-1 11:-1 12:-1 13:-1 57 | +1 1:0.166667 2:1 3:1 4:0.0943396 5:-0.324201 6:-1 7:-1 8:-0.740458 9:1 10:-0.612903 12:-0.333333 13:1 58 | -1 1:0.125 2:-1 3:-0.333333 4:-0.132075 5:-0.232877 6:-1 7:1 8:0.251908 9:-1 10:-0.580645 12:-1 13:-1 59 | +1 1:0.25 2:1 3:-1 4:0.433962 5:-0.260274 6:-1 7:1 8:0.343511 9:-1 10:-0.935484 12:-1 13:1 60 | -1 1:0.0416667 2:-1 3:0.333333 4:-0.735849 5:-0.356164 6:-1 7:1 8:0.465649 9:-1 10:-1 11:-1 12:-1 13:-1 61 | -1 1:-0.458333 2:-1 3:1 4:-0.849057 5:-0.365297 6:-1 7:1 8:-0.221374 9:-1 10:-0.806452 12:-1 13:-1 62 | -1 1:0.0416667 2:1 3:0.333333 4:-0.415094 5:-0.328767 6:-1 7:1 8:0.236641 9:-1 10:-0.83871 11:1 12:-0.333333 13:-1 63 | -1 1:0.708333 2:1 3:-0.333333 4:0.169811 5:-0.456621 6:-1 7:1 8:0.0992366 9:-1 10:-1 11:-1 12:-1 13:-1 64 | -1 1:0.25 2:1 3:-0.333333 4:-0.132075 5:-0.56621 6:-1 7:-1 8:0.419847 9:1 10:-1 11:-1 12:-1 13:-1 65 | +1 1:0.458333 2:1 3:1 4:-0.0377358 5:-0.607306 6:-1 7:1 8:-0.0687023 9:-1 10:-0.354839 12:0.333333 13:0.5 66 | +1 1:0.416667 2:1 3:1 4:-0.320755 5:-0.0684932 6:1 7:1 8:-0.0687023 9:1 10:-0.419355 11:-1 12:1 13:1 67 | -1 1:0.5 2:-1 3:0.333333 4:-0.132075 5:0.328767 6:1 7:1 8:0.312977 9:-1 10:-0.741935 11:-1 12:-0.333333 13:-1 68 | +1 1:0.583333 2:1 3:1 4:-0.415094 5:-0.415525 6:1 7:-1 8:0.40458 9:-1 10:-0.935484 12:0.333333 13:1 69 | -1 1:0.583333 2:-1 3:1 4:-0.773585 5:-0.557078 6:-1 7:-1 8:0.0839695 9:-1 10:-0.903226 11:-1 12:0.333333 13:-1 70 | -1 1:-0.0833333 2:1 3:0.333333 4:-1 5:-0.538813 6:-1 7:-1 8:0.267176 9:1 10:-1 11:-1 12:-0.333333 13:1 71 | -------------------------------------------------------------------------------- /test/data/heart_scale.train: -------------------------------------------------------------------------------- 1 | -1 1:0.666667 2:1 3:-1 4:0.245283 5:-0.506849 6:1 7:1 8:-0.0839695 9:-1 10:-0.967742 12:-0.333333 13:-1 2 | -1 1:-0.5 2:1 3:-0.333333 4:-0.698113 5:-0.502283 6:-1 7:-1 8:0.251908 9:-1 10:-1 11:-1 12:-1 13:-1 3 | +1 1:0.583333 2:1 3:1 4:0.245283 5:-0.269406 6:-1 7:1 8:-0.435115 9:1 10:-0.516129 12:1 13:-1 4 | -1 1:-0.0833333 2:-1 3:0.333333 4:-0.320755 5:-0.406393 6:-1 7:1 8:0.19084 9:-1 10:-0.83871 11:-1 12:-1 13:-1 5 | -1 1:-0.166667 2:-1 3:1 4:-0.320755 5:-0.347032 6:-1 7:-1 8:0.40458 9:-1 10:-1 11:-1 12:-1 13:-1 6 | -1 1:-0.583333 2:-1 3:0.333333 4:-1 5:-0.666667 6:-1 7:-1 8:0.648855 9:-1 10:-1 11:-1 12:-1 13:-1 7 | -1 1:0.458333 2:1 3:1 4:-0.358491 5:-0.374429 6:-1 7:-1 8:-0.480916 9:1 10:-0.935484 12:-0.333333 13:1 8 | -1 1:0.208333 2:-1 3:1 4:-0.886792 5:-0.442922 6:-1 7:1 8:-0.221374 9:-1 10:-0.677419 12:-1 13:-1 9 | -1 1:-0.0416667 2:-1 3:0.333333 4:-0.207547 5:-0.680365 6:-1 7:1 8:0.496183 9:-1 10:-0.967742 12:-1 13:-1 10 | +1 1:0.333333 2:1 3:1 4:-0.169811 5:-0.817352 6:-1 7:1 8:-0.175573 9:1 10:0.16129 12:-0.333333 13:-1 11 | +1 1:-0.208333 2:1 3:1 4:-0.433962 5:-0.324201 6:-1 7:1 8:0.450382 9:-1 10:-0.83871 12:-1 13:1 12 | +1 1:0.125 2:-1 3:1 4:-0.245283 5:0.292237 6:-1 7:1 8:0.206107 9:1 10:-0.387097 12:0.333333 13:1 13 | +1 1:-0.125 2:1 3:1 4:0.0566038 5:-0.465753 6:-1 7:1 8:-0.129771 9:-1 10:-0.16129 12:-1 13:1 14 | +1 1:0.25 2:1 3:0.333333 4:-0.396226 5:-0.579909 6:1 7:-1 8:-0.0381679 9:-1 10:-0.290323 12:-0.333333 13:0.5 15 | +1 1:0.208333 2:-1 3:-0.333333 4:-0.207547 5:-0.118721 6:1 7:1 8:0.236641 9:-1 10:-1 11:-1 12:0.333333 13:-1 16 | -1 1:0.0416667 2:-1 3:0.333333 4:-0.698113 5:-0.598174 6:-1 7:-1 8:0.328244 9:-1 10:-0.483871 12:-1 13:-1 17 | +1 1:-0.375 2:1 3:1 4:-0.660377 5:-0.251142 6:-1 7:1 8:0.251908 9:-1 10:-1 11:-1 12:-0.333333 13:-1 18 | +1 1:0.416667 2:-1 3:1 4:-0.735849 5:-0.347032 6:-1 7:-1 8:0.496183 9:1 10:-0.419355 12:0.333333 13:-1 19 | +1 1:-0.125 2:1 3:0.333333 4:-0.132075 5:-0.511416 6:-1 7:-1 8:0.40458 9:-1 10:-0.806452 12:-0.333333 13:1 20 | -1 2:-1 3:1 4:-0.320755 5:-0.369863 6:-1 7:1 8:0.0992366 9:-1 10:-0.870968 12:-1 13:-1 21 | -1 1:-0.458333 2:1 3:1 4:-0.132075 5:-0.543379 6:-1 7:-1 8:0.633588 9:-1 10:-1 11:-1 12:-1 13:-1 22 | +1 1:0.375 2:-1 3:1 4:-0.132075 5:-0.351598 6:-1 7:1 8:0.358779 9:-1 10:0.16129 11:1 12:0.333333 13:-1 23 | -1 1:0.0416667 2:1 3:0.333333 4:0.0566038 5:-0.515982 6:-1 7:1 8:0.435115 9:-1 10:-0.483871 11:-1 12:-1 13:1 24 | +1 1:-0.583333 2:1 3:1 4:-0.54717 5:-0.575342 6:-1 7:-1 8:0.0534351 9:-1 10:-0.612903 12:-1 13:1 25 | -1 1:0.75 2:-1 3:1 4:-0.660377 5:-0.894977 6:-1 7:-1 8:-0.175573 9:-1 10:-0.483871 12:-1 13:-1 26 | +1 1:0.0833333 2:1 3:1 4:-0.132075 5:-0.584475 6:-1 7:-1 8:-0.389313 9:1 10:0.806452 11:1 12:-1 13:1 27 | +1 1:0.208333 2:1 3:-0.333333 4:-0.509434 5:-0.278539 6:-1 7:1 8:0.358779 9:-1 10:-0.419355 12:-1 13:-1 28 | -1 1:-0.375 2:1 3:-0.333333 4:-0.509434 5:-0.570776 6:-1 7:-1 8:0.51145 9:-1 10:-1 11:-1 12:-1 13:-1 29 | +1 1:-0.0416667 2:1 3:1 4:-0.415094 5:-0.607306 6:-1 7:-1 8:0.480916 9:-1 10:-0.677419 11:-1 12:0.333333 13:1 30 | -1 1:-0.208333 2:1 3:0.333333 4:-0.433962 5:-0.410959 6:1 7:-1 8:0.587786 9:-1 10:-1 11:-1 12:0.333333 13:-1 31 | -1 1:0.291667 2:-1 3:-1 4:0.0566038 5:-0.479452 6:-1 7:-1 8:0.526718 9:-1 10:-0.709677 11:-1 12:-1 13:-1 32 | -1 1:0.666667 2:-1 3:-1 4:-0.132075 5:-0.484018 6:-1 7:-1 8:0.221374 9:-1 10:-0.419355 11:-1 12:0.333333 13:-1 33 | -1 1:0.125 2:1 3:-0.333333 4:-0.509434 5:-0.497717 6:-1 7:-1 8:0.633588 9:-1 10:-0.741935 11:-1 12:-1 13:-1 34 | +1 1:0.416667 2:-1 3:1 4:0.0566038 5:0.283105 6:-1 7:1 8:0.267176 9:-1 10:0.290323 12:1 13:1 35 | -1 1:-0.0833333 2:1 3:0.333333 4:-0.886792 5:-0.561644 6:-1 7:-1 8:0.0992366 9:1 10:-0.612903 12:-1 13:-1 36 | -1 1:0.5 2:1 3:1 4:-0.509434 5:-0.767123 6:-1 7:-1 8:0.0534351 9:-1 10:-0.870968 11:-1 12:-1 13:1 37 | -1 2:1 3:0.333333 4:-0.320755 5:-0.452055 6:1 7:1 8:0.557252 9:-1 10:-1 11:-1 12:1 13:-1 38 | -1 1:-0.291667 2:-1 3:-0.333333 4:-0.792453 5:-0.643836 6:-1 7:-1 8:0.541985 9:-1 10:-1 11:-1 12:-1 13:-1 39 | -1 1:0.208333 2:1 3:0.333333 4:-0.792453 5:-0.479452 6:-1 7:1 8:0.267176 9:1 10:-0.806452 12:-1 13:1 40 | +1 1:0.0416667 2:1 3:1 4:-0.509434 5:-0.716895 6:-1 7:-1 8:-0.358779 9:-1 10:-0.548387 12:-0.333333 13:1 41 | -1 1:0.166667 2:1 3:1 4:-0.698113 5:-0.657534 6:-1 7:-1 8:-0.160305 9:1 10:-0.516129 12:-1 13:0.5 42 | -1 1:0.0416667 2:-1 3:0.333333 4:-0.226415 5:-0.187215 6:1 7:-1 8:0.51145 9:-1 10:-1 11:-1 12:-1 13:-1 43 | -1 1:0.0416667 2:-1 3:-0.333333 4:-0.283019 5:-0.260274 6:1 7:1 8:0.343511 9:1 10:-1 11:-1 12:-0.333333 13:-1 44 | -1 1:0.25 2:1 3:-1 4:0.584906 5:-0.342466 6:-1 7:1 8:0.129771 9:-1 10:0.354839 11:1 12:-1 13:1 45 | -1 1:0.583333 2:-1 3:0.333333 4:0.0943396 5:-0.310502 6:-1 7:-1 8:0.541985 9:-1 10:-1 11:-1 12:-0.333333 13:-1 46 | -1 1:-0.791667 2:1 3:-1 4:-0.54717 5:-0.744292 6:-1 7:1 8:0.572519 9:-1 10:-1 11:-1 12:-1 13:-1 47 | +1 1:0.208333 2:1 3:1 4:-0.886792 5:-0.506849 6:-1 7:-1 8:0.29771 9:-1 10:-0.967742 11:-1 12:-0.333333 13:1 48 | +1 1:0.291667 2:-1 3:1 4:0.0566038 5:-0.39726 6:-1 7:1 8:0.312977 9:-1 10:-0.16129 12:0.333333 13:1 49 | -1 1:0.458333 2:-1 3:0.333333 4:-0.132075 5:-0.146119 6:-1 7:-1 8:-0.0534351 9:-1 10:-0.935484 11:-1 12:-1 13:1 50 | -1 1:-0.5 2:1 3:0.333333 4:-0.320755 5:-0.598174 6:-1 7:1 8:0.480916 9:-1 10:-0.354839 12:-1 13:-1 51 | -1 1:-0.375 2:-1 3:0.333333 4:-0.54717 5:-0.47032 6:-1 7:-1 8:0.19084 9:-1 10:-0.903226 12:-0.333333 13:-1 52 | +1 1:-0.75 2:1 3:1 4:-0.396226 5:-0.287671 6:-1 7:1 8:0.29771 9:1 10:-1 11:-1 12:-1 13:1 53 | -1 1:0.958333 2:-1 3:0.333333 4:-0.132075 5:-0.675799 6:-1 8:-0.312977 9:-1 10:-0.645161 12:-1 13:-1 54 | +1 1:-0.375 2:1 3:1 4:-0.698113 5:-0.675799 6:-1 7:1 8:0.618321 9:-1 10:-1 11:-1 12:-0.333333 13:-1 55 | -1 1:-0.75 2:-1 3:1 4:-0.169811 5:-0.739726 6:-1 7:-1 8:0.694656 9:-1 10:-0.548387 11:-1 12:-1 13:-1 56 | -1 1:-0.666667 2:1 3:0.333333 4:-0.320755 5:-0.43379 6:-1 7:-1 8:0.770992 9:-1 10:0.129032 11:1 12:-1 13:-1 57 | +1 1:0.291667 2:1 3:1 4:-0.320755 5:-0.634703 6:-1 7:1 8:-0.0687023 9:1 10:-0.225806 12:0.333333 13:1 58 | -1 1:0.0416667 2:-1 3:0.333333 4:0.245283 5:-0.657534 6:-1 7:-1 8:0.40458 9:-1 10:-1 11:-1 12:-0.333333 13:-1 59 | +1 1:0.208333 2:1 3:1 4:-0.358491 5:-0.392694 6:-1 7:1 8:-0.0992366 9:1 10:-0.0322581 12:0.333333 13:1 60 | -1 1:-0.375 2:1 3:0.333333 4:-0.320755 5:-0.511416 6:-1 7:-1 8:0.648855 9:1 10:-0.870968 11:-1 12:-1 13:-1 61 | -1 1:-0.166667 2:1 3:-0.333333 4:-0.320755 5:-0.360731 6:-1 7:-1 8:0.526718 9:-1 10:-0.806452 11:-1 12:-1 13:-1 62 | +1 1:-0.541667 2:1 3:1 4:0.0943396 5:-0.557078 6:-1 7:-1 8:0.679389 9:-1 10:-1 11:-1 12:-1 13:1 63 | +1 1:0.583333 2:1 3:1 4:-0.509434 5:-0.52968 6:-1 7:1 8:-0.114504 9:1 10:-0.16129 12:0.333333 13:1 64 | -1 1:-0.291667 2:-1 3:0.333333 4:-0.0943396 5:-0.767123 6:-1 7:1 8:0.358779 9:1 10:-0.548387 11:1 12:-1 13:-1 65 | +1 1:0.583333 2:1 3:1 4:-0.509434 5:-0.493151 6:-1 7:-1 8:-1 9:-1 10:-0.677419 12:-1 13:-1 66 | -1 1:-0.291667 2:1 3:-0.333333 4:-0.867925 5:-0.675799 6:1 7:-1 8:0.29771 9:-1 10:-1 11:-1 12:-1 13:1 67 | +1 1:0.166667 2:1 3:-0.333333 4:-0.433962 5:-0.383562 6:-1 7:-1 8:0.0687023 9:-1 10:-0.903226 11:-1 12:-1 13:1 68 | +1 1:0.375 2:-1 3:0.333333 4:-0.320755 5:-0.374429 6:-1 7:-1 8:-0.603053 9:-1 10:-0.612903 12:-0.333333 13:1 69 | +1 1:-0.25 2:1 3:0.333333 4:-0.735849 5:-0.465753 6:-1 7:-1 8:0.236641 9:-1 10:-1 11:-1 12:-1 13:-1 70 | -1 1:-0.333333 2:1 3:-0.333333 4:-0.358491 5:-0.16895 6:-1 7:1 8:0.51145 9:-1 10:-1 11:-1 12:-1 13:-1 71 | -1 1:-0.5 2:-1 3:-0.333333 4:-0.792453 5:-0.671233 6:-1 7:-1 8:0.480916 9:-1 10:-1 11:-1 12:-0.333333 13:-1 72 | +1 1:0.5 2:1 3:1 4:-0.226415 5:-0.415525 6:-1 7:1 8:-0.145038 9:-1 10:-0.0967742 12:-0.333333 13:1 73 | +1 1:0.291667 2:1 3:1 4:-0.320755 5:-0.420091 6:-1 7:-1 8:0.114504 9:1 10:-0.548387 11:-1 12:-0.333333 13:1 74 | +1 1:0.125 2:1 3:1 4:-0.415094 5:-0.438356 6:1 7:1 8:0.114504 9:1 10:-0.612903 12:-0.333333 13:-1 75 | -1 1:0.0416667 2:1 3:1 4:-0.132075 5:-0.484018 6:-1 7:-1 8:0.358779 9:-1 10:-0.612903 11:-1 12:-1 13:-1 76 | -1 1:-0.416667 2:-1 3:0.333333 4:-0.471698 5:-0.60274 6:-1 7:-1 8:0.435115 9:-1 10:-0.935484 12:-1 13:-1 77 | -1 1:0.208333 2:-1 3:-1 4:0.0566038 5:-0.283105 6:1 7:1 8:0.389313 9:-1 10:-0.677419 11:-1 12:-1 13:-1 78 | -1 1:0.125 2:1 3:-1 4:-0.509434 5:-0.694064 6:-1 7:1 8:0.389313 9:-1 10:-0.387097 12:-1 13:1 79 | -1 1:-0.458333 2:1 3:0.333333 4:-0.320755 5:-0.753425 6:-1 7:-1 8:0.206107 9:-1 10:-1 11:-1 12:-1 13:-1 80 | -1 1:-0.458333 2:1 3:-1 4:0.0188679 5:-0.461187 6:-1 7:1 8:0.633588 9:-1 10:-0.741935 11:-1 12:0.333333 13:-1 81 | -1 1:0.5 2:-1 3:0.333333 4:0.245283 5:0.0684932 6:-1 7:1 8:0.221374 9:-1 10:-0.741935 11:-1 12:-1 13:-1 82 | -1 1:-0.333333 2:-1 3:-0.333333 4:-0.660377 5:-0.844749 6:-1 7:-1 8:0.0229008 9:-1 10:-1 12:-1 13:-1 83 | +1 1:0.25 2:1 3:1 4:0.433962 5:-0.086758 6:-1 7:1 8:0.0534351 9:1 10:0.0967742 11:1 12:-1 13:1 84 | +1 1:-0.0416667 2:1 3:1 4:-0.358491 5:-0.410959 6:-1 7:-1 8:0.374046 9:1 10:-1 11:-1 12:-0.333333 13:1 85 | -1 1:0.166667 2:-1 3:1 4:-0.358491 5:-0.191781 6:-1 7:1 8:0.343511 9:-1 10:-1 11:-1 12:-0.333333 13:-1 86 | +1 1:0.208333 2:1 3:1 4:-0.358491 5:-0.589041 6:-1 7:1 8:-0.0839695 9:1 10:-0.290323 12:1 13:1 87 | -1 1:0.0833333 2:-1 3:-0.333333 4:-0.226415 5:-0.43379 6:-1 7:1 8:0.374046 9:-1 10:-0.548387 12:-1 13:-1 88 | -1 1:-0.375 2:1 3:0.333333 4:-0.132075 5:-0.502283 6:-1 7:1 8:0.664122 9:-1 10:-1 11:-1 12:-1 13:-1 89 | -1 1:-0.0416667 2:1 3:-1 4:-0.54717 5:-0.726027 6:-1 7:1 8:0.816794 9:-1 10:-1 12:-1 13:0.5 90 | -1 1:0.166667 2:-1 3:1 4:-0.509434 5:0.0410959 6:-1 7:-1 8:0.40458 9:1 10:-0.806452 11:-1 12:-1 13:-1 91 | +1 1:-0.541667 2:1 3:1 4:-0.698113 5:-0.812785 6:-1 7:1 8:-0.343511 9:1 10:-0.354839 12:-1 13:1 92 | +1 1:-0.25 2:1 3:1 4:-0.698113 5:-0.319635 6:-1 7:1 8:-0.282443 9:1 10:-0.677419 12:-0.333333 13:-1 93 | -1 1:-0.458333 2:1 3:-0.333333 4:-0.509434 5:-0.228311 6:-1 7:-1 8:0.389313 9:-1 10:-1 11:-1 12:-1 13:-1 94 | -1 1:-0.0833333 2:1 3:0.333333 4:-0.698113 5:-0.776256 6:-1 7:-1 8:-0.206107 9:-1 10:-0.806452 11:-1 12:-1 13:-1 95 | -1 1:-0.416667 2:1 3:1 4:-0.698113 5:-0.611872 6:-1 7:-1 8:0.374046 9:-1 10:-1 11:-1 12:-1 13:1 96 | -1 1:0.333333 2:1 3:0.333333 4:0.0566038 5:-0.465753 6:1 7:-1 8:0.00763359 9:1 10:-0.677419 12:-1 13:-1 97 | +1 1:0.208333 2:1 3:1 4:0.0566038 5:-0.342466 6:-1 7:1 8:-0.389313 9:1 10:-0.741935 11:-1 12:-1 13:1 98 | -1 1:0.375 2:-1 3:1 4:-0.433962 5:-0.621005 6:-1 7:-1 8:0.40458 9:-1 10:-1 11:-1 12:-1 13:-1 99 | -1 1:-0.25 2:1 3:0.333333 4:-0.169811 5:-0.401826 6:-1 7:1 8:0.29771 9:-1 10:-1 11:-1 12:-1 13:-1 100 | -1 1:-0.0416667 2:1 3:-0.333333 4:-0.245283 5:-0.657534 6:-1 7:-1 8:0.328244 9:-1 10:-0.741935 11:-1 12:-0.333333 13:-1 101 | +1 1:-0.416667 2:-1 3:1 4:-0.283019 5:-0.0182648 6:1 7:1 8:-0.00763359 9:1 10:-0.0322581 12:-1 13:1 102 | +1 1:0.208333 2:1 3:0.333333 4:-0.660377 5:-0.525114 6:-1 7:1 8:0.435115 9:-1 10:-0.193548 12:-0.333333 13:1 103 | +1 1:0.458333 2:1 3:0.333333 4:-0.415094 5:-0.164384 6:-1 7:-1 8:-0.0839695 9:1 10:-0.419355 12:-1 13:1 104 | -1 1:-0.791667 2:-1 3:-0.333333 4:-0.54717 5:-0.616438 6:-1 7:-1 8:0.847328 9:-1 10:-0.774194 11:-1 12:-1 13:-1 105 | -1 1:-0.375 2:1 3:-0.333333 4:-0.320755 5:-0.575342 6:-1 7:1 8:0.78626 9:-1 10:-1 11:-1 12:-1 13:-1 106 | -1 1:-0.0416667 2:1 3:0.333333 4:0.471698 5:-0.666667 6:1 7:-1 8:0.389313 9:-1 10:-0.83871 11:-1 12:-1 13:1 107 | +1 1:0.541667 2:-1 3:1 4:0.584906 5:-0.534247 6:1 7:-1 8:0.435115 9:1 10:-0.677419 12:0.333333 13:1 108 | -1 1:0.291667 2:-1 3:0.333333 4:-0.509434 5:-0.762557 6:1 7:-1 8:-0.618321 9:-1 10:-1 11:-1 12:-1 13:-1 109 | +1 1:-0.208333 2:1 3:-0.333333 4:-0.698113 5:-0.52968 6:-1 7:-1 8:0.480916 9:-1 10:-0.677419 11:1 12:-1 13:1 110 | +1 2:1 3:1 4:-0.45283 5:-0.287671 6:-1 7:-1 8:-0.633588 9:1 10:-0.354839 12:0.333333 13:1 111 | +1 1:0.0416667 2:1 3:-0.333333 4:0.849057 5:-0.283105 6:-1 7:1 8:0.89313 9:-1 10:-1 11:-1 12:-0.333333 13:1 112 | +1 1:0.375 2:-1 3:1 4:0.0566038 5:-0.461187 6:-1 7:-1 8:0.267176 9:1 10:-0.548387 12:-1 13:-1 113 | +1 1:1 2:1 3:1 4:-0.415094 5:-0.187215 6:-1 7:1 8:0.389313 9:1 10:-1 11:-1 12:1 13:-1 114 | +1 1:0.0833333 2:-1 3:1 4:0.622642 5:-0.0821918 6:-1 8:-0.29771 9:1 10:0.0967742 12:-1 13:-1 115 | +1 1:0.0416667 2:1 3:1 4:-0.433962 5:-0.360731 6:-1 7:1 8:-0.419847 9:1 10:-0.290323 12:-0.333333 13:1 116 | -1 1:-0.0833333 2:-1 3:0.333333 4:-0.132075 5:-0.16895 6:-1 7:1 8:0.0839695 9:-1 10:-0.516129 11:-1 12:-0.333333 13:-1 117 | +1 1:0.708333 2:1 3:1 4:-0.0377358 5:-0.780822 6:-1 7:-1 8:-0.175573 9:1 10:-0.16129 11:1 12:-1 13:1 118 | -1 1:0.5 2:-1 3:0.333333 4:0.150943 5:-0.347032 6:-1 7:-1 8:0.175573 9:-1 10:-0.741935 11:-1 12:-1 13:-1 119 | -1 1:-0.0833333 2:-1 3:0.333333 4:-0.509434 5:-0.228311 6:-1 7:1 8:0.312977 9:-1 10:-0.806452 11:-1 12:-1 13:-1 120 | +1 1:0.0833333 2:1 3:1 4:0.245283 5:-0.255708 6:-1 7:1 8:0.129771 9:1 10:-0.741935 12:-0.333333 13:1 121 | +1 2:1 3:1 4:-0.132075 5:-0.648402 6:1 7:1 8:0.282443 9:1 11:1 12:-1 13:1 122 | -1 1:0.25 2:1 3:0.333333 4:0.0566038 5:-0.607306 6:1 7:-1 8:0.312977 9:-1 10:-0.483871 11:-1 12:-1 13:-1 123 | -1 1:0.375 2:1 3:0.333333 4:-0.320755 5:-0.520548 6:-1 7:-1 8:0.145038 9:-1 10:-0.419355 12:1 13:1 124 | +1 1:0.625 2:1 3:0.333333 4:0.622642 5:-0.324201 6:1 7:1 8:0.206107 9:1 10:-0.483871 12:-1 13:1 125 | +1 1:-0.5 2:1 3:1 4:-0.698113 5:-0.789954 6:-1 7:1 8:0.328244 9:-1 10:-1 11:-1 12:-1 13:1 126 | +1 1:0.166667 2:1 3:0.333333 4:-0.358491 5:-0.52968 6:-1 7:1 8:0.206107 9:-1 10:-0.870968 12:-0.333333 13:1 127 | +1 1:-0.208333 2:1 3:1 4:-0.320755 5:-0.406393 6:1 7:1 8:0.206107 9:1 10:-1 11:-1 12:0.333333 13:1 128 | +1 1:-0.291667 2:1 3:0.333333 4:0.0566038 5:-0.520548 6:-1 7:-1 8:0.160305 9:-1 10:0.16129 12:-1 13:-1 129 | -1 1:0.25 2:1 3:1 4:-0.169811 5:-0.3379 6:-1 7:1 8:0.694656 9:-1 10:-1 11:-1 12:-1 13:-1 130 | -1 1:0.75 2:-1 3:0.333333 4:-0.698113 5:-0.365297 6:1 7:1 8:-0.0992366 9:-1 10:-1 11:-1 12:-0.333333 13:-1 131 | +1 1:0.375 2:-1 3:1 4:-0.169811 5:-0.232877 6:1 7:-1 8:-0.465649 9:-1 10:-0.387097 12:1 13:-1 132 | +1 1:-0.0416667 2:1 3:1 4:-0.660377 5:-0.525114 6:-1 7:-1 8:0.358779 9:-1 10:-1 11:-1 12:-0.333333 13:-1 133 | -1 1:-0.416667 2:1 3:1 4:-0.603774 5:-0.191781 6:-1 7:-1 8:0.679389 9:-1 10:-0.612903 12:-1 13:-1 134 | +1 1:0.708333 2:1 3:1 4:-0.320755 5:-0.105023 6:-1 7:1 8:-0.419847 9:-1 10:-0.225806 12:1 13:-1 135 | -1 1:-0.0416667 2:1 3:-0.333333 4:-0.358491 5:-0.639269 6:1 7:-1 8:0.725191 9:-1 10:-1 11:-1 12:-1 13:-1 136 | -1 1:0.375 2:1 3:-0.333333 4:-0.358491 5:-0.625571 6:1 7:1 8:0.0534351 9:-1 10:-1 11:-1 12:-1 13:-1 137 | -1 1:0.166667 2:1 3:1 4:-0.132075 5:-0.69863 6:-1 7:-1 8:0.175573 9:-1 10:-0.870968 12:-1 13:0.5 138 | +1 1:0.0416667 2:1 3:1 4:-0.698113 5:-0.484018 6:-1 7:-1 8:-0.160305 9:1 10:-0.0967742 12:-0.333333 13:1 139 | -1 1:-0.5 2:1 3:-0.333333 4:-0.226415 5:-0.648402 6:-1 7:-1 8:-0.0687023 9:-1 10:-1 12:-1 13:0.5 140 | -1 2:-1 3:1 4:-0.169811 5:-0.506849 6:-1 7:1 8:0.358779 9:-1 10:-1 11:-1 12:-1 13:-1 141 | -1 1:-0.0416667 2:1 3:-0.333333 4:-0.509434 5:-0.0913242 6:-1 7:-1 8:0.541985 9:-1 10:-0.935484 11:-1 12:-1 13:-1 142 | -1 1:-1 2:1 3:-0.333333 4:-0.320755 5:-0.643836 6:-1 7:1 8:1 9:-1 10:-1 11:-1 12:-1 13:-1 143 | +1 1:0.541667 2:1 3:-0.333333 4:0.245283 5:-0.452055 6:-1 7:-1 8:-0.251908 9:1 10:-1 12:1 13:0.5 144 | -1 1:-0.541667 2:1 3:-1 4:-0.132075 5:-0.666667 6:-1 7:-1 8:0.633588 9:1 10:-0.548387 11:-1 12:-1 13:1 145 | -1 1:0.75 2:-1 3:-0.333333 4:0.245283 5:-0.196347 6:-1 7:-1 8:0.389313 9:-1 10:-0.870968 11:-1 12:0.333333 13:-1 146 | +1 1:0.333333 2:1 3:-1 4:-0.245283 5:-0.506849 6:-1 7:-1 8:0.129771 9:-1 10:-0.16129 12:0.333333 13:-1 147 | +1 1:0.291667 2:-1 3:1 4:0.207547 5:-0.182648 6:-1 7:1 8:0.374046 9:-1 10:-1 11:-1 12:-1 13:-1 148 | -1 1:0.0833333 2:1 3:-0.333333 4:-0.320755 5:-0.378995 6:-1 7:-1 8:0.282443 9:-1 10:-1 11:-1 12:-1 13:-1 149 | -1 1:-0.375 2:-1 3:0.333333 4:-0.735849 5:-0.931507 6:-1 7:-1 8:0.587786 9:-1 10:-0.806452 12:-1 13:-1 150 | -1 1:-0.333333 2:1 3:1 4:-0.603774 5:-0.388128 6:-1 7:1 8:0.740458 9:-1 10:-1 11:-1 12:-1 13:-1 151 | +1 1:0.208333 2:1 3:1 4:-0.0188679 5:-0.579909 6:-1 7:-1 8:-0.480916 9:-1 10:-0.354839 12:-0.333333 13:1 152 | -1 1:0.25 2:1 3:1 4:-0.226415 5:-0.506849 6:-1 7:-1 8:0.374046 9:-1 10:-0.83871 12:-1 13:1 153 | -1 1:0.541667 2:-1 3:-1 4:0.0566038 5:-0.543379 6:-1 7:-1 8:-0.343511 9:-1 10:-0.16129 11:1 12:-1 13:-1 154 | +1 1:0.458333 2:1 3:1 4:-0.509434 5:-0.452055 6:-1 7:1 8:-0.618321 9:1 10:-0.290323 11:1 12:-0.333333 13:-1 155 | -1 1:-0.0833333 2:1 3:0.333333 4:-0.415094 5:-0.456621 6:1 7:1 8:0.450382 9:-1 10:-0.225806 12:-1 13:-1 156 | -1 1:0.458333 2:-1 3:1 4:0.622642 5:-0.0913242 6:-1 7:-1 8:0.267176 9:1 10:-1 11:-1 12:-1 13:-1 157 | -1 1:-0.125 2:-1 3:0.333333 4:-0.509434 5:-0.575342 6:-1 7:-1 8:0.328244 9:-1 10:-0.483871 12:-1 13:-1 158 | -1 1:-0.458333 2:1 3:0.333333 4:-0.509434 5:-0.479452 6:1 7:-1 8:0.877863 9:-1 10:-0.741935 11:1 12:-1 13:1 159 | -1 1:-0.166667 2:-1 3:-0.333333 4:-0.245283 5:-0.3379 6:-1 7:-1 8:0.389313 9:-1 10:-1 12:-1 13:-1 160 | -1 1:0.375 2:-1 3:1 4:-0.132075 5:0.223744 6:-1 7:1 8:0.312977 9:-1 10:-0.612903 12:-1 13:-1 161 | -1 1:-0.666667 2:-1 3:0.333333 4:-0.509434 5:-0.593607 6:-1 7:-1 8:0.51145 9:-1 10:-1 11:-1 12:-1 13:-1 162 | +1 1:0.125 2:1 3:1 4:-0.320755 5:-0.283105 6:1 7:1 8:-0.51145 9:1 10:-0.483871 11:1 12:-1 13:1 163 | +1 1:0.125 2:-1 3:1 4:1 5:-0.260274 6:1 7:1 8:-0.0534351 9:1 10:0.290323 11:1 12:0.333333 13:1 164 | -1 1:0.166667 2:1 3:0.333333 4:0.0566038 5:-0.808219 6:-1 7:-1 8:0.572519 9:-1 10:-0.483871 11:-1 12:-1 13:-1 165 | -1 1:0.0416667 2:1 3:0.333333 4:-0.509434 5:-0.39726 6:-1 7:1 8:0.160305 9:-1 10:-0.870968 12:-1 13:1 166 | +1 1:0.291667 2:1 3:1 4:-0.415094 5:-0.39726 6:-1 7:1 8:0.0687023 9:1 10:-0.0967742 12:-0.333333 13:1 167 | +1 1:-0.458333 2:1 3:1 4:-0.207547 5:-0.136986 6:-1 7:-1 8:-0.175573 9:1 10:-0.419355 12:-1 13:0.5 168 | -1 1:-0.208333 2:1 3:-0.333333 4:-0.320755 5:-0.456621 6:-1 7:1 8:0.664122 9:-1 10:-0.935484 12:-1 13:-1 169 | -1 1:-0.0833333 2:1 3:1 4:-0.132075 5:-0.383562 6:-1 7:1 8:0.755725 9:1 10:-1 11:-1 12:-1 13:-1 170 | +1 1:-0.291667 2:1 3:1 4:-0.509434 5:-0.438356 6:-1 7:1 8:0.114504 9:-1 10:-0.741935 11:-1 12:-1 13:1 171 | +1 1:-0.0833333 2:1 3:1 4:-0.132075 5:-0.210046 6:-1 7:-1 8:0.557252 9:1 10:-0.483871 11:-1 12:-1 13:1 172 | -1 1:0.583333 2:-1 3:0.333333 4:-0.603774 5:1 6:-1 7:1 8:0.358779 9:-1 10:-0.483871 12:-1 13:1 173 | +1 1:0.333333 2:1 3:1 4:-0.132075 5:-0.630137 6:-1 7:1 8:0.0229008 9:1 10:-0.387097 11:-1 12:-0.333333 13:1 174 | -1 1:-0.416667 2:1 3:0.333333 4:-0.320755 5:-0.136986 6:-1 7:-1 8:0.389313 9:-1 10:-0.387097 11:-1 12:-0.333333 13:-1 175 | +1 1:0.0416667 2:1 3:1 4:-0.698113 5:-0.634703 6:-1 7:1 8:-0.435115 9:1 10:-1 12:-0.333333 13:-1 176 | +1 1:0.291667 2:1 3:1 4:-0.566038 5:-0.525114 6:1 7:-1 8:0.358779 9:1 10:-0.548387 11:-1 12:0.333333 13:1 177 | -1 1:-0.458333 2:-1 3:0.333333 4:-0.509434 5:-0.621005 6:-1 7:-1 8:0.557252 9:-1 10:-1 12:-1 13:-1 178 | +1 1:0.5 2:-1 3:1 4:0.0566038 5:-0.547945 6:-1 7:1 8:-0.343511 9:-1 10:-0.677419 12:1 13:1 179 | -1 1:-0.375 2:1 3:0.333333 4:-0.509434 5:-0.543379 6:-1 7:-1 8:0.496183 9:-1 10:-1 11:-1 12:-1 13:-1 180 | -1 1:-0.583333 2:1 3:0.333333 4:-0.132075 5:-0.109589 6:-1 7:1 8:0.694656 9:-1 10:-1 11:-1 12:-1 13:-1 181 | +1 1:-0.625 2:1 3:-1 4:-0.509434 5:-0.520548 6:-1 7:-1 8:0.694656 9:1 10:0.225806 12:-1 13:1 182 | +1 1:0.25 2:1 3:1 4:-0.132075 5:-0.767123 6:-1 7:-1 8:0.389313 9:1 10:-1 11:-1 12:-0.333333 13:1 183 | -1 1:-0.5 2:-1 3:-0.333333 4:-0.320755 5:-0.643836 6:-1 7:1 8:0.541985 9:-1 10:-0.548387 11:-1 12:-1 13:-1 184 | -1 1:-0.375 2:1 3:-0.333333 4:-0.509434 5:-0.374429 6:-1 7:-1 8:0.557252 9:-1 10:-1 11:-1 12:-1 13:1 185 | -1 1:-0.0833333 2:1 3:-1 4:-0.415094 5:-0.60274 6:-1 7:1 8:-0.175573 9:1 10:-0.548387 11:-1 12:-0.333333 13:-1 186 | +1 1:0.25 2:-1 3:1 4:0.509434 5:-0.438356 6:-1 7:-1 8:0.0992366 9:1 10:-1 12:-1 13:-1 187 | +1 1:0.5 2:1 3:1 4:-0.698113 5:-0.442922 6:-1 7:1 8:0.328244 9:-1 10:-0.806452 11:-1 12:0.333333 13:0.5 188 | -1 1:-0.125 2:1 3:0.333333 4:-0.339623 5:-0.680365 6:-1 7:-1 8:0.40458 9:-1 10:-1 11:-1 12:-1 13:-1 189 | +1 1:0.458333 2:1 3:0.333333 4:-0.132075 5:-0.0456621 6:-1 7:-1 8:0.328244 9:-1 10:-1 11:-1 12:-1 13:-1 190 | -1 1:-0.25 2:1 3:1 4:-0.660377 5:-0.643836 6:-1 7:-1 8:0.0992366 9:-1 10:-0.967742 11:-1 12:-1 13:-1 191 | +1 1:-0.166667 2:1 3:0.333333 4:-0.54717 5:-0.894977 6:-1 7:1 8:-0.160305 9:-1 10:-0.741935 11:-1 12:1 13:-1 192 | +1 1:0.291667 2:1 3:0.333333 4:-0.132075 5:-0.730594 6:-1 7:1 8:0.282443 9:-1 10:-0.0322581 12:-1 13:-1 193 | -1 1:0.0416667 2:1 3:-0.333333 4:-0.735849 5:-0.164384 6:-1 7:-1 8:0.29771 9:-1 10:-1 11:-1 12:-1 13:1 194 | +1 1:0.333333 2:1 3:1 4:-0.509434 5:-0.388128 6:-1 7:-1 8:0.0534351 9:1 10:0.16129 12:-0.333333 13:1 195 | -1 1:-0.291667 2:-1 3:1 4:-0.169811 5:-0.465753 6:-1 7:1 8:0.236641 9:1 10:-1 12:-1 13:-1 196 | +1 1:0.583333 2:1 3:1 4:-0.886792 5:-0.210046 6:-1 7:1 8:-0.175573 9:1 10:-0.709677 12:0.333333 13:-1 197 | -1 1:0.458333 2:1 3:-1 4:-0.698113 5:-0.611872 6:-1 7:1 8:0.114504 9:1 10:-0.419355 12:-1 13:-1 198 | -1 1:-0.416667 2:1 3:1 4:0.0566038 5:-0.447489 6:-1 7:-1 8:0.526718 9:-1 10:-0.516129 11:-1 12:-1 13:-1 199 | -1 1:-0.125 2:-1 3:1 4:-0.698113 5:-0.415525 6:-1 7:1 8:0.343511 9:-1 10:-1 11:-1 12:-1 13:-1 200 | -1 1:0.291667 2:-1 3:0.333333 4:-0.849057 5:-0.123288 6:-1 7:-1 8:0.358779 9:-1 10:-1 11:-1 12:-0.333333 13:-1 201 | -------------------------------------------------------------------------------- /test/data/test_batch_read_sample.dat: -------------------------------------------------------------------------------- 1 | 1.0 2:1.0 0:0.0 1:4.0 2 | 0.0 1:2.0 2:0.0 0:3.0 3 | 1.0 2:3.0 1:2.0 0:0.0 4 | 0.0 1:4.0 2:1.0 3:0.0 5 | -------------------------------------------------------------------------------- /test/test_svm_common.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using std::string; 9 | using std::vector; 10 | using std::ifstream; 11 | 12 | int main(int argc, char **argv) 13 | { 14 | testing::InitGoogleTest(&argc, argv); 15 | return RUN_ALL_TESTS(); 16 | } 17 | /** 18 | * @brief 19 | **/ 20 | class test_split_suite : public ::testing::Test{ 21 | protected: 22 | test_split_suite(){}; 23 | virtual ~test_split_suite(){}; 24 | virtual void SetUp() { 25 | //Called befor every TEST_F(test_split_suite, *) 26 | }; 27 | virtual void TearDown() { 28 | //Called after every TEST_F(test_split_suite, *) 29 | }; 30 | }; 31 | 32 | /** 33 | * @brief 34 | * @begin_version 35 | **/ 36 | TEST_F(test_split_suite, case_split) 37 | { 38 | string s = "this is a test string"; 39 | vector v; 40 | 41 | split(s, ' ', v); 42 | 43 | ASSERT_EQ(5, (int)v.size()); 44 | 45 | ASSERT_EQ(0, v[0].compare("this")); 46 | ASSERT_EQ(0, v[1].compare("is")); 47 | ASSERT_EQ(0, v[2].compare("a")); 48 | ASSERT_EQ(0, v[3].compare("test")); 49 | ASSERT_EQ(0, v[4].compare("string")); 50 | } 51 | 52 | /** 53 | * @brief 54 | **/ 55 | class test_cmp_suite : public ::testing::Test{ 56 | protected: 57 | test_cmp_suite(){}; 58 | virtual ~test_cmp_suite(){}; 59 | virtual void SetUp() { 60 | //Called befor every TEST_F(test_cmp_suite, *) 61 | }; 62 | virtual void TearDown() { 63 | //Called after every TEST_F(test_cmp_suite, *) 64 | }; 65 | }; 66 | 67 | /** 68 | * @brief 69 | * @begin_version 70 | **/ 71 | TEST_F(test_cmp_suite, case_cmp) 72 | { 73 | TVectorDim p1, p2; 74 | 75 | p1.second = 0.0; 76 | p2.second = 0.0; 77 | 78 | p1.first = 0; 79 | p2.first = 1; 80 | 81 | ASSERT_TRUE(cmp(p1, p2)); 82 | ASSERT_FALSE(cmp(p2, p1)); 83 | 84 | } 85 | 86 | /** 87 | * @brief 88 | **/ 89 | class test_read_sample_suite : public ::testing::Test{ 90 | protected: 91 | test_read_sample_suite(){}; 92 | virtual ~test_read_sample_suite(){}; 93 | virtual void SetUp() { 94 | //Called befor every TEST_F(test_read_sample_suite, *) 95 | }; 96 | virtual void TearDown() { 97 | //Called after every TEST_F(test_read_sample_suite, *) 98 | }; 99 | }; 100 | 101 | /** 102 | * @brief 103 | * @begin_version 104 | **/ 105 | TEST_F(test_read_sample_suite, case_read_sample) 106 | { 107 | TString s = "1.0 2:2.0 0:0.0 1:1.0"; 108 | TVector x; 109 | float y; 110 | 111 | int ret = read_sample(s, x, y); 112 | 113 | ASSERT_EQ(0, ret); 114 | ASSERT_EQ(1.0, y); 115 | ASSERT_EQ(3, (int)x.size()); 116 | 117 | ASSERT_TRUE(x[0].first == 0); 118 | ASSERT_TRUE(x[0].second == 0.0); 119 | 120 | ASSERT_TRUE(x[1].first == 1); 121 | ASSERT_TRUE(x[1].second == 1.0); 122 | 123 | ASSERT_TRUE(x[2].first == 2); 124 | ASSERT_TRUE(x[2].second == 2.0); 125 | } 126 | 127 | /** 128 | * @brief 129 | **/ 130 | class test_write_sample_suite : public ::testing::Test{ 131 | protected: 132 | test_write_sample_suite(){}; 133 | virtual ~test_write_sample_suite(){}; 134 | virtual void SetUp() { 135 | //Called befor every TEST_F(test_write_sample_suite, *) 136 | }; 137 | virtual void TearDown() { 138 | //Called after every TEST_F(test_write_sample_suite, *) 139 | }; 140 | }; 141 | 142 | /** 143 | * @brief 144 | * @begin_version 145 | **/ 146 | TEST_F(test_write_sample_suite, case_write_sample) 147 | { 148 | //TODO 149 | TString s; 150 | TVector x; 151 | float y; 152 | 153 | x.push_back(TVectorDim(2, 2.1)); 154 | x.push_back(TVectorDim(0, 0.1)); 155 | x.push_back(TVectorDim(1, 1.1)); 156 | y = 1.1; 157 | 158 | int ret = write_sample(s, x, y); 159 | 160 | ASSERT_EQ(0, ret); 161 | ASSERT_EQ(0, s.compare("1.1 2:2.1 0:0.1 1:1.1")); 162 | } 163 | 164 | /** 165 | * @brief 166 | **/ 167 | class test_batch_read_sample_suite : public ::testing::Test{ 168 | protected: 169 | test_batch_read_sample_suite(){}; 170 | virtual ~test_batch_read_sample_suite(){}; 171 | virtual void SetUp() { 172 | //Called befor every TEST_F(test_batch_read_sample_suite, *) 173 | }; 174 | virtual void TearDown() { 175 | //Called after every TEST_F(test_batch_read_sample_suite, *) 176 | }; 177 | }; 178 | 179 | /** 180 | * @brief 181 | * @begin_version 182 | **/ 183 | TEST_F(test_batch_read_sample_suite, case_batch_read_sample) 184 | { 185 | //TODO 186 | TVectorArray X; 187 | TFloatArray Y; 188 | int n; 189 | 190 | string fname = "data/test_batch_read_sample.dat"; 191 | ifstream is(fname.c_str()); 192 | int ret = batch_read_sample(is, X, Y, n); 193 | 194 | ASSERT_EQ(0, ret); 195 | ASSERT_EQ(4, n); 196 | 197 | ASSERT_EQ(4, (int)X.size()); 198 | ASSERT_EQ(4, (int)Y.size()); 199 | 200 | } 201 | 202 | /** 203 | * @brief 204 | **/ 205 | class test_batch_write_sample_suite : public ::testing::Test{ 206 | protected: 207 | test_batch_write_sample_suite(){}; 208 | virtual ~test_batch_write_sample_suite(){}; 209 | virtual void SetUp() { 210 | //Called befor every TEST_F(test_batch_write_sample_suite, *) 211 | }; 212 | virtual void TearDown() { 213 | //Called after every TEST_F(test_batch_write_sample_suite, *) 214 | }; 215 | }; 216 | 217 | /** 218 | * @brief 219 | * @begin_version 220 | **/ 221 | TEST_F(test_batch_write_sample_suite, case_batch_write_sample) 222 | { 223 | //TODO 224 | } 225 | 226 | /** 227 | * @brief 228 | **/ 229 | class test_print_vector_suite : public ::testing::Test{ 230 | protected: 231 | test_print_vector_suite(){}; 232 | virtual ~test_print_vector_suite(){}; 233 | virtual void SetUp() { 234 | //Called befor every TEST_F(test_print_vector_suite, *) 235 | }; 236 | virtual void TearDown() { 237 | //Called after every TEST_F(test_print_vector_suite, *) 238 | }; 239 | }; 240 | 241 | /** 242 | * @brief 243 | * @begin_version 244 | **/ 245 | TEST_F(test_print_vector_suite, case_name1) 246 | { 247 | //TODO 248 | } 249 | 250 | /** 251 | * @brief 252 | **/ 253 | class test_dot_product_suite : public ::testing::Test{ 254 | protected: 255 | test_dot_product_suite(){}; 256 | virtual ~test_dot_product_suite(){}; 257 | virtual void SetUp() { 258 | //Called befor every TEST_F(test_dot_product_suite, *) 259 | }; 260 | virtual void TearDown() { 261 | //Called after every TEST_F(test_dot_product_suite, *) 262 | }; 263 | }; 264 | 265 | /** 266 | * @brief 267 | * @begin_version 268 | **/ 269 | TEST_F(test_dot_product_suite, case_dot_product) 270 | { 271 | TVector v1; 272 | TVector v2; 273 | 274 | v1.push_back(TVectorDim(0, 1.0)); 275 | v1.push_back(TVectorDim(1, 2.0)); 276 | v1.push_back(TVectorDim(3, 4.0)); 277 | 278 | v2.push_back(TVectorDim(0, 2.0)); 279 | v2.push_back(TVectorDim(2, 4.0)); 280 | v2.push_back(TVectorDim(3, 8.0)); 281 | 282 | float dot = dot_product(v1, v2); 283 | 284 | ASSERT_EQ(34.0, dot); 285 | 286 | } 287 | 288 | /** 289 | * @brief 290 | **/ 291 | class test_operator_multiplies_suite : public ::testing::Test{ 292 | protected: 293 | test_operator_multiplies_suite(){}; 294 | virtual ~test_operator_multiplies_suite(){}; 295 | virtual void SetUp() { 296 | //Called befor every TEST_F(test_operator_multiplies_suite, *) 297 | }; 298 | virtual void TearDown() { 299 | //Called after every TEST_F(test_operator_multiplies_suite, *) 300 | }; 301 | }; 302 | 303 | /** 304 | * @brief 305 | * @begin_version 306 | **/ 307 | TEST_F(test_operator_multiplies_suite, case_left_multiplies) 308 | { 309 | TVector v; 310 | float f; 311 | 312 | v.push_back(TVectorDim(0, 1.0)); 313 | v.push_back(TVectorDim(1, 2.0)); 314 | v.push_back(TVectorDim(2, 4.0)); 315 | 316 | f = 4.0; 317 | 318 | TVector fv = f * v; 319 | ASSERT_EQ(3, (int)fv.size()); 320 | 321 | ASSERT_EQ(0, fv[0].first); 322 | ASSERT_EQ(4.0, fv[0].second); 323 | 324 | ASSERT_EQ(1, fv[1].first); 325 | ASSERT_EQ(8.0, fv[1].second); 326 | 327 | ASSERT_EQ(2, fv[2].first); 328 | ASSERT_EQ(16.0, fv[2].second); 329 | 330 | } 331 | 332 | /** 333 | * @brief 334 | * @begin_version 335 | **/ 336 | TEST_F(test_operator_multiplies_suite, case_right_multiplies) 337 | { 338 | //TODO 339 | TVector v; 340 | float f; 341 | 342 | v.push_back(TVectorDim(0, 1.0)); 343 | v.push_back(TVectorDim(1, 2.0)); 344 | v.push_back(TVectorDim(2, 4.0)); 345 | 346 | f = 2.0; 347 | 348 | TVector vf = v * f; 349 | ASSERT_EQ(3, (int)vf.size()); 350 | 351 | ASSERT_EQ(0, vf[0].first); 352 | ASSERT_EQ(2.0, vf[0].second); 353 | 354 | ASSERT_EQ(1, vf[1].first); 355 | ASSERT_EQ(4.0, vf[1].second); 356 | 357 | ASSERT_EQ(2, vf[2].first); 358 | ASSERT_EQ(8.0, vf[2].second); 359 | } 360 | 361 | /** 362 | * @brief 363 | **/ 364 | class test_operator_plus_suite : public ::testing::Test{ 365 | protected: 366 | test_operator_plus_suite(){}; 367 | virtual ~test_operator_plus_suite(){}; 368 | virtual void SetUp() { 369 | //Called befor every TEST_F(test_operator_plus_suite, *) 370 | }; 371 | virtual void TearDown() { 372 | //Called after every TEST_F(test_operator_plus_suite, *) 373 | }; 374 | }; 375 | 376 | /** 377 | * @brief 378 | * @begin_version 379 | **/ 380 | TEST_F(test_operator_plus_suite, case_plus) 381 | { 382 | TVector v1; 383 | TVector v2; 384 | 385 | v1.push_back(TVectorDim(0, 1.0)); 386 | v1.push_back(TVectorDim(1, 2.0)); 387 | v1.push_back(TVectorDim(3, 4.0)); 388 | 389 | v2.push_back(TVectorDim(0, 2.0)); 390 | v2.push_back(TVectorDim(2, 4.0)); 391 | v2.push_back(TVectorDim(3, 8.0)); 392 | 393 | TVector v12 = v1 + v2; 394 | 395 | ASSERT_EQ(4, (int)v12.size()); 396 | 397 | ASSERT_EQ(0, v12[0].first); 398 | ASSERT_EQ(3.0, v12[0].second); 399 | 400 | ASSERT_EQ(1, v12[1].first); 401 | ASSERT_EQ(2.0, v12[1].second); 402 | 403 | ASSERT_EQ(2, v12[2].first); 404 | ASSERT_EQ(4.0, v12[2].second); 405 | 406 | ASSERT_EQ(3, v12[3].first); 407 | ASSERT_EQ(12.0, v12[3].second); 408 | 409 | } 410 | 411 | -------------------------------------------------------------------------------- /test/test_svm_option.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "svm_common.h" 4 | #include 5 | 6 | 7 | int main(int argc, char **argv) 8 | { 9 | testing::InitGoogleTest(&argc, argv); 10 | return RUN_ALL_TESTS(); 11 | } 12 | /** 13 | * @brief 14 | **/ 15 | class test_SVMOption_SVMOption_suite : public ::testing::Test{ 16 | protected: 17 | test_SVMOption_SVMOption_suite(){}; 18 | virtual ~test_SVMOption_SVMOption_suite(){}; 19 | virtual void SetUp() { 20 | //Called befor every TEST_F(test_SVMOption_SVMOption_suite, *) 21 | option = new SVMOption(); 22 | }; 23 | virtual void TearDown() { 24 | //Called after every TEST_F(test_SVMOption_SVMOption_suite, *) 25 | delete option; 26 | }; 27 | SVMOption *option; 28 | }; 29 | 30 | /** 31 | * @brief 32 | * @begin_version 33 | **/ 34 | TEST_F(test_SVMOption_SVMOption_suite, case_svm_option) 35 | { 36 | ASSERT_TRUE(fabs(SVM_OPTION_C - option->_c) < 1e-6); 37 | ASSERT_TRUE(fabs(SVM_OPTION_EPSILON - option->_eps) < 1e-6); 38 | ASSERT_TRUE(fabs(SVM_OPTION_SIGMA - option->_sig) < 1e-6); 39 | ASSERT_TRUE(false == option->_is_linear_kernel); 40 | ASSERT_EQ(0, (int)strlen(option->_fname_train)); 41 | ASSERT_EQ(0, (int)strlen(option->_fname_valid)); 42 | ASSERT_EQ(0, (int)strlen(option->_fname_model)); 43 | } 44 | 45 | /** 46 | * @brief 47 | **/ 48 | class test_SVMOption_parse_command_line_suite : public ::testing::Test{ 49 | protected: 50 | test_SVMOption_parse_command_line_suite(){}; 51 | virtual ~test_SVMOption_parse_command_line_suite(){}; 52 | virtual void SetUp() { 53 | //Called befor every TEST_F(test_SVMOption_parse_command_line_suite, *) 54 | option = new SVMOption(); 55 | }; 56 | virtual void TearDown() { 57 | //Called after every TEST_F(test_SVMOption_parse_command_line_suite, *) 58 | delete option; 59 | }; 60 | SVMOption *option; 61 | }; 62 | 63 | /** 64 | * @brief 65 | * @begin_version 66 | **/ 67 | TEST_F(test_SVMOption_parse_command_line_suite, case_parse_command_line) 68 | { 69 | const int argc = 15; 70 | char arr[argc][128] = {"xxx.xxx", "-train", "ftrain", "-model", "fmodel", 71 | "-validate", "fvalid", "-linear_kernel", "-c", "0.01", 72 | "-epsilon", "0.001", "-sigma", "0.0001", "-help"}; 73 | 74 | char *argv[] = {arr[0], arr[1], arr[2], arr[3], arr[4], 75 | arr[5], arr[6], arr[7], arr[8], arr[9], 76 | arr[10], arr[11], arr[12], arr[13], arr[14]}; 77 | 78 | int ret = option->parse_command_line(argc, argv); 79 | 80 | ASSERT_EQ(0, ret); 81 | 82 | ASSERT_EQ(0, strcmp(arr[2], option->_fname_train)); 83 | ASSERT_EQ(0, strcmp(arr[4], option->_fname_model)); 84 | ASSERT_EQ(0, strcmp(arr[6], option->_fname_valid)); 85 | 86 | ASSERT_EQ(true, option->_is_linear_kernel); 87 | 88 | ASSERT_TRUE(fabs(atof(arr[9]) - option->_c) < 1e-6); 89 | ASSERT_TRUE(fabs(atof(arr[11]) - option->_eps) < 1e-6); 90 | ASSERT_TRUE(fabs(atof(arr[13]) - option->_sig) < 1e-6); 91 | } 92 | 93 | /** 94 | * @brief 95 | **/ 96 | class test_SVMOption_print_suite : public ::testing::Test{ 97 | protected: 98 | test_SVMOption_print_suite(){}; 99 | virtual ~test_SVMOption_print_suite(){}; 100 | virtual void SetUp() { 101 | //Called befor every TEST_F(test_SVMOption_print_suite, *) 102 | }; 103 | virtual void TearDown() { 104 | //Called after every TEST_F(test_SVMOption_print_suite, *) 105 | }; 106 | }; 107 | 108 | /** 109 | * @brief 110 | * @begin_version 111 | **/ 112 | TEST_F(test_SVMOption_print_suite, case_name1) 113 | { 114 | //TODO 115 | } 116 | 117 | -------------------------------------------------------------------------------- /test/test_svm_solver.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | 6 | int main(int argc, char **argv) 7 | { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } 11 | /** 12 | * @brief 13 | **/ 14 | class test_SVMSolver_SVMSolver_suite : public ::testing::Test{ 15 | protected: 16 | test_SVMSolver_SVMSolver_suite(){}; 17 | virtual ~test_SVMSolver_SVMSolver_suite(){}; 18 | virtual void SetUp() { 19 | //Called befor every TEST_F(test_SVMSolver_SVMSolver_suite, *) 20 | }; 21 | virtual void TearDown() { 22 | //Called after every TEST_F(test_SVMSolver_SVMSolver_suite, *) 23 | }; 24 | }; 25 | 26 | /** 27 | * @brief 28 | * @begin_version 29 | **/ 30 | TEST_F(test_SVMSolver_SVMSolver_suite, case_name1) 31 | { 32 | //TODO 33 | } 34 | 35 | /** 36 | * @brief 37 | **/ 38 | class test_SVMSolver_train_suite : public ::testing::Test{ 39 | protected: 40 | test_SVMSolver_train_suite(){}; 41 | virtual ~test_SVMSolver_train_suite(){}; 42 | virtual void SetUp() { 43 | //Called befor every TEST_F(test_SVMSolver_train_suite, *) 44 | }; 45 | virtual void TearDown() { 46 | //Called after every TEST_F(test_SVMSolver_train_suite, *) 47 | }; 48 | SVMOption *option; 49 | SVMSolver *solver; 50 | }; 51 | 52 | /** 53 | * @brief 54 | * @begin_version 55 | **/ 56 | TEST_F(test_SVMSolver_train_suite, case_train) 57 | { 58 | option = new SVMOption(); 59 | strcpy(option->_fname_train, "data/heart_scale.train"); 60 | strcpy(option->_fname_model, "data/heart_scale.model.unittest"); 61 | solver = new SVMSolver(option); 62 | int ret = solver->train(); 63 | ASSERT_EQ(0, ret); 64 | delete solver; 65 | delete option; 66 | 67 | } 68 | 69 | /** 70 | * @brief 71 | **/ 72 | class test_SVMSolver_predict_suite : public ::testing::Test{ 73 | protected: 74 | test_SVMSolver_predict_suite(){}; 75 | virtual ~test_SVMSolver_predict_suite(){}; 76 | virtual void SetUp() { 77 | //Called befor every TEST_F(test_SVMSolver_predict_suite, *) 78 | }; 79 | virtual void TearDown() { 80 | //Called after every TEST_F(test_SVMSolver_predict_suite, *) 81 | }; 82 | SVMOption *option; 83 | SVMSolver *solver; 84 | }; 85 | 86 | /** 87 | * @brief 88 | * @begin_version 89 | **/ 90 | TEST_F(test_SVMSolver_predict_suite, case_name1) 91 | { 92 | option = new SVMOption(); 93 | strcpy(option->_fname_valid, "data/heart_scale.test"); 94 | strcpy(option->_fname_model, "data/heart_scale.model"); 95 | solver = new SVMSolver(option); 96 | int ret = solver->predict(); 97 | ASSERT_EQ(0, ret); 98 | delete solver; 99 | delete option; 100 | } 101 | 102 | -------------------------------------------------------------------------------- /tools/install_gtest.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | install_gtest.html 9 | 10 | 11 | 12 | 13 | 14 |

Install GTest Packages

15 | 16 |

In running the test applications we may need gtest if the gtest is not 17 | already installed.

18 | 19 |

Ubuntu 16.04 Installation

20 | 21 |

This will install the gtest development pacakges.

22 | 23 |
sudo apt-get install libgtest-dev
24 | 
25 | 26 |

Then cmake must be used to build the source packages. 27 | If you don't have cmake please install it first.

28 | 29 |
sudo apt-get install cmake
30 | 
31 | 32 |

Then move to the gtest folder

33 | 34 |
cd /usr/src/gtest
35 | 
36 | 37 |

After that use cmake to make the list

38 | 39 |
sudo cmake CMakeLists.txt
40 | sudo make
41 | 
42 | 43 |

After compiling copy the files to /usr/lib folder

44 | 45 |
sudo co *.a /usr/lib
46 | 
47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /tools/install_gtest.html~: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | install_gtest.html 9 | 10 | 11 | 12 | 13 | 14 |

Install GTest Packages

15 | 16 |

In running the test applications we may need gtest if the gtest is not 17 | already installed.

18 | 19 |

Ubuntu 16.04 Installation

20 | 21 |

This will install the gtest development pacakges.

22 | 23 |
sudo apt-get install libgtest-dev
24 | 
25 | 26 |

Then cmake must be used to build the source packages. 27 | If you don't have cmake please install it first.

28 | 29 |

30 | sudo apt-get install cmake 31 |

32 | 33 |

Then move to the gtest folder

34 | 35 |
cd /usr/src/gtest
36 | 
37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /tools/install_gtest.md: -------------------------------------------------------------------------------- 1 | # Install GTest Packages 2 | 3 | In running the test applications we may need gtest if the gtest is not 4 | already installed. 5 | 6 | ## Ubuntu 16.04 Installation 7 | 8 | This will install the gtest development pacakges. 9 | 10 | sudo apt-get install libgtest-dev 11 | 12 | Then cmake must be used to build the source packages. 13 | If you don't have cmake please install it first. 14 | 15 | sudo apt-get install cmake 16 | 17 | 18 | Then move to the gtest folder 19 | 20 | cd /usr/src/gtest 21 | 22 | After that use cmake to make the list 23 | 24 | sudo cmake CMakeLists.txt 25 | sudo make 26 | 27 | After compiling copy the files to /usr/lib folder 28 | 29 | sudo co *.a /usr/lib 30 | 31 | ## References 32 | 33 | [Getting Started With Google Test on Ubuntu](https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/) 34 | -------------------------------------------------------------------------------- /tools/install_gtest.md~: -------------------------------------------------------------------------------- 1 | # Install GTest Packages 2 | 3 | In running the test applications we may need gtest if the gtest is not 4 | already installed. 5 | 6 | ## Ubuntu 16.04 Installation 7 | 8 | This will install the gtest development pacakges. 9 | 10 | sudo apt-get install libgtest-dev 11 | 12 | Then cmake must be used to build the source packages. 13 | If you don't have cmake please install it first. 14 | 15 | sudo apt-get install cmake 16 | 17 | Then move to the gtest folder 18 | 19 | cd /usr/src/gtest 20 | --------------------------------------------------------------------------------