summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILDING17
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac2
-rw-r--r--creg/Makefile.am11
-rw-r--r--creg/README17
-rw-r--r--creg/creg.cc384
-rw-r--r--creg/json_feature_map_lexer.h15
-rw-r--r--creg/json_feature_map_lexer.ll132
-rw-r--r--creg/test_data/auto-mpg.testfeat93
-rw-r--r--creg/test_data/auto-mpg.testresp93
-rw-r--r--creg/test_data/auto-mpg.trainfeat300
-rw-r--r--creg/test_data/auto-mpg.trainresp300
-rw-r--r--creg/test_data/iris.testfeat50
-rw-r--r--creg/test_data/iris.testresp50
-rw-r--r--creg/test_data/iris.trainfeat100
-rw-r--r--creg/test_data/iris.trainresp100
-rw-r--r--training/liblbfgs/lbfgs++.h30
-rw-r--r--training/liblbfgs/ll_test.cc4
-rw-r--r--utils/fast_sparse_vector.h16
19 files changed, 1686 insertions, 30 deletions
diff --git a/BUILDING b/BUILDING
index c7b954c7..d5a086e8 100644
--- a/BUILDING
+++ b/BUILDING
@@ -1,6 +1,5 @@
To build cdec, you'll need:
- * Google c++ testing framework (http://code.google.com/p/googletest/)
* boost headers & boost program_options (you may need to install a package
like boost-devel)
@@ -8,20 +7,14 @@ To build cdec, you'll need:
Instructions for building
-----------------------------------
- 1) Optional: Download and build SRILM
-
- 2) Download, build, and install Google Test (optional, this is necessary
- to build unit tests that may be useful in development; system tests
- work without it)
-
- 3) Use automake / autoconf to generate the configure script.
+ 1) Use automake / autoconf to generate the configure script.
I'm not an expert at using these tools, but this should be sufficient:
autoreconf -ifv
- 4) Configure and build. Your command will look something like this.
+ 2) Configure and build. Your command will look something like this.
- ./configure --disable-gtest
+ ./configure
make
If you get errors during configure about missing BOOST macros, then step 3
@@ -36,12 +29,12 @@ Instructions for building
make LIBS+="-lz -lboost_program_options" \
CFLAGS+="-Wno-sign-compare"
- 5) Test
+ 3) Test
./tests/run-system-tests.pl
Everything should pass.
- 6) Enjoy!
+ 4) Enjoy!
diff --git a/Makefile.am b/Makefile.am
index ea5e2b3f..0e08ee72 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# warning - the subdirectories in the following list should
# be kept in topologically sorted order. Also, DO NOT introduce
# cyclic dependencies between these directories!
-SUBDIRS = utils mteval klm/util klm/lm decoder phrasinator training training/liblbfgs mira dtrain dpmert pro-train rampion extools gi/pf gi/markov_al rst_parser
+SUBDIRS = utils mteval klm/util klm/lm decoder phrasinator training training/liblbfgs creg mira dtrain dpmert pro-train rampion extools gi/pf gi/markov_al rst_parser
#gi/pyp-topics/src gi/clda/src gi/posterior-regularisation/prjava
diff --git a/configure.ac b/configure.ac
index 849b100b..1e853fb6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,4 +130,4 @@ then
AM_CONDITIONAL([GLC], true)
fi
-AC_OUTPUT(Makefile rst_parser/Makefile utils/Makefile mteval/Makefile extools/Makefile decoder/Makefile phrasinator/Makefile training/Makefile training/liblbfgs/Makefile dpmert/Makefile pro-train/Makefile rampion/Makefile klm/util/Makefile klm/lm/Makefile mira/Makefile dtrain/Makefile gi/pyp-topics/src/Makefile gi/clda/src/Makefile gi/pf/Makefile gi/markov_al/Makefile)
+AC_OUTPUT(Makefile rst_parser/Makefile utils/Makefile mteval/Makefile extools/Makefile decoder/Makefile phrasinator/Makefile training/Makefile training/liblbfgs/Makefile creg/Makefile dpmert/Makefile pro-train/Makefile rampion/Makefile klm/util/Makefile klm/lm/Makefile mira/Makefile dtrain/Makefile gi/pyp-topics/src/Makefile gi/clda/src/Makefile gi/pf/Makefile gi/markov_al/Makefile)
diff --git a/creg/Makefile.am b/creg/Makefile.am
new file mode 100644
index 00000000..9e25b838
--- /dev/null
+++ b/creg/Makefile.am
@@ -0,0 +1,11 @@
+bin_PROGRAMS = \
+ creg
+
+creg_SOURCES = creg.cc json_feature_map_lexer.cc
+creg_LDADD = $(top_srcdir)/training/liblbfgs/liblbfgs.a $(top_srcdir)/utils/libutils.a -lz
+
+json_feature_map_lexer.cc: json_feature_map_lexer.ll
+ $(LEX) -s -8 -CF -o$@ $<
+
+AM_CPPFLAGS = -W -Wall -DNDEBUG -I$(top_srcdir)/utils -I$(top_srcdir)/training
+
diff --git a/creg/README b/creg/README
new file mode 100644
index 00000000..28a71d11
--- /dev/null
+++ b/creg/README
@@ -0,0 +1,17 @@
+creg is a fast tool for training linear and logistic regression models with
+l_1 and l_2 regularization. Its data (feature and response) format is
+compatible with ARKRegression.
+
+EXAMPLES
+
+Logistic regression example (training only):
+ $ ./creg -x test_data/iris.trainfeat -y test_data/iris.trainresp --l1 1.0 > weights.txt
+
+Logistic regression example (training and testing):
+ $ ./creg -x test_data/iris.trainfeat -y test_data/iris.trainresp --l1 1.0 \
+ -t test_data/iris.testfeat -s test_data/iris.testresp > weights.txt
+
+Linear regression example (training and testing):
+ $ ./creg -n -x test_data/auto-mpg.trainfeat -y test_data/auto-mpg.trainresp --l2 1000 \
+ -t test_data/auto-mpg.testfeat -s test_data/auto-mpg.testresp > weights.txt
+
diff --git a/creg/creg.cc b/creg/creg.cc
new file mode 100644
index 00000000..005ec9ac
--- /dev/null
+++ b/creg/creg.cc
@@ -0,0 +1,384 @@
+#include <cstdlib>
+#include <iostream>
+#include <vector>
+#include <tr1/unordered_map>
+#include <limits>
+#include <cmath>
+
+#include <boost/program_options.hpp>
+#include <boost/program_options/variables_map.hpp>
+
+#include "json_feature_map_lexer.h"
+#include "prob.h"
+#include "filelib.h"
+#include "weights.h"
+#include "sparse_vector.h"
+#include "liblbfgs/lbfgs++.h"
+
+using namespace std;
+using namespace std::tr1;
+namespace po = boost::program_options;
+
+void InitCommandLine(int argc, char** argv, po::variables_map* conf) {
+ po::options_description opts("Configuration options");
+ opts.add_options()
+ ("training_features,x", po::value<string>(), "File containing training instance features (ARKRegression format)")
+ ("training_responses,y", po::value<string>(), "File containing training response features (ARKRegression format)")
+ ("linear,n", "Linear (rather than logistic) regression")
+ ("l1",po::value<double>()->default_value(0.0), "l_1 regularization strength")
+ ("l2",po::value<double>()->default_value(0.0), "l_2 regularization strength")
+ ("test_features,t", po::value<string>(), "File containing training instance features (ARKRegression format)")
+ ("test_responses,s", po::value<string>(), "File containing training response features (ARKRegression format)")
+ ("weights,w", po::value<string>(), "Initial weights")
+ ("epsilon,e", po::value<double>()->default_value(1e-4), "Epsilon for convergence test. Terminates when ||g|| < epsilon * max(1, ||w||)")
+ ("memory_buffers,m",po::value<unsigned>()->default_value(40), "Number of memory buffers for LBFGS")
+ ("help,h", "Help");
+ po::options_description dcmdline_options;
+ dcmdline_options.add(opts);
+ po::store(parse_command_line(argc, argv, dcmdline_options), *conf);
+ if (conf->count("help") || !conf->count("training_features") || !conf->count("training_responses")) {
+ cerr << dcmdline_options << endl;
+ exit(1);
+ }
+}
+
+struct TrainingInstance {
+ SparseVector<float> x;
+ union {
+ unsigned label; // for categorical predictions
+ float value; // for continuous predictions
+ } y;
+};
+
+struct ReaderHelper {
+ explicit ReaderHelper(vector<TrainingInstance>* xyp) : xy_pairs(xyp), lc(), flag() {}
+ unordered_map<string, unsigned> id2ind;
+ vector<TrainingInstance>* xy_pairs;
+ int lc;
+ bool flag;
+};
+
+void ReaderCB(const string& id, const SparseVector<float>& fmap, void* extra) {
+ ReaderHelper& rh = *reinterpret_cast<ReaderHelper*>(extra);
+ ++rh.lc;
+ if (rh.lc % 1000 == 0) { cerr << '.'; rh.flag = true; }
+ if (rh.lc % 40000 == 0) { cerr << " [" << rh.lc << "]\n"; rh.flag = false; }
+ const unordered_map<string, unsigned>::iterator it = rh.id2ind.find(id);
+ if (it == rh.id2ind.end()) {
+ cerr << "Unlabeled example in line " << rh.lc << endl;
+ abort();
+ }
+ (*rh.xy_pairs)[it->second - 1].x = fmap;
+}
+
+void ReadLabeledInstances(const string& ffeats,
+ const string& fresp,
+ const bool is_continuous,
+ vector<TrainingInstance>* xy_pairs,
+ vector<string>* labels) {
+ bool flag = false;
+ xy_pairs->clear();
+ int lc = 0;
+ ReaderHelper rh(xy_pairs);
+ unordered_map<string, unsigned> label2id;
+ cerr << "Reading responses from " << fresp << " ..." << endl;
+ ReadFile fr(fresp);
+ for (unsigned i = 0; i < labels->size(); ++i)
+ label2id[(*labels)[i]] = i;
+ istream& in = *fr.stream();
+ string line;
+ while(getline(in, line)) {
+ ++lc;
+ if (lc % 1000 == 0) { cerr << '.'; flag = true; }
+ if (lc % 40000 == 0) { cerr << " [" << lc << "]\n"; flag = false; }
+ if (line.size() == 0) continue;
+ if (line[0] == '#') continue;
+ unsigned p = 0;
+ while (p < line.size() && line[p] != ' ' && line[p] != '\t') { ++p; }
+ unsigned& ind = rh.id2ind[line.substr(0, p)];
+ if (ind != 0) { cerr << "ID " << line.substr(0, p) << " duplicated in line " << lc << endl; abort(); }
+ while (p < line.size() && (line[p] == ' ' || line[p] == '\t')) { ++p; }
+ assert(p < line.size());
+ xy_pairs->push_back(TrainingInstance());
+ ind = xy_pairs->size();
+ if (is_continuous) {
+ xy_pairs->back().y.value = strtof(&line[p], 0);
+ } else { // categorical predictions
+ unordered_map<string, unsigned>::iterator it = label2id.find(line.substr(p));
+ if (it == label2id.end()) {
+ const string label = line.substr(p);
+ it = label2id.insert(make_pair(label, labels->size())).first;
+ labels->push_back(label);
+ }
+ xy_pairs->back().y.label = it->second; // label id
+ }
+ }
+ if (flag) cerr << endl;
+ if (!is_continuous) {
+ cerr << "LABELS:";
+ for (unsigned j = 0; j < labels->size(); ++j)
+ cerr << " " << (*labels)[j];
+ cerr << endl;
+ }
+ cerr << "Reading features from " << ffeats << " ..." << endl;
+ ReadFile ff(ffeats);
+ JSONFeatureMapLexer::ReadRules(ff.stream(), ReaderCB, &rh);
+ if (rh.flag) cerr << endl;
+}
+
+// helper base class (not polymorphic- just a container and some helper functions) for loss functions
+// real loss functions should implement double operator()(const vector<double>& x, double* g),
+// which should evaluate f(x) and g = f'(x)
+struct BaseLoss {
+ // dimp1 = number of categorial outputs possible for logistic regression
+ // for linear regression, it should be 1 more than the dimension of the response variable
+ BaseLoss(
+ const vector<TrainingInstance>& tr,
+ unsigned dimp1,
+ unsigned numfeats,
+ unsigned ll2) : training(tr), K(dimp1), p(numfeats), l2(ll2) {}
+
+ // weight vector layout for K classes, with p features
+ // w[0 : K-1] = bias weights
+ // w[y*p + K : y*p + K + p - 1] = feature weights for y^th class
+ // this representation is used in ComputeDotProducts and GradAdd
+ void ComputeDotProducts(const SparseVector<float>& fx, // feature vector of x
+ const vector<double>& w, // full weight vector
+ vector<double>* pdotprods) const {
+ vector<double>& dotprods = *pdotprods;
+ const unsigned km1 = K - 1;
+ dotprods.resize(km1);
+ for (unsigned y = 0; y < km1; ++y)
+ dotprods[y] = w[y]; // bias terms
+ for (SparseVector<float>::const_iterator it = fx.begin(); it != fx.end(); ++it) {
+ const float fval = it->second;
+ const unsigned fid = it->first;
+ for (unsigned y = 0; y < km1; ++y)
+ dotprods[y] += w[fid + y * p + km1] * fval;
+ }
+ }
+
+ double ApplyRegularizationTerms(const vector<double>& weights,
+ double* g) const {
+ double reg = 0;
+ for (size_t i = K - 1; i < weights.size(); ++i) {
+ const double& w_i = weights[i];
+ reg += l2 * w_i * w_i;
+ g[i] += 2 * l2 * w_i;
+ }
+ return reg;
+ }
+
+ void GradAdd(const SparseVector<float>& fx,
+ const unsigned y,
+ const double scale,
+ double* acc) const {
+ acc[y] += scale; // class bias
+ for (SparseVector<float>::const_iterator it = fx.begin();
+ it != fx.end(); ++it)
+ acc[it->first + y * p + K - 1] += it->second * scale;
+ }
+
+ const vector<TrainingInstance>& training;
+ const unsigned K, p;
+ const double l2;
+};
+
+struct UnivariateSquaredLoss : public BaseLoss {
+ UnivariateSquaredLoss(
+ const vector<TrainingInstance>& tr,
+ unsigned numfeats,
+ const double l2) : BaseLoss(tr, 2, numfeats, l2) {}
+
+ // evaluate squared loss and gradient
+ double operator()(const vector<double>& x, double* g) const {
+ fill(g, g + x.size(), 0.0);
+ double cll = 0;
+ vector<double> dotprods(1); // univariate prediction
+ for (unsigned i = 0; i < training.size(); ++i) {
+ const SparseVector<float>& fmapx = training[i].x;
+ const double refy = training[i].y.value;
+ ComputeDotProducts(fmapx, x, &dotprods);
+ double diff = dotprods[0] - refy;
+ cll += diff * diff;
+
+ double scale = 2 * diff;
+ GradAdd(fmapx, 0, scale, g);
+ }
+ double reg = ApplyRegularizationTerms(x, g);
+ return cll + reg;
+ }
+
+ // return root mse
+ double Evaluate(const vector<TrainingInstance>& test,
+ const vector<double>& w) const {
+ vector<double> dotprods(1); // K-1 degrees of freedom
+ double mse = 0;
+ for (unsigned i = 0; i < test.size(); ++i) {
+ const SparseVector<float>& fmapx = test[i].x;
+ const float refy = test[i].y.value;
+ ComputeDotProducts(fmapx, w, &dotprods);
+ double diff = dotprods[0] - refy;
+ cerr << "line=" << (i+1) << " true=" << refy << " pred=" << dotprods[0] << endl;
+ mse += diff * diff;
+ }
+ mse /= test.size();
+ return sqrt(mse);
+ }
+};
+
+struct MulticlassLogLoss : public BaseLoss {
+ MulticlassLogLoss(
+ const vector<TrainingInstance>& tr,
+ unsigned k,
+ unsigned numfeats,
+ const double l2) : BaseLoss(tr, k, numfeats, l2) {}
+
+ // evaluate log loss and gradient
+ double operator()(const vector<double>& x, double* g) const {
+ fill(g, g + x.size(), 0.0);
+ vector<double> dotprods(K - 1); // K-1 degrees of freedom
+ vector<prob_t> probs(K);
+ double cll = 0;
+ for (unsigned i = 0; i < training.size(); ++i) {
+ const SparseVector<float>& fmapx = training[i].x;
+ const unsigned refy = training[i].y.label;
+ //cerr << "FMAP: " << fmapx << endl;
+ ComputeDotProducts(fmapx, x, &dotprods);
+ prob_t z;
+ for (unsigned j = 0; j < dotprods.size(); ++j)
+ z += (probs[j] = prob_t(dotprods[j], init_lnx()));
+ z += (probs.back() = prob_t::One());
+ for (unsigned y = 0; y < probs.size(); ++y) {
+ probs[y] /= z;
+ //cerr << " p(y=" << y << ")=" << probs[y].as_float() << "\tz=" << z << endl;
+ }
+ cll -= log(probs[refy]); // log p(y | x)
+
+ for (unsigned y = 0; y < dotprods.size(); ++y) {
+ double scale = probs[y].as_float();
+ if (y == refy) { scale -= 1.0; }
+ GradAdd(fmapx, y, scale, g);
+ }
+ }
+ double reg = ApplyRegularizationTerms(x, g);
+ return cll + reg;
+ }
+
+ double Evaluate(const vector<TrainingInstance>& test,
+ const vector<double>& w) const {
+ vector<double> dotprods(K - 1); // K-1 degrees of freedom
+ double correct = 0;
+ for (unsigned i = 0; i < test.size(); ++i) {
+ const SparseVector<float>& fmapx = test[i].x;
+ const unsigned refy = test[i].y.label;
+ ComputeDotProducts(fmapx, w, &dotprods);
+ double best = 0;
+ unsigned besty = dotprods.size();
+ for (unsigned y = 0; y < dotprods.size(); ++y)
+ if (dotprods[y] > best) { best = dotprods[y]; besty = y; }
+ if (refy == besty) { ++correct; }
+ }
+ return correct / test.size();
+ }
+};
+
+template <class LossFunction>
+double LearnParameters(LossFunction& loss,
+ const double l1,
+ const unsigned l1_start,
+ const unsigned memory_buffers,
+ const double eps,
+ vector<double>* px) {
+ LBFGS<LossFunction> lbfgs(px, loss, memory_buffers, l1, l1_start, eps);
+ lbfgs.MinimizeFunction();
+ return 0;
+}
+
+int main(int argc, char** argv) {
+ po::variables_map conf;
+ InitCommandLine(argc, argv, &conf);
+ string line;
+ double l1 = conf["l1"].as<double>();
+ double l2 = conf["l2"].as<double>();
+ const unsigned memory_buffers = conf["memory_buffers"].as<unsigned>();
+ const double epsilon = conf["epsilon"].as<double>();
+ if (l1 < 0.0) {
+ cerr << "L1 strength must be >= 0\n";
+ return 1;
+ }
+ if (l2 < 0.0) {
+ cerr << "L2 strength must be >= 0\n";
+ return 2;
+ }
+
+ const bool is_continuous = conf.count("linear");
+ const string xfile = conf["training_features"].as<string>();
+ const string yfile = conf["training_responses"].as<string>();
+ vector<string> labels; // only populated for non-continuous models
+ vector<TrainingInstance> training, test;
+ ReadLabeledInstances(xfile, yfile, is_continuous, &training, &labels);
+ if (conf.count("test_features")) {
+ const string txfile = conf["test_features"].as<string>();
+ const string tyfile = conf["test_responses"].as<string>();
+ ReadLabeledInstances(txfile, tyfile, is_continuous, &test, &labels);
+ }
+
+ if (conf.count("weights")) {
+ cerr << "Initial weights are not implemented, please implement." << endl;
+ // TODO read weights for categorical and continuous predictions
+ // can't use normal cdec weight framework
+ abort();
+ }
+
+ cerr << " Number of features: " << FD::NumFeats() << endl;
+ cerr << "Number of training examples: " << training.size() << endl;
+ const unsigned p = FD::NumFeats();
+ cout.precision(15);
+
+ if (conf.count("linear")) { // linear regression
+ vector<double> weights(1 + FD::NumFeats(), 0.0);
+ cerr << " Number of parameters: " << weights.size() << endl;
+ UnivariateSquaredLoss loss(training, p, l2);
+ LearnParameters(loss, l1, 1, memory_buffers, epsilon, &weights);
+
+ if (test.size())
+ cerr << "Held-out root MSE: " << loss.Evaluate(test, weights) << endl;
+
+ cout << p << "\t***CONTINUOUS***" << endl;
+ cout << "***BIAS***\t" << weights[0] << endl;
+ for (unsigned f = 0; f < p; ++f) {
+ const double w = weights[1 + f];
+ if (w)
+ cout << FD::Convert(f) << "\t" << w << endl;
+ }
+ } else { // logistic regression
+ vector<double> weights((1 + FD::NumFeats()) * (labels.size() - 1), 0.0);
+ cerr << " Number of parameters: " << weights.size() << endl;
+ cerr << " Number of labels: " << labels.size() << endl;
+ const unsigned K = labels.size();
+ const unsigned km1 = K - 1;
+ MulticlassLogLoss loss(training, K, p, l2);
+ LearnParameters(loss, l1, km1, memory_buffers, epsilon, &weights);
+
+ if (test.size())
+ cerr << "Held-out accuracy: " << loss.Evaluate(test, weights) << endl;
+
+ cout << p << "\t***CATEGORICAL***";
+ for (unsigned y = 0; y < K; ++y)
+ cout << '\t' << labels[y];
+ cout << endl;
+ for (unsigned y = 0; y < km1; ++y)
+ cout << labels[y] << "\t***BIAS***\t" << weights[y] << endl;
+ for (unsigned y = 0; y < km1; ++y) {
+ for (unsigned f = 0; f < p; ++f) {
+ const double w = weights[km1 + y * p + f];
+ if (w)
+ cout << labels[y] << "\t" << FD::Convert(f) << "\t" << w << endl;
+ }
+ }
+ }
+
+ return 0;
+}
+
diff --git a/creg/json_feature_map_lexer.h b/creg/json_feature_map_lexer.h
new file mode 100644
index 00000000..3324aa29
--- /dev/null
+++ b/creg/json_feature_map_lexer.h
@@ -0,0 +1,15 @@
+#ifndef _RULE_LEXER_H_
+#define _RULE_LEXER_H_
+
+#include <iostream>
+#include <string>
+
+#include "sparse_vector.h"
+
+struct JSONFeatureMapLexer {
+ typedef void (*FeatureMapCallback)(const std::string& id, const SparseVector<float>& fmap, void* extra);
+ static void ReadRules(std::istream* in, FeatureMapCallback func, void* extra);
+};
+
+#endif
+
diff --git a/creg/json_feature_map_lexer.ll b/creg/json_feature_map_lexer.ll
new file mode 100644
index 00000000..cbb6d9a9
--- /dev/null
+++ b/creg/json_feature_map_lexer.ll
@@ -0,0 +1,132 @@
+%option nounput
+%{
+
+#include "json_feature_map_lexer.h"
+#include "fdict.h"
+#include "fast_sparse_vector.h"
+
+#define YY_DECL int json_fmap_yylex (void)
+#undef YY_INPUT
+#define YY_INPUT(buf, result, max_size) (result = jfmap_stream->read(buf, max_size).gcount())
+#define YY_SKIP_YYWRAP 1
+int yywrap() { return 1; }
+
+JSONFeatureMapLexer::FeatureMapCallback json_fmap_callback = NULL;
+void* json_fmap_callback_extra = NULL;
+std::istream* jfmap_stream = NULL;
+bool fl = true;
+unsigned spos = 0;
+char featname[16000];
+#define MAX_FEATS 20000
+std::pair<int, float> featmap[MAX_FEATS];
+unsigned curfeat = 0;
+std::string instid;
+
+inline unsigned unicode_escape_to_utf8(uint16_t w1, uint16_t w2, char* putf8) {
+ uint32_t cp;
+ if((w1 & 0xfc00) == 0xd800) {
+ if((w2 & 0xfc00) == 0xdc00) {
+ cp = 0x10000 + (((static_cast<uint32_t>(w1) & 0x3ff) << 10) | (w2 & 0x3ff));
+ } else {
+ abort();
+ }
+ } else {
+ cp = w1;
+ }
+
+
+ if(cp < 0x80) {
+ putf8[0] = static_cast<char>(cp);
+ return 1;
+ } else if(cp < 0x0800) {
+ putf8[0] = 0xc0 | ((cp >> 6) & 0x1f);
+ putf8[1] = 0x80 | (cp & 0x3f);
+ return 2;
+ } else if(cp < 0x10000) {
+ putf8[0] = 0xe0 | ((cp >> 6) & 0x0f);
+ putf8[1] = 0x80 | ((cp >> 6) & 0x3f);
+ putf8[2] = 0x80 | (cp & 0x3f);
+ return 3;
+ } else if(cp < 0x1fffff) {
+ putf8[0] = 0xf0 | ((cp >> 18) & 0x07);
+ putf8[1] = 0x80 | ((cp >> 12) & 0x3f);
+ putf8[2] = 0x80 | ((cp >> 6) & 0x3f);
+ putf8[3] = 0x80 | (cp & 0x3f);
+ return 4;
+ } else {
+ abort();
+ }
+ return 0;
+}
+
+%}
+
+ID [^ \t\n\r]+
+HEX_D [a-fA-F0-9]
+INT [-]?[0-9]+
+DOUBLE {INT}((\.[0-9]+)?([eE][-+]?[0-9]+)?)
+WS [ \t\r\n]
+LCB [{]
+RCB [}]
+UNESCAPED_CH [^\"\\\b\n\r\f\t]
+
+%x JSON PREVAL STRING JSONVAL POSTVAL DOUBLE
+%%
+
+<INITIAL>{ID} { instid = yytext; BEGIN(JSON); }
+
+<JSON>{WS}*{LCB}{WS}* { BEGIN(PREVAL); }
+
+<PREVAL>\" { BEGIN(STRING); spos=0; }
+
+<STRING>\" { featname[spos] = 0;
+ featmap[curfeat].first = FD::Convert(featname);
+ BEGIN(JSONVAL);
+ }
+<STRING>{UNESCAPED_CH} { featname[spos++] = yytext[0]; }
+<STRING>\\\" { featname[spos++] = '"'; }
+<STRING>\\\\ { featname[spos++] = '\\'; }
+<STRING>\\\/ { featname[spos++] = '/'; }
+<STRING>\\b { }
+<STRING>\\f { }
+<STRING>\\n { }
+<STRING>\\r { }
+<STRING>\\t { }
+<STRING>\\u{HEX_D}{HEX_D}{HEX_D}{HEX_D} { abort();
+ }
+
+<JSONVAL>{WS}*:{WS}* { BEGIN(DOUBLE); }
+<DOUBLE>{DOUBLE} { featmap[curfeat++].second = strtod(yytext, 0);
+ BEGIN(POSTVAL); }
+
+<POSTVAL>{WS}*,{WS}* { BEGIN(PREVAL); }
+<POSTVAL>{WS}*{RCB}\n* {
+ const SparseVector<float> x(&featmap[0], &featmap[curfeat]);
+ json_fmap_callback(instid, x, json_fmap_callback_extra);
+ curfeat = 0;
+ BEGIN(INITIAL);
+ }
+
+<PREVAL,POSTVAL,DOUBLE,JSONVAL,INITIAL>. { std::cerr << "bad input: " << yytext << std::endl; abort(); }
+
+%%
+
+void JSONFeatureMapLexer::ReadRules(std::istream* in, FeatureMapCallback func, void* extra) {
+ json_fmap_callback = func;
+ json_fmap_callback_extra = extra;
+ jfmap_stream = in;
+ json_fmap_yylex();
+}
+
+#if 0
+void cb(const std::string& id, const SparseVector<float>& fmap, void* extra) {
+ (void) extra;
+ static int cc = 0;
+ cc++;
+}
+
+int main() {
+ JSONFeatureMapLexer::ReadRules(&std::cin, cb, NULL);
+}
+#endif
+
diff --git a/creg/test_data/auto-mpg.testfeat b/creg/test_data/auto-mpg.testfeat
new file mode 100644
index 00000000..91c21e99
--- /dev/null
+++ b/creg/test_data/auto-mpg.testfeat
@@ -0,0 +1,93 @@
+test1_fiat_124b {"horsepower": 76.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 88.0, "weight": 2065.0}
+test2_dodge_aspen {"horsepower": 110.0, "acceleration": 18.7, "cylinders": 6.0, "displacement": 225.0, "weight": 3620.0}
+test3_toyota_celica_gt_liftback {"horsepower": 95.0, "acceleration": 14.8, "cylinders": 4.0, "displacement": 134.0, "weight": 2515.0}
+test4_amc_matador {"horsepower": 110.0, "acceleration": 18.0, "cylinders": 6.0, "displacement": 258.0, "weight": 3632.0}
+test5_audi_5000s_(diesel) {"horsepower": 67.0, "acceleration": 19.9, "cylinders": 5.0, "displacement": 121.0, "weight": 2950.0}
+test6_datsun_310 {"horsepower": 65.0, "acceleration": 16.4, "cylinders": 4.0, "displacement": 86.0, "weight": 2019.0}
+test7_chevrolet_woody {"horsepower": 60.0, "acceleration": 22.1, "cylinders": 4.0, "displacement": 98.0, "weight": 2164.0}
+test8_volkswagen_1131_deluxe_sedan {"horsepower": 46.0, "acceleration": 20.5, "cylinders": 4.0, "displacement": 97.0, "weight": 1835.0}
+test9_plymouth_satellite_sebring {"horsepower": 105.0, "acceleration": 16.5, "cylinders": 6.0, "displacement": 225.0, "weight": 3613.0}
+test10_amc_matador {"horsepower": 120.0, "acceleration": 13.9, "cylinders": 8.0, "displacement": 304.0, "weight": 3962.0}
+test11_chevrolet_chevette {"horsepower": 52.0, "acceleration": 22.2, "cylinders": 4.0, "displacement": 85.0, "weight": 2035.0}
+test12_buick_century_special {"horsepower": 105.0, "acceleration": 15.8, "cylinders": 6.0, "displacement": 231.0, "weight": 3380.0}
+test13_ford_escort_2h {"horsepower": 65.0, "acceleration": 20.7, "cylinders": 4.0, "displacement": 98.0, "weight": 2380.0}
+test14_ford_torino_500 {"horsepower": 88.0, "acceleration": 15.5, "cylinders": 6.0, "displacement": 250.0, "weight": 3302.0}
+test15_dodge_aries_wagon_(sw) {"horsepower": 92.0, "acceleration": 14.4, "cylinders": 4.0, "displacement": 156.0, "weight": 2620.0}
+test16_plymouth_valiant {"horsepower": 105.0, "acceleration": 16.5, "cylinders": 6.0, "displacement": 225.0, "weight": 3121.0}
+test17_amc_pacer {"horsepower": 90.0, "acceleration": 17.0, "cylinders": 6.0, "displacement": 232.0, "weight": 3211.0}
+test18_honda_civic {"horsepower": 97.0, "acceleration": 15.0, "cylinders": 4.0, "displacement": 120.0, "weight": 2489.0}
+test19_ford_ltd {"horsepower": 148.0, "acceleration": 13.5, "cylinders": 8.0, "displacement": 351.0, "weight": 4657.0}
+test20_volkswagen_rabbit {"horsepower": 70.0, "acceleration": 14.0, "cylinders": 4.0, "displacement": 90.0, "weight": 1937.0}
+test21_honda_civic_1500_gl {"horsepower": 67.0, "acceleration": 13.8, "cylinders": 4.0, "displacement": 91.0, "weight": 1850.0}
+test22_chevrolet_impala {"horsepower": 165.0, "acceleration": 12.0, "cylinders": 8.0, "displacement": 350.0, "weight": 4209.0}
+test23_chevrolet_chevette {"horsepower": 63.0, "acceleration": 17.0, "cylinders": 4.0, "displacement": 98.0, "weight": 2051.0}
+test24_amc_concord {"horsepower": 90.0, "acceleration": 17.2, "cylinders": 6.0, "displacement": 232.0, "weight": 3210.0}
+test25_ford_pinto {"horsepower": 83.0, "acceleration": 17.0, "cylinders": 4.0, "displacement": 140.0, "weight": 2639.0}
+test26_ford_country_squire_(sw) {"horsepower": 142.0, "acceleration": 14.3, "cylinders": 8.0, "displacement": 351.0, "weight": 4054.0}
+test27_plymouth_valiant_custom {"horsepower": 95.0, "acceleration": 16.0, "cylinders": 6.0, "displacement": 225.0, "weight": 3264.0}
+test28_chevy_s-10 {"horsepower": 82.0, "acceleration": 19.4, "cylinders": 4.0, "displacement": 119.0, "weight": 2720.0}
+test29_maxda_rx3 {"horsepower": 90.0, "acceleration": 13.5, "cylinders": 3.0, "displacement": 70.0, "weight": 2124.0}
+test30_plymouth_sapporo {"horsepower": 105.0, "acceleration": 16.7, "cylinders": 4.0, "displacement": 156.0, "weight": 2745.0}
+test31_amc_hornet {"horsepower": 90.0, "acceleration": 17.6, "cylinders": 6.0, "displacement": 232.0, "weight": 3085.0}
+test32_chevrolet_caprice_classic {"horsepower": 145.0, "acceleration": 12.5, "cylinders": 8.0, "displacement": 305.0, "weight": 3880.0}
+test33_pontiac_sunbird_coupe {"horsepower": 88.0, "acceleration": 16.0, "cylinders": 4.0, "displacement": 151.0, "weight": 2740.0}
+test34_mercury_marquis_brougham {"horsepower": 198.0, "acceleration": 11.5, "cylinders": 8.0, "displacement": 429.0, "weight": 4952.0}
+test35_mercury_monarch_ghia {"horsepower": 139.0, "acceleration": 12.8, "cylinders": 8.0, "displacement": 302.0, "weight": 3570.0}
+test36_ford_country_squire_(sw) {"horsepower": 170.0, "acceleration": 12.0, "cylinders": 8.0, "displacement": 400.0, "weight": 4746.0}
+test37_audi_fox {"horsepower": 83.0, "acceleration": 16.5, "cylinders": 4.0, "displacement": 98.0, "weight": 2219.0}
+test38_triumph_tr7_coupe {"horsepower": 88.0, "acceleration": 15.1, "cylinders": 4.0, "displacement": 122.0, "weight": 2500.0}
+test39_dodge_d100 {"horsepower": 150.0, "acceleration": 14.0, "cylinders": 8.0, "displacement": 318.0, "weight": 3755.0}
+test40_mercury_cougar_brougham {"horsepower": 130.0, "acceleration": 14.9, "cylinders": 8.0, "displacement": 302.0, "weight": 4295.0}
+test41_pontiac_phoenix_lj {"horsepower": 105.0, "acceleration": 19.2, "cylinders": 6.0, "displacement": 231.0, "weight": 3535.0}
+test42_vw_rabbit_custom {"horsepower": 71.0, "acceleration": 14.0, "cylinders": 4.0, "displacement": 89.0, "weight": 1925.0}
+test43_peugeot_504 {"horsepower": 87.0, "acceleration": 17.5, "cylinders": 4.0, "displacement": 110.0, "weight": 2672.0}
+test44_datsun_310_gx {"horsepower": 67.0, "acceleration": 16.2, "cylinders": 4.0, "displacement": 91.0, "weight": 1995.0}
+test45_dodge_monaco_(sw) {"horsepower": 180.0, "acceleration": 11.5, "cylinders": 8.0, "displacement": 383.0, "weight": 4955.0}
+test46_chevrolet_monza_2+2 {"horsepower": 110.0, "acceleration": 13.5, "cylinders": 8.0, "displacement": 262.0, "weight": 3221.0}
+test47_capri_ii {"horsepower": 92.0, "acceleration": 14.9, "cylinders": 4.0, "displacement": 140.0, "weight": 2572.0}
+test48_mazda_rx2_coupe {"horsepower": 97.0, "acceleration": 13.5, "cylinders": 3.0, "displacement": 70.0, "weight": 2330.0}
+test49_plymouth_fury {"horsepower": 95.0, "acceleration": 19.0, "cylinders": 6.0, "displacement": 225.0, "weight": 3785.0}
+test50_plymouth_fury_iii {"horsepower": 215.0, "acceleration": 8.5, "cylinders": 8.0, "displacement": 440.0, "weight": 4312.0}
+test51_dodge_st._regis {"horsepower": 135.0, "acceleration": 15.2, "cylinders": 8.0, "displacement": 318.0, "weight": 3830.0}
+test52_amc_spirit_dl {"horsepower": 80.0, "acceleration": 15.0, "cylinders": 4.0, "displacement": 121.0, "weight": 2670.0}
+test53_peugeot_504_(sw) {"horsepower": 87.0, "acceleration": 19.5, "cylinders": 4.0, "displacement": 120.0, "weight": 2979.0}
+test54_chevroelt_chevelle_malibu {"horsepower": 105.0, "acceleration": 18.5, "cylinders": 6.0, "displacement": 250.0, "weight": 3897.0}
+test55_opel_1900 {"horsepower": 90.0, "acceleration": 14.0, "cylinders": 4.0, "displacement": 116.0, "weight": 2123.0}
+test56_dodge_challenger_se {"horsepower": 170.0, "acceleration": 10.0, "cylinders": 8.0, "displacement": 383.0, "weight": 3563.0}
+test57_vw_pickup {"horsepower": 52.0, "acceleration": 24.6, "cylinders": 4.0, "displacement": 97.0, "weight": 2130.0}
+test58_peugeot_604sl {"horsepower": 133.0, "acceleration": 15.8, "cylinders": 6.0, "displacement": 163.0, "weight": 3410.0}
+test59_mazda_glc_4 {"horsepower": 68.0, "acceleration": 16.0, "cylinders": 4.0, "displacement": 91.0, "weight": 1985.0}
+test60_audi_4000 {"horsepower": 78.0, "acceleration": 15.8, "cylinders": 4.0, "displacement": 97.0, "weight": 2188.0}
+test61_plymouth_duster {"horsepower": 95.0, "acceleration": 16.5, "cylinders": 6.0, "displacement": 198.0, "weight": 3102.0}
+test62_dodge_magnum_xe {"horsepower": 140.0, "acceleration": 13.7, "cylinders": 8.0, "displacement": 318.0, "weight": 4080.0}
+test63_buick_century_limited {"horsepower": 110.0, "acceleration": 16.4, "cylinders": 6.0, "displacement": 181.0, "weight": 2945.0}
+test64_chevrolet_monte_carlo_s {"horsepower": 145.0, "acceleration": 13.0, "cylinders": 8.0, "displacement": 350.0, "weight": 4082.0}
+test65_amc_matador {"horsepower": 150.0, "acceleration": 11.5, "cylinders": 8.0, "displacement": 304.0, "weight": 3672.0}
+test66_honda_accord {"horsepower": 75.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 107.0, "weight": 2205.0}
+test67_plymouth_volare {"horsepower": 100.0, "acceleration": 17.2, "cylinders": 6.0, "displacement": 225.0, "weight": 3430.0}
+test68_ford_galaxie_500 {"horsepower": 198.0, "acceleration": 10.0, "cylinders": 8.0, "displacement": 429.0, "weight": 4341.0}
+test69_chevrolet_citation {"horsepower": 110.0, "acceleration": 12.6, "cylinders": 6.0, "displacement": 173.0, "weight": 2725.0}
+test70_amc_ambassador_sst {"horsepower": 150.0, "acceleration": 11.5, "cylinders": 8.0, "displacement": 304.0, "weight": 3672.0}
+test71_ford_thunderbird {"horsepower": 149.0, "acceleration": 14.5, "cylinders": 8.0, "displacement": 351.0, "weight": 4335.0}
+test72_pontiac_phoenix {"horsepower": 90.0, "acceleration": 13.2, "cylinders": 4.0, "displacement": 151.0, "weight": 2556.0}
+test73_vw_rabbit {"horsepower": 76.0, "acceleration": 14.7, "cylinders": 4.0, "displacement": 98.0, "weight": 2144.0}
+test74_bmw_2002 {"horsepower": 113.0, "acceleration": 12.5, "cylinders": 4.0, "displacement": 121.0, "weight": 2234.0}
+test75_dodge_colt {"horsepower": 105.0, "acceleration": 14.4, "cylinders": 4.0, "displacement": 156.0, "weight": 2800.0}
+test76_mercury_capri_2000 {"horsepower": 86.0, "acceleration": 14.0, "cylinders": 4.0, "displacement": 122.0, "weight": 2220.0}
+test77_ford_galaxie_500 {"horsepower": 153.0, "acceleration": 13.5, "cylinders": 8.0, "displacement": 351.0, "weight": 4154.0}
+test78_volkswagen_rabbit_custom_diesel {"horsepower": 48.0, "acceleration": 21.5, "cylinders": 4.0, "displacement": 90.0, "weight": 1985.0}
+test79_dodge_aspen_se {"horsepower": 100.0, "acceleration": 17.7, "cylinders": 6.0, "displacement": 225.0, "weight": 3651.0}
+test80_mazda_glc_deluxe {"horsepower": 52.0, "acceleration": 19.4, "cylinders": 4.0, "displacement": 78.0, "weight": 1985.0}
+test81_mazda_glc_custom {"horsepower": 68.0, "acceleration": 17.6, "cylinders": 4.0, "displacement": 91.0, "weight": 1970.0}
+test82_audi_100ls {"horsepower": 91.0, "acceleration": 14.0, "cylinders": 4.0, "displacement": 114.0, "weight": 2582.0}
+test83_oldsmobile_delta_88_royale {"horsepower": 160.0, "acceleration": 13.5, "cylinders": 8.0, "displacement": 350.0, "weight": 4456.0}
+test84_ford_gran_torino {"horsepower": 137.0, "acceleration": 14.5, "cylinders": 8.0, "displacement": 302.0, "weight": 4042.0}
+test85_plymouth_cricket {"horsepower": 70.0, "acceleration": 20.5, "cylinders": 4.0, "displacement": 91.0, "weight": 1955.0}
+test86_plymouth_fury_iii {"horsepower": 150.0, "acceleration": 13.0, "cylinders": 8.0, "displacement": 318.0, "weight": 4096.0}
+test87_plymouth_horizon {"horsepower": 70.0, "acceleration": 13.2, "cylinders": 4.0, "displacement": 105.0, "weight": 2200.0}
+test88_peugeot_504 {"horsepower": 88.0, "acceleration": 21.9, "cylinders": 4.0, "displacement": 120.0, "weight": 3270.0}
+test89_dodge_dart_custom {"horsepower": 150.0, "acceleration": 11.0, "cylinders": 8.0, "displacement": 318.0, "weight": 3399.0}
+test90_pontiac_j2000_se_hatchback {"horsepower": 85.0, "acceleration": 16.2, "cylinders": 4.0, "displacement": 112.0, "weight": 2575.0}
+test91_toyota_starlet {"horsepower": 58.0, "acceleration": 16.9, "cylinders": 4.0, "displacement": 79.0, "weight": 1755.0}
+test92_mazda_glc_custom_l {"horsepower": 68.0, "acceleration": 18.2, "cylinders": 4.0, "displacement": 91.0, "weight": 2025.0}
+test93_fiat_124_tc {"horsepower": 75.0, "acceleration": 14.0, "cylinders": 4.0, "displacement": 116.0, "weight": 2246.0}
diff --git a/creg/test_data/auto-mpg.testresp b/creg/test_data/auto-mpg.testresp
new file mode 100644
index 00000000..4f2cad37
--- /dev/null
+++ b/creg/test_data/auto-mpg.testresp
@@ -0,0 +1,93 @@
+test1_fiat_124b 30.0
+test2_dodge_aspen 18.6
+test3_toyota_celica_gt_liftback 21.1
+test4_amc_matador 16.0
+test5_audi_5000s_(diesel) 36.4
+test6_datsun_310 37.2
+test7_chevrolet_woody 24.5
+test8_volkswagen_1131_deluxe_sedan 26.0
+test9_plymouth_satellite_sebring 18.0
+test10_amc_matador 15.5
+test11_chevrolet_chevette 29.0
+test12_buick_century_special 20.6
+test13_ford_escort_2h 29.9
+test14_ford_torino_500 19.0
+test15_dodge_aries_wagon_(sw) 25.8
+test16_plymouth_valiant 18.0
+test17_amc_pacer 19.0
+test18_honda_civic 24.0
+test19_ford_ltd 14.0
+test20_volkswagen_rabbit 29.0
+test21_honda_civic_1500_gl 44.6
+test22_chevrolet_impala 14.0
+test23_chevrolet_chevette 30.5
+test24_amc_concord 19.4
+test25_ford_pinto 23.0
+test26_ford_country_squire_(sw) 15.5
+test27_plymouth_valiant_custom 19.0
+test28_chevy_s-10 31.0
+test29_maxda_rx3 18.0
+test30_plymouth_sapporo 23.2
+test31_amc_hornet 22.5
+test32_chevrolet_caprice_classic 17.5
+test33_pontiac_sunbird_coupe 24.5
+test34_mercury_marquis_brougham 12.0
+test35_mercury_monarch_ghia 20.2
+test36_ford_country_squire_(sw) 13.0
+test37_audi_fox 29.0
+test38_triumph_tr7_coupe 35.0
+test39_dodge_d100 13.0
+test40_mercury_cougar_brougham 15.0
+test41_pontiac_phoenix_lj 19.2
+test42_vw_rabbit_custom 31.9
+test43_peugeot_504 25.0
+test44_datsun_310_gx 38.0
+test45_dodge_monaco_(sw) 12.0
+test46_chevrolet_monza_2+2 20.0
+test47_capri_ii 25.0
+test48_mazda_rx2_coupe 19.0
+test49_plymouth_fury 18.0
+test50_plymouth_fury_iii 14.0
+test51_dodge_st._regis 18.2
+test52_amc_spirit_dl 27.4
+test53_peugeot_504_(sw) 21.0
+test54_chevroelt_chevelle_malibu 16.0
+test55_opel_1900 28.0
+test56_dodge_challenger_se 15.0
+test57_vw_pickup 44.0
+test58_peugeot_604sl 16.2
+test59_mazda_glc_4 34.1
+test60_audi_4000 34.3
+test61_plymouth_duster 20.0
+test62_dodge_magnum_xe 17.5
+test63_buick_century_limited 25.0
+test64_chevrolet_monte_carlo_s 15.0
+test65_amc_matador 14.0
+test66_honda_accord 36.0
+test67_plymouth_volare 20.5
+test68_ford_galaxie_500 15.0
+test69_chevrolet_citation 23.5
+test70_amc_ambassador_sst 17.0
+test71_ford_thunderbird 16.0
+test72_pontiac_phoenix 33.5
+test73_vw_rabbit 41.5
+test74_bmw_2002 26.0
+test75_dodge_colt 27.9
+test76_mercury_capri_2000 23.0
+test77_ford_galaxie_500 14.0
+test78_volkswagen_rabbit_custom_diesel 43.1
+test79_dodge_aspen_se 20.0
+test80_mazda_glc_deluxe 32.8
+test81_mazda_glc_custom 31.0
+test82_audi_100ls 20.0
+test83_oldsmobile_delta_88_royale 12.0
+test84_ford_gran_torino 14.0
+test85_plymouth_cricket 26.0
+test86_plymouth_fury_iii 14.0
+test87_plymouth_horizon 34.2
+test88_peugeot_504 19.0
+test89_dodge_dart_custom 15.0
+test90_pontiac_j2000_se_hatchback 31.0
+test91_toyota_starlet 39.1
+test92_mazda_glc_custom_l 37.0
+test93_fiat_124_tc 26.0
diff --git a/creg/test_data/auto-mpg.trainfeat b/creg/test_data/auto-mpg.trainfeat
new file mode 100644
index 00000000..20b87d3f
--- /dev/null
+++ b/creg/test_data/auto-mpg.trainfeat
@@ -0,0 +1,300 @@
+train1_buick_century_350 {"horsepower": 175.0, "acceleration": 13.0, "cylinders": 8.0, "displacement": 350.0, "weight": 4100.0}
+train2_audi_100_ls {"horsepower": 90.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 107.0, "weight": 2430.0}
+train3_chrysler_newport_royal {"horsepower": 190.0, "acceleration": 12.5, "cylinders": 8.0, "displacement": 400.0, "weight": 4422.0}
+train4_mercury_zephyr_6 {"horsepower": 85.0, "acceleration": 18.2, "cylinders": 6.0, "displacement": 200.0, "weight": 2990.0}
+train5_volkswagen_model_111 {"horsepower": 60.0, "acceleration": 19.0, "cylinders": 4.0, "displacement": 97.0, "weight": 1834.0}
+train6_dodge_monaco_brougham {"horsepower": 145.0, "acceleration": 13.7, "cylinders": 8.0, "displacement": 318.0, "weight": 4140.0}
+train7_mercedes-benz_240d {"horsepower": 67.0, "acceleration": 21.8, "cylinders": 4.0, "displacement": 146.0, "weight": 3250.0}
+train8_datsun_510_(sw) {"horsepower": 92.0, "acceleration": 17.0, "cylinders": 4.0, "displacement": 97.0, "weight": 2288.0}
+train9_opel_manta {"horsepower": 75.0, "acceleration": 15.5, "cylinders": 4.0, "displacement": 116.0, "weight": 2158.0}
+train10_renault_12_(sw) {"horsepower": 69.0, "acceleration": 18.0, "cylinders": 4.0, "displacement": 96.0, "weight": 2189.0}
+train11_chevrolet_nova {"horsepower": 100.0, "acceleration": 17.0, "cylinders": 6.0, "displacement": 250.0, "weight": 3336.0}
+train12_plymouth_arrow_gs {"horsepower": 96.0, "acceleration": 15.5, "cylinders": 4.0, "displacement": 122.0, "weight": 2300.0}
+train13_toyota_mark_ii {"horsepower": 108.0, "acceleration": 15.5, "cylinders": 6.0, "displacement": 156.0, "weight": 2930.0}
+train14_chevrolet_caprice_classic {"horsepower": 150.0, "acceleration": 12.0, "cylinders": 8.0, "displacement": 400.0, "weight": 4464.0}
+train15_ford_maverick {"horsepower": 88.0, "acceleration": 16.5, "cylinders": 6.0, "displacement": 250.0, "weight": 3021.0}
+train16_pontiac_lemans_v6 {"horsepower": 115.0, "acceleration": 15.4, "cylinders": 6.0, "displacement": 231.0, "weight": 3245.0}
+train17_ford_granada_gl {"horsepower": 88.0, "acceleration": 17.1, "cylinders": 6.0, "displacement": 200.0, "weight": 3060.0}
+train18_chevrolet_monte_carlo_landau {"horsepower": 170.0, "acceleration": 11.4, "cylinders": 8.0, "displacement": 350.0, "weight": 4165.0}
+train19_subaru {"horsepower": 93.0, "acceleration": 15.5, "cylinders": 4.0, "displacement": 108.0, "weight": 2391.0}
+train20_volkswagen_411_(sw) {"horsepower": 76.0, "acceleration": 18.0, "cylinders": 4.0, "displacement": 121.0, "weight": 2511.0}
+train21_chrysler_lebaron_salon {"horsepower": 85.0, "acceleration": 16.6, "cylinders": 6.0, "displacement": 225.0, "weight": 3465.0}
+train22_volkswagen_jetta {"horsepower": 74.0, "acceleration": 14.2, "cylinders": 4.0, "displacement": 105.0, "weight": 2190.0}
+train23_dodge_coronet_brougham {"horsepower": 150.0, "acceleration": 13.0, "cylinders": 8.0, "displacement": 318.0, "weight": 4190.0}
+train24_pontiac_safari_(sw) {"horsepower": 175.0, "acceleration": 12.0, "cylinders": 8.0, "displacement": 400.0, "weight": 5140.0}
+train25_mazda_rx-7_gs {"horsepower": 100.0, "acceleration": 12.5, "cylinders": 3.0, "displacement": 70.0, "weight": 2420.0}
+train26_datsun_210 {"horsepower": 65.0, "acceleration": 19.2, "cylinders": 4.0, "displacement": 85.0, "weight": 2110.0}
+train27_vw_rabbit_c_(diesel) {"horsepower": 48.0, "acceleration": 21.7, "cylinders": 4.0, "displacement": 90.0, "weight": 2085.0}
+train28_nissan_stanza_xe {"horsepower": 88.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 120.0, "weight": 2160.0}
+train29_audi_5000 {"horsepower": 103.0, "acceleration": 15.9, "cylinders": 5.0, "displacement": 131.0, "weight": 2830.0}
+train30_chevrolet_malibu {"horsepower": 145.0, "acceleration": 13.0, "cylinders": 8.0, "displacement": 350.0, "weight": 3988.0}
+train31_mercury_capri_v6 {"horsepower": 107.0, "acceleration": 14.0, "cylinders": 6.0, "displacement": 155.0, "weight": 2472.0}
+train32_datsun_b210_gx {"horsepower": 70.0, "acceleration": 18.6, "cylinders": 4.0, "displacement": 85.0, "weight": 2070.0}
+train33_volkswagen_dasher {"horsepower": 67.0, "acceleration": 15.5, "cylinders": 4.0, "displacement": 79.0, "weight": 1963.0}
+train34_volvo_145e_(sw) {"horsepower": 112.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 121.0, "weight": 2933.0}
+train35_chrysler_lebaron_medallion {"horsepower": 92.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 156.0, "weight": 2585.0}
+train36_pontiac_catalina {"horsepower": 170.0, "acceleration": 11.5, "cylinders": 8.0, "displacement": 400.0, "weight": 4668.0}
+train37_toyota_tercel {"horsepower": 62.0, "acceleration": 17.3, "cylinders": 4.0, "displacement": 89.0, "weight": 2050.0}
+train38_datsun_f-10_hatchback {"horsepower": 70.0, "acceleration": 16.8, "cylinders": 4.0, "displacement": 85.0, "weight": 1945.0}
+train39_chrysler_lebaron_town_@_country_(sw) {"horsepower": 150.0, "acceleration": 13.0, "cylinders": 8.0, "displacement": 360.0, "weight": 3940.0}
+train40_buick_century {"horsepower": 110.0, "acceleration": 15.8, "cylinders": 6.0, "displacement": 231.0, "weight": 3415.0}
+train41_amc_matador_(sw) {"horsepower": 150.0, "acceleration": 12.5, "cylinders": 8.0, "displacement": 304.0, "weight": 3892.0}
+train42_honda_civic {"horsepower": 67.0, "acceleration": 15.0, "cylinders": 4.0, "displacement": 91.0, "weight": 1965.0}
+train43_dodge_coronet_custom_(sw) {"horsepower": 150.0, "acceleration": 13.5, "cylinders": 8.0, "displacement": 318.0, "weight": 4457.0}
+train44_bmw_320i {"horsepower": 110.0, "acceleration": 12.8, "cylinders": 4.0, "displacement": 121.0, "weight": 2600.0}
+train45_mercury_marquis {"horsepower": 208.0, "acceleration": 11.0, "cylinders": 8.0, "displacement": 429.0, "weight": 4633.0}
+train46_amc_matador_(sw) {"horsepower": 150.0, "acceleration": 15.5, "cylinders": 8.0, "displacement": 304.0, "weight": 4257.0}
+train47_ford_ltd {"horsepower": 158.0, "acceleration": 13.0, "cylinders": 8.0, "displacement": 351.0, "weight": 4363.0}
+train48_toyota_corolla_1200 {"horsepower": 65.0, "acceleration": 19.0, "cylinders": 4.0, "displacement": 71.0, "weight": 1773.0}
+train49_amc_ambassador_brougham {"horsepower": 175.0, "acceleration": 11.0, "cylinders": 8.0, "displacement": 360.0, "weight": 3821.0}
+train50_ford_galaxie_500 {"horsepower": 153.0, "acceleration": 13.0, "cylinders": 8.0, "displacement": 351.0, "weight": 4129.0}
+train51_amc_concord_d/l {"horsepower": 120.0, "acceleration": 15.1, "cylinders": 6.0, "displacement": 258.0, "weight": 3410.0}
+train52_amc_matador {"horsepower": 100.0, "acceleration": 15.5, "cylinders": 6.0, "displacement": 232.0, "weight": 3288.0}
+train53_toyota_corona {"horsepower": 96.0, "acceleration": 13.5, "cylinders": 4.0, "displacement": 134.0, "weight": 2702.0}
+train54_plymouth_reliant {"horsepower": 84.0, "acceleration": 15.7, "cylinders": 4.0, "displacement": 135.0, "weight": 2490.0}
+train55_ford_pinto {"horsepower": 97.0, "acceleration": 14.5, "cylinders": 6.0, "displacement": 171.0, "weight": 2984.0}
+train56_datsun_810 {"horsepower": 97.0, "acceleration": 14.5, "cylinders": 6.0, "displacement": 146.0, "weight": 2815.0}
+train57_fiat_x1.9 {"horsepower": 67.0, "acceleration": 16.0, "cylinders": 4.0, "displacement": 79.0, "weight": 2000.0}
+train58_mercury_zephyr {"horsepower": 85.0, "acceleration": 16.7, "cylinders": 6.0, "displacement": 200.0, "weight": 3070.0}
+train59_toyota_corolla_1600_(sw) {"horsepower": 88.0, "acceleration": 16.5, "cylinders": 4.0, "displacement": 97.0, "weight": 2100.0}
+train60_chevrolet_chevette {"horsepower": 68.0, "acceleration": 16.5, "cylinders": 4.0, "displacement": 98.0, "weight": 2155.0}
+train61_toyota_cressida {"horsepower": 116.0, "acceleration": 12.6, "cylinders": 6.0, "displacement": 168.0, "weight": 2900.0}
+train62_toyota_corolla {"horsepower": 70.0, "acceleration": 16.9, "cylinders": 4.0, "displacement": 108.0, "weight": 2245.0}
+train63_datsun_710 {"horsepower": 97.0, "acceleration": 17.0, "cylinders": 4.0, "displacement": 119.0, "weight": 2545.0}
+train64_mercury_grand_marquis {"horsepower": 138.0, "acceleration": 13.2, "cylinders": 8.0, "displacement": 351.0, "weight": 3955.0}
+train65_plymouth_champ {"horsepower": 64.0, "acceleration": 16.4, "cylinders": 4.0, "displacement": 86.0, "weight": 1875.0}
+train66_datsun_200-sx {"horsepower": 97.0, "acceleration": 14.9, "cylinders": 4.0, "displacement": 119.0, "weight": 2405.0}
+train67_chevrolet_nova {"horsepower": 105.0, "acceleration": 16.0, "cylinders": 6.0, "displacement": 250.0, "weight": 3459.0}
+train68_hi_1200d {"horsepower": 193.0, "acceleration": 18.5, "cylinders": 8.0, "displacement": 304.0, "weight": 4732.0}
+train69_ford_country {"horsepower": 167.0, "acceleration": 12.5, "cylinders": 8.0, "displacement": 400.0, "weight": 4906.0}
+train70_plymouth_valiant {"horsepower": 100.0, "acceleration": 15.4, "cylinders": 6.0, "displacement": 225.0, "weight": 3233.0}
+train71_amc_gremlin {"horsepower": 100.0, "acceleration": 16.0, "cylinders": 6.0, "displacement": 232.0, "weight": 2914.0}
+train72_ford_pinto_runabout {"horsepower": 86.0, "acceleration": 16.5, "cylinders": 4.0, "displacement": 122.0, "weight": 2226.0}
+train73_chevrolet_monte_carlo_landau {"horsepower": 145.0, "acceleration": 13.2, "cylinders": 8.0, "displacement": 305.0, "weight": 3425.0}
+train74_amc_concord_dl_6 {"horsepower": 90.0, "acceleration": 18.2, "cylinders": 6.0, "displacement": 232.0, "weight": 3265.0}
+train75_pontiac_firebird {"horsepower": 100.0, "acceleration": 15.0, "cylinders": 6.0, "displacement": 250.0, "weight": 3282.0}
+train76_chevrolet_cavalier_2-door {"horsepower": 88.0, "acceleration": 18.0, "cylinders": 4.0, "displacement": 112.0, "weight": 2395.0}
+train77_mercedes-benz_280s {"horsepower": 120.0, "acceleration": 16.7, "cylinders": 6.0, "displacement": 168.0, "weight": 3820.0}
+train78_dodge_d200 {"horsepower": 210.0, "acceleration": 13.5, "cylinders": 8.0, "displacement": 318.0, "weight": 4382.0}
+train79_amc_hornet {"horsepower": 97.0, "acceleration": 15.5, "cylinders": 6.0, "displacement": 199.0, "weight": 2774.0}
+train80_plymouth_reliant {"horsepower": 84.0, "acceleration": 12.9, "cylinders": 4.0, "displacement": 135.0, "weight": 2385.0}
+train81_amc_hornet {"horsepower": 100.0, "acceleration": 16.0, "cylinders": 6.0, "displacement": 232.0, "weight": 2901.0}
+train82_toyota_corona_liftback {"horsepower": 90.0, "acceleration": 15.5, "cylinders": 4.0, "displacement": 134.0, "weight": 2711.0}
+train83_ford_maverick {"horsepower": 72.0, "acceleration": 19.5, "cylinders": 6.0, "displacement": 250.0, "weight": 3158.0}
+train84_cadillac_eldorado {"horsepower": 125.0, "acceleration": 17.4, "cylinders": 8.0, "displacement": 350.0, "weight": 3900.0}
+train85_mercury_monarch {"horsepower": 72.0, "acceleration": 21.0, "cylinders": 6.0, "displacement": 250.0, "weight": 3432.0}
+train86_buick_skylark {"horsepower": 105.0, "acceleration": 16.9, "cylinders": 6.0, "displacement": 231.0, "weight": 3425.0}
+train87_chevrolet_cavalier {"horsepower": 88.0, "acceleration": 19.6, "cylinders": 4.0, "displacement": 112.0, "weight": 2605.0}
+train88_chevrolet_vega {"horsepower": 90.0, "acceleration": 19.5, "cylinders": 4.0, "displacement": 140.0, "weight": 2408.0}
+train89_ford_torino {"horsepower": 140.0, "acceleration": 10.5, "cylinders": 8.0, "displacement": 302.0, "weight": 3449.0}
+train90_chevrolet_chevelle_malibu {"horsepower": 130.0, "acceleration": 12.0, "cylinders": 8.0, "displacement": 307.0, "weight": 3504.0}
+train91_toyota_corona {"horsepower": 52.0, "acceleration": 16.5, "cylinders": 4.0, "displacement": 76.0, "weight": 1649.0}
+train92_buick_opel_isuzu_deluxe {"horsepower": 80.0, "acceleration": 14.8, "cylinders": 4.0, "displacement": 111.0, "weight": 2155.0}
+train93_volvo_244dl {"horsepower": 98.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 121.0, "weight": 2945.0}
+train94_opel_1900 {"horsepower": 81.0, "acceleration": 16.9, "cylinders": 4.0, "displacement": 116.0, "weight": 2220.0}
+train95_peugeot_304 {"horsepower": 70.0, "acceleration": 19.5, "cylinders": 4.0, "displacement": 79.0, "weight": 2074.0}
+train96_toyota_celica_gt {"horsepower": 96.0, "acceleration": 13.9, "cylinders": 4.0, "displacement": 144.0, "weight": 2665.0}
+train97_buick_estate_wagon_(sw) {"horsepower": 155.0, "acceleration": 14.9, "cylinders": 8.0, "displacement": 350.0, "weight": 4360.0}
+train98_volvo_245 {"horsepower": 102.0, "acceleration": 15.7, "cylinders": 4.0, "displacement": 130.0, "weight": 3150.0}
+train99_chevrolet_impala {"horsepower": 150.0, "acceleration": 14.0, "cylinders": 8.0, "displacement": 400.0, "weight": 4997.0}
+train100_chevrolet_bel_air {"horsepower": 145.0, "acceleration": 14.0, "cylinders": 8.0, "displacement": 350.0, "weight": 4440.0}
+train101_datsun_pl510 {"horsepower": 88.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 97.0, "weight": 2130.0}
+train102_saab_99gle {"horsepower": 115.0, "acceleration": 15.7, "cylinders": 4.0, "displacement": 121.0, "weight": 2795.0}
+train103_renault_12tl {"horsepower": 83.0, "acceleration": 15.3, "cylinders": 4.0, "displacement": 101.0, "weight": 2202.0}
+train104_pontiac_catalina {"horsepower": 175.0, "acceleration": 12.0, "cylinders": 8.0, "displacement": 400.0, "weight": 4385.0}
+train105_subaru {"horsepower": 67.0, "acceleration": 17.8, "cylinders": 4.0, "displacement": 97.0, "weight": 2065.0}
+train106_chevrolet_chevette {"horsepower": 70.0, "acceleration": 15.5, "cylinders": 4.0, "displacement": 98.0, "weight": 2120.0}
+train107_saab_99le {"horsepower": 115.0, "acceleration": 13.5, "cylinders": 4.0, "displacement": 121.0, "weight": 2671.0}
+train108_amc_rebel_sst {"horsepower": 150.0, "acceleration": 12.0, "cylinders": 8.0, "displacement": 304.0, "weight": 3433.0}
+train109_ford_gran_torino {"horsepower": 140.0, "acceleration": 14.0, "cylinders": 8.0, "displacement": 302.0, "weight": 4141.0}
+train110_ford_mustang_ii_2+2 {"horsepower": 89.0, "acceleration": 15.8, "cylinders": 4.0, "displacement": 140.0, "weight": 2755.0}
+train111_ford_pinto {"horsepower": 80.0, "acceleration": 16.5, "cylinders": 4.0, "displacement": 122.0, "weight": 2451.0}
+train112_toyota_corolla {"horsepower": 75.0, "acceleration": 16.8, "cylinders": 4.0, "displacement": 108.0, "weight": 2350.0}
+train113_toyota_carina {"horsepower": 88.0, "acceleration": 19.0, "cylinders": 4.0, "displacement": 97.0, "weight": 2279.0}
+train114_amc_hornet {"horsepower": 100.0, "acceleration": 16.0, "cylinders": 6.0, "displacement": 232.0, "weight": 2945.0}
+train115_plymouth_horizon_4 {"horsepower": 63.0, "acceleration": 14.9, "cylinders": 4.0, "displacement": 105.0, "weight": 2215.0}
+train116_chevrolet_nova {"horsepower": 105.0, "acceleration": 14.5, "cylinders": 6.0, "displacement": 250.0, "weight": 3353.0}
+train117_fiat_128 {"horsepower": 75.0, "acceleration": 15.5, "cylinders": 4.0, "displacement": 90.0, "weight": 2108.0}
+train118_dodge_coronet_custom {"horsepower": 150.0, "acceleration": 12.5, "cylinders": 8.0, "displacement": 318.0, "weight": 3777.0}
+train119_volkswagen_rabbit {"horsepower": 71.0, "acceleration": 12.2, "cylinders": 4.0, "displacement": 97.0, "weight": 1825.0}
+train120_chevrolet_camaro {"horsepower": 90.0, "acceleration": 17.3, "cylinders": 4.0, "displacement": 151.0, "weight": 2950.0}
+train121_ford_gran_torino_(sw) {"horsepower": 140.0, "acceleration": 16.0, "cylinders": 8.0, "displacement": 302.0, "weight": 4294.0}
+train122_subaru_dl {"horsepower": 67.0, "acceleration": 16.4, "cylinders": 4.0, "displacement": 97.0, "weight": 1985.0}
+train123_mazda_626 {"horsepower": 75.0, "acceleration": 17.5, "cylinders": 4.0, "displacement": 120.0, "weight": 2542.0}
+train124_oldsmobile_cutlass_salon_brougham {"horsepower": 90.0, "acceleration": 22.2, "cylinders": 8.0, "displacement": 260.0, "weight": 3420.0}
+train125_volvo_144ea {"horsepower": 112.0, "acceleration": 15.5, "cylinders": 4.0, "displacement": 121.0, "weight": 2868.0}
+train126_plymouth_satellite {"horsepower": 150.0, "acceleration": 11.0, "cylinders": 8.0, "displacement": 318.0, "weight": 3436.0}
+train127_amc_gremlin {"horsepower": 100.0, "acceleration": 15.0, "cylinders": 6.0, "displacement": 232.0, "weight": 2789.0}
+train128_chevrolet_malibu_classic_(sw) {"horsepower": 125.0, "acceleration": 15.0, "cylinders": 8.0, "displacement": 267.0, "weight": 3605.0}
+train129_toyota_corolla {"horsepower": 75.0, "acceleration": 16.0, "cylinders": 4.0, "displacement": 97.0, "weight": 2171.0}
+train130_buick_skylark_320 {"horsepower": 165.0, "acceleration": 11.5, "cylinders": 8.0, "displacement": 350.0, "weight": 3693.0}
+train131_toyota_corona_mark_ii {"horsepower": 95.0, "acceleration": 15.0, "cylinders": 4.0, "displacement": 113.0, "weight": 2372.0}
+train132_ford_gran_torino {"horsepower": 152.0, "acceleration": 12.8, "cylinders": 8.0, "displacement": 351.0, "weight": 4215.0}
+train133_dodge_colt {"horsepower": 79.0, "acceleration": 17.7, "cylinders": 4.0, "displacement": 98.0, "weight": 2255.0}
+train134_pontiac_ventura_sj {"horsepower": 110.0, "acceleration": 16.2, "cylinders": 6.0, "displacement": 250.0, "weight": 3645.0}
+train135_oldsmobile_cutlass_ls {"horsepower": 105.0, "acceleration": 19.0, "cylinders": 8.0, "displacement": 350.0, "weight": 3725.0}
+train136_toyouta_corona_mark_ii_(sw) {"horsepower": 97.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 120.0, "weight": 2506.0}
+train137_amc_gremlin {"horsepower": 100.0, "acceleration": 13.0, "cylinders": 6.0, "displacement": 232.0, "weight": 2634.0}
+train138_chevrolet_malibu {"horsepower": 95.0, "acceleration": 18.2, "cylinders": 6.0, "displacement": 200.0, "weight": 3155.0}
+train139_oldsmobile_starfire_sx {"horsepower": 85.0, "acceleration": 17.6, "cylinders": 4.0, "displacement": 151.0, "weight": 2855.0}
+train140_amc_ambassador_dpl {"horsepower": 190.0, "acceleration": 8.5, "cylinders": 8.0, "displacement": 390.0, "weight": 3850.0}
+train141_volkswagen_scirocco {"horsepower": 71.0, "acceleration": 14.9, "cylinders": 4.0, "displacement": 89.0, "weight": 1990.0}
+train142_plymouth_satellite_custom_(sw) {"horsepower": 150.0, "acceleration": 14.0, "cylinders": 8.0, "displacement": 318.0, "weight": 4077.0}
+train143_toyota_corolla_liftback {"horsepower": 75.0, "acceleration": 18.2, "cylinders": 4.0, "displacement": 97.0, "weight": 2265.0}
+train144_ford_fairmont {"horsepower": 88.0, "acceleration": 18.1, "cylinders": 4.0, "displacement": 140.0, "weight": 2870.0}
+train145_plymouth_fury_gran_sedan {"horsepower": 150.0, "acceleration": 14.5, "cylinders": 8.0, "displacement": 318.0, "weight": 4237.0}
+train146_buick_century_luxus_(sw) {"horsepower": 150.0, "acceleration": 14.5, "cylinders": 8.0, "displacement": 350.0, "weight": 4699.0}
+train147_ford_granada_ghia {"horsepower": 78.0, "acceleration": 21.0, "cylinders": 6.0, "displacement": 250.0, "weight": 3574.0}
+train148_dodge_charger_2.2 {"horsepower": 84.0, "acceleration": 13.0, "cylinders": 4.0, "displacement": 135.0, "weight": 2370.0}
+train149_chevrolet_concours {"horsepower": 110.0, "acceleration": 16.4, "cylinders": 6.0, "displacement": 250.0, "weight": 3520.0}
+train150_toyota_corona {"horsepower": 95.0, "acceleration": 14.2, "cylinders": 4.0, "displacement": 134.0, "weight": 2560.0}
+train151_pontiac_grand_prix_lj {"horsepower": 180.0, "acceleration": 11.1, "cylinders": 8.0, "displacement": 400.0, "weight": 4220.0}
+train152_dodge_colt_m/m {"horsepower": 83.0, "acceleration": 15.9, "cylinders": 4.0, "displacement": 98.0, "weight": 2075.0}
+train153_pontiac_astro {"horsepower": 78.0, "acceleration": 18.5, "cylinders": 4.0, "displacement": 140.0, "weight": 2592.0}
+train154_amc_gremlin {"horsepower": 90.0, "acceleration": 15.0, "cylinders": 6.0, "displacement": 199.0, "weight": 2648.0}
+train155_fiat_strada_custom {"horsepower": 69.0, "acceleration": 14.7, "cylinders": 4.0, "displacement": 91.0, "weight": 2130.0}
+train156_toyota_corona_hardtop {"horsepower": 95.0, "acceleration": 15.5, "cylinders": 4.0, "displacement": 113.0, "weight": 2278.0}
+train157_datsun_b210 {"horsepower": 67.0, "acceleration": 19.0, "cylinders": 4.0, "displacement": 79.0, "weight": 1950.0}
+train158_volkswagen_dasher {"horsepower": 78.0, "acceleration": 14.1, "cylinders": 4.0, "displacement": 97.0, "weight": 2190.0}
+train159_plymouth_duster {"horsepower": 95.0, "acceleration": 16.0, "cylinders": 6.0, "displacement": 198.0, "weight": 2904.0}
+train160_mazda_626 {"horsepower": 74.0, "acceleration": 18.3, "cylinders": 4.0, "displacement": 120.0, "weight": 2635.0}
+train161_buick_lesabre_custom {"horsepower": 155.0, "acceleration": 13.5, "cylinders": 8.0, "displacement": 350.0, "weight": 4502.0}
+train162_chevrolet_monte_carlo {"horsepower": 150.0, "acceleration": 9.5, "cylinders": 8.0, "displacement": 400.0, "weight": 3761.0}
+train163_peugeot_505s_turbo_diesel {"horsepower": 80.0, "acceleration": 20.4, "cylinders": 4.0, "displacement": 141.0, "weight": 3230.0}
+train164_datsun_610 {"horsepower": 94.0, "acceleration": 16.5, "cylinders": 4.0, "displacement": 108.0, "weight": 2379.0}
+train165_ford_granada {"horsepower": 98.0, "acceleration": 19.0, "cylinders": 6.0, "displacement": 250.0, "weight": 3525.0}
+train166_pontiac_grand_prix {"horsepower": 230.0, "acceleration": 9.5, "cylinders": 8.0, "displacement": 400.0, "weight": 4278.0}
+train167_cadillac_seville {"horsepower": 180.0, "acceleration": 12.1, "cylinders": 8.0, "displacement": 350.0, "weight": 4380.0}
+train168_amc_concord {"horsepower": 90.0, "acceleration": 20.1, "cylinders": 4.0, "displacement": 151.0, "weight": 3003.0}
+train169_ford_mustang_gl {"horsepower": 86.0, "acceleration": 15.6, "cylinders": 4.0, "displacement": 140.0, "weight": 2790.0}
+train170_amc_matador {"horsepower": 110.0, "acceleration": 19.0, "cylinders": 6.0, "displacement": 258.0, "weight": 3730.0}
+train171_ford_gran_torino_(sw) {"horsepower": 140.0, "acceleration": 16.0, "cylinders": 8.0, "displacement": 302.0, "weight": 4638.0}
+train172_datsun_510_hatchback {"horsepower": 92.0, "acceleration": 15.0, "cylinders": 4.0, "displacement": 119.0, "weight": 2434.0}
+train173_dodge_rampage {"horsepower": 84.0, "acceleration": 11.6, "cylinders": 4.0, "displacement": 135.0, "weight": 2295.0}
+train174_datsun_b-210 {"horsepower": 70.0, "acceleration": 17.0, "cylinders": 4.0, "displacement": 85.0, "weight": 1990.0}
+train175_datsun_210_mpg {"horsepower": 65.0, "acceleration": 19.4, "cylinders": 4.0, "displacement": 85.0, "weight": 1975.0}
+train176_plymouth_horizon_tc3 {"horsepower": 70.0, "acceleration": 14.9, "cylinders": 4.0, "displacement": 105.0, "weight": 2150.0}
+train177_ford_pinto {"horsepower": 85.0, "acceleration": 18.5, "cylinders": 4.0, "displacement": 122.0, "weight": 2310.0}
+train178_chrysler_new_yorker_brougham {"horsepower": 215.0, "acceleration": 11.0, "cylinders": 8.0, "displacement": 440.0, "weight": 4735.0}
+train179_chrysler_cordoba {"horsepower": 190.0, "acceleration": 12.2, "cylinders": 8.0, "displacement": 400.0, "weight": 4325.0}
+train180_oldsmobile_cutlass_salon_brougham {"horsepower": 110.0, "acceleration": 15.5, "cylinders": 8.0, "displacement": 260.0, "weight": 3365.0}
+train181_plymouth_satellite_custom {"horsepower": 105.0, "acceleration": 15.5, "cylinders": 6.0, "displacement": 225.0, "weight": 3439.0}
+train182_maxda_glc_deluxe {"horsepower": 65.0, "acceleration": 15.2, "cylinders": 4.0, "displacement": 86.0, "weight": 1975.0}
+train183_datsun_1200 {"horsepower": 69.0, "acceleration": 18.0, "cylinders": 4.0, "displacement": 72.0, "weight": 1613.0}
+train184_ford_pinto {"horsepower": 72.0, "acceleration": 13.6, "cylinders": 4.0, "displacement": 140.0, "weight": 2565.0}
+train185_volkswagen_rabbit_l {"horsepower": 74.0, "acceleration": 15.3, "cylinders": 4.0, "displacement": 105.0, "weight": 1980.0}
+train186_audi_100ls {"horsepower": 95.0, "acceleration": 15.0, "cylinders": 4.0, "displacement": 115.0, "weight": 2694.0}
+train187_chevrolet_citation {"horsepower": 115.0, "acceleration": 11.3, "cylinders": 6.0, "displacement": 173.0, "weight": 2595.0}
+train188_buick_electra_225_custom {"horsepower": 225.0, "acceleration": 11.0, "cylinders": 8.0, "displacement": 455.0, "weight": 4951.0}
+train189_datsun_200sx {"horsepower": 100.0, "acceleration": 14.8, "cylinders": 4.0, "displacement": 119.0, "weight": 2615.0}
+train190_dodge_colt_hatchback_custom {"horsepower": 80.0, "acceleration": 14.4, "cylinders": 4.0, "displacement": 98.0, "weight": 1915.0}
+train191_honda_accord_lx {"horsepower": 68.0, "acceleration": 16.6, "cylinders": 4.0, "displacement": 98.0, "weight": 2135.0}
+train192_plymouth_custom_suburb {"horsepower": 170.0, "acceleration": 13.0, "cylinders": 8.0, "displacement": 360.0, "weight": 4654.0}
+train193_toyota_mark_ii {"horsepower": 122.0, "acceleration": 13.5, "cylinders": 6.0, "displacement": 156.0, "weight": 2807.0}
+train194_oldsmobile_omega_brougham {"horsepower": 115.0, "acceleration": 12.9, "cylinders": 6.0, "displacement": 173.0, "weight": 2700.0}
+train195_ford_ltd_landau {"horsepower": 129.0, "acceleration": 13.4, "cylinders": 8.0, "displacement": 302.0, "weight": 3725.0}
+train196_chevy_c10 {"horsepower": 145.0, "acceleration": 12.0, "cylinders": 8.0, "displacement": 350.0, "weight": 4055.0}
+train197_dodge_colt {"horsepower": 75.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 90.0, "weight": 2125.0}
+train198_oldsmobile_cutlass_supreme {"horsepower": 110.0, "acceleration": 19.0, "cylinders": 8.0, "displacement": 260.0, "weight": 4060.0}
+train199_ford_pinto_(sw) {"horsepower": 86.0, "acceleration": 16.0, "cylinders": 4.0, "displacement": 122.0, "weight": 2395.0}
+train200_chevrolet_vega {"horsepower": 75.0, "acceleration": 17.0, "cylinders": 4.0, "displacement": 140.0, "weight": 2542.0}
+train201_pontiac_catalina_brougham {"horsepower": 175.0, "acceleration": 11.5, "cylinders": 8.0, "displacement": 400.0, "weight": 4464.0}
+train202_ford_futura {"horsepower": 139.0, "acceleration": 11.2, "cylinders": 8.0, "displacement": 302.0, "weight": 3205.0}
+train203_honda_civic {"horsepower": 53.0, "acceleration": 17.4, "cylinders": 4.0, "displacement": 91.0, "weight": 1795.0}
+train204_ford_mustang {"horsepower": 88.0, "acceleration": 14.5, "cylinders": 6.0, "displacement": 250.0, "weight": 3139.0}
+train205_chevrolet_vega_(sw) {"horsepower": 72.0, "acceleration": 19.0, "cylinders": 4.0, "displacement": 140.0, "weight": 2408.0}
+train206_buick_century {"horsepower": 110.0, "acceleration": 21.0, "cylinders": 6.0, "displacement": 231.0, "weight": 3907.0}
+train207_dodge_aspen {"horsepower": 90.0, "acceleration": 18.7, "cylinders": 6.0, "displacement": 225.0, "weight": 3381.0}
+train208_subaru_dl {"horsepower": 67.0, "acceleration": 18.0, "cylinders": 4.0, "displacement": 97.0, "weight": 2145.0}
+train209_plymouth_fury_iii {"horsepower": 150.0, "acceleration": 13.5, "cylinders": 8.0, "displacement": 318.0, "weight": 4135.0}
+train210_fiat_128 {"horsepower": 49.0, "acceleration": 19.5, "cylinders": 4.0, "displacement": 68.0, "weight": 1867.0}
+train211_volvo_264gl {"horsepower": 125.0, "acceleration": 13.6, "cylinders": 6.0, "displacement": 163.0, "weight": 3140.0}
+train212_dodge_aries_se {"horsepower": 84.0, "acceleration": 16.0, "cylinders": 4.0, "displacement": 135.0, "weight": 2525.0}
+train213_datsun_510 {"horsepower": 97.0, "acceleration": 14.7, "cylinders": 4.0, "displacement": 119.0, "weight": 2300.0}
+train214_chevrolet_chevelle_malibu_classic {"horsepower": 100.0, "acceleration": 17.0, "cylinders": 6.0, "displacement": 250.0, "weight": 3781.0}
+train215_ford_ranger {"horsepower": 79.0, "acceleration": 18.6, "cylinders": 4.0, "displacement": 120.0, "weight": 2625.0}
+train216_vw_dasher_(diesel) {"horsepower": 48.0, "acceleration": 23.7, "cylinders": 4.0, "displacement": 90.0, "weight": 2335.0}
+train217_chevy_c20 {"horsepower": 200.0, "acceleration": 15.0, "cylinders": 8.0, "displacement": 307.0, "weight": 4376.0}
+train218_buick_skyhawk {"horsepower": 110.0, "acceleration": 15.0, "cylinders": 6.0, "displacement": 231.0, "weight": 3039.0}
+train219_peugeot_504 {"horsepower": 88.0, "acceleration": 17.0, "cylinders": 4.0, "displacement": 120.0, "weight": 2957.0}
+train220_ford_f250 {"horsepower": 215.0, "acceleration": 14.0, "cylinders": 8.0, "displacement": 360.0, "weight": 4615.0}
+train221_dodge_diplomat {"horsepower": 140.0, "acceleration": 13.2, "cylinders": 8.0, "displacement": 318.0, "weight": 3735.0}
+train222_honda_civic_(auto) {"horsepower": 67.0, "acceleration": 15.7, "cylinders": 4.0, "displacement": 91.0, "weight": 1965.0}
+train223_chevrolet_caprice_classic {"horsepower": 130.0, "acceleration": 15.4, "cylinders": 8.0, "displacement": 305.0, "weight": 3840.0}
+train224_toyota_corolla_1200 {"horsepower": 65.0, "acceleration": 21.0, "cylinders": 4.0, "displacement": 71.0, "weight": 1836.0}
+train225_plymouth_volare_premier_v8 {"horsepower": 150.0, "acceleration": 13.2, "cylinders": 8.0, "displacement": 318.0, "weight": 3940.0}
+train226_opel_manta {"horsepower": 78.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 97.0, "weight": 2300.0}
+train227_mercedes_benz_300d {"horsepower": 77.0, "acceleration": 20.1, "cylinders": 5.0, "displacement": 183.0, "weight": 3530.0}
+train228_chevrolet_cavalier_wagon {"horsepower": 88.0, "acceleration": 18.6, "cylinders": 4.0, "displacement": 112.0, "weight": 2640.0}
+train229_vw_rabbit {"horsepower": 70.0, "acceleration": 14.2, "cylinders": 4.0, "displacement": 90.0, "weight": 1937.0}
+train230_toyota_corolla {"horsepower": 75.0, "acceleration": 15.2, "cylinders": 4.0, "displacement": 108.0, "weight": 2265.0}
+train231_buick_estate_wagon_(sw) {"horsepower": 225.0, "acceleration": 10.0, "cylinders": 8.0, "displacement": 455.0, "weight": 3086.0}
+train232_ford_f108 {"horsepower": 130.0, "acceleration": 15.0, "cylinders": 8.0, "displacement": 302.0, "weight": 3870.0}
+train233_oldsmobile_omega {"horsepower": 180.0, "acceleration": 11.0, "cylinders": 8.0, "displacement": 350.0, "weight": 3664.0}
+train234_oldsmobile_cutlass_ciera_(diesel) {"horsepower": 85.0, "acceleration": 17.0, "cylinders": 6.0, "displacement": 262.0, "weight": 3015.0}
+train235_chevrolet_impala {"horsepower": 220.0, "acceleration": 9.0, "cylinders": 8.0, "displacement": 454.0, "weight": 4354.0}
+train236_volkswagen_dasher {"horsepower": 71.0, "acceleration": 16.5, "cylinders": 4.0, "displacement": 90.0, "weight": 2223.0}
+train237_ford_fairmont_futura {"horsepower": 92.0, "acceleration": 16.4, "cylinders": 4.0, "displacement": 140.0, "weight": 2865.0}
+train238_datsun_210 {"horsepower": 65.0, "acceleration": 19.2, "cylinders": 4.0, "displacement": 85.0, "weight": 2020.0}
+train239_honda_accord_cvcc {"horsepower": 68.0, "acceleration": 18.5, "cylinders": 4.0, "displacement": 98.0, "weight": 2045.0}
+train240_mazda_glc {"horsepower": 65.0, "acceleration": 17.9, "cylinders": 4.0, "displacement": 86.0, "weight": 2110.0}
+train241_chevrolet_citation {"horsepower": 90.0, "acceleration": 16.5, "cylinders": 4.0, "displacement": 151.0, "weight": 2678.0}
+train242_datsun_810_maxima {"horsepower": 120.0, "acceleration": 13.8, "cylinders": 6.0, "displacement": 146.0, "weight": 2930.0}
+train243_ford_maverick {"horsepower": 85.0, "acceleration": 16.0, "cylinders": 6.0, "displacement": 200.0, "weight": 2587.0}
+train244_fiat_124_sport_coupe {"horsepower": 90.0, "acceleration": 15.5, "cylinders": 4.0, "displacement": 98.0, "weight": 2265.0}
+train245_chevrolet_vega {"horsepower": 72.0, "acceleration": 19.5, "cylinders": 4.0, "displacement": 140.0, "weight": 2401.0}
+train246_chevrolet_chevelle_malibu_classic {"horsepower": 140.0, "acceleration": 13.0, "cylinders": 8.0, "displacement": 305.0, "weight": 4215.0}
+train247_buick_skylark {"horsepower": 84.0, "acceleration": 16.4, "cylinders": 4.0, "displacement": 151.0, "weight": 2635.0}
+train248_renault_5_gtl {"horsepower": 58.0, "acceleration": 18.6, "cylinders": 4.0, "displacement": 79.0, "weight": 1825.0}
+train249_plymouth_duster {"horsepower": 95.0, "acceleration": 15.5, "cylinders": 6.0, "displacement": 198.0, "weight": 2833.0}
+train250_buick_regal_sport_coupe_(turbo) {"horsepower": 165.0, "acceleration": 13.4, "cylinders": 6.0, "displacement": 231.0, "weight": 3445.0}
+train251_mercury_lynx_l {"horsepower": 70.0, "acceleration": 17.3, "cylinders": 4.0, "displacement": 98.0, "weight": 2125.0}
+train252_dodge_aspen_6 {"horsepower": 110.0, "acceleration": 16.6, "cylinders": 6.0, "displacement": 225.0, "weight": 3360.0}
+train253_oldsmobile_vista_cruiser {"horsepower": 180.0, "acceleration": 12.5, "cylinders": 8.0, "displacement": 350.0, "weight": 4499.0}
+train254_amc_pacer_d/l {"horsepower": 95.0, "acceleration": 17.8, "cylinders": 6.0, "displacement": 258.0, "weight": 3193.0}
+train255_ford_fairmont_4 {"horsepower": 88.0, "acceleration": 17.3, "cylinders": 4.0, "displacement": 140.0, "weight": 2890.0}
+train256_chevrolet_chevelle_concours_(sw) {"horsepower": 130.0, "acceleration": 14.0, "cylinders": 8.0, "displacement": 307.0, "weight": 4098.0}
+train257_honda_accord {"horsepower": 72.0, "acceleration": 17.0, "cylinders": 4.0, "displacement": 107.0, "weight": 2290.0}
+train258_dodge_colt_hardtop {"horsepower": 80.0, "acceleration": 17.0, "cylinders": 4.0, "displacement": 97.5, "weight": 2126.0}
+train259_amc_hornet_sportabout_(sw) {"horsepower": 110.0, "acceleration": 13.5, "cylinders": 6.0, "displacement": 258.0, "weight": 2962.0}
+train260_toyota_corona {"horsepower": 95.0, "acceleration": 14.0, "cylinders": 4.0, "displacement": 113.0, "weight": 2228.0}
+train261_ford_fiesta {"horsepower": 66.0, "acceleration": 14.4, "cylinders": 4.0, "displacement": 98.0, "weight": 1800.0}
+train262_datsun_280-zx {"horsepower": 132.0, "acceleration": 11.4, "cylinders": 6.0, "displacement": 168.0, "weight": 2910.0}
+train263_chevrolet_impala {"horsepower": 165.0, "acceleration": 12.0, "cylinders": 8.0, "displacement": 350.0, "weight": 4274.0}
+train264_toyota_corolla {"horsepower": 75.0, "acceleration": 16.4, "cylinders": 4.0, "displacement": 97.0, "weight": 2155.0}
+train265_chevrolet_chevelle_malibu {"horsepower": 100.0, "acceleration": 15.5, "cylinders": 6.0, "displacement": 250.0, "weight": 3329.0}
+train266_volvo_diesel {"horsepower": 76.0, "acceleration": 19.6, "cylinders": 6.0, "displacement": 145.0, "weight": 3160.0}
+train267_pontiac_phoenix {"horsepower": 90.0, "acceleration": 18.0, "cylinders": 4.0, "displacement": 151.0, "weight": 2735.0}
+train268_dodge_colt_(sw) {"horsepower": 80.0, "acceleration": 15.0, "cylinders": 4.0, "displacement": 98.0, "weight": 2164.0}
+train269_vokswagen_rabbit {"horsepower": 62.0, "acceleration": 15.3, "cylinders": 4.0, "displacement": 89.0, "weight": 1845.0}
+train270_peugeot_504 {"horsepower": 71.0, "acceleration": 24.8, "cylinders": 4.0, "displacement": 141.0, "weight": 3190.0}
+train271_chevrolet_vega_2300 {"horsepower": 90.0, "acceleration": 15.5, "cylinders": 4.0, "displacement": 140.0, "weight": 2264.0}
+train272_ford_fairmont_(auto) {"horsepower": 85.0, "acceleration": 15.8, "cylinders": 6.0, "displacement": 200.0, "weight": 2965.0}
+train273_plymouth_grand_fury {"horsepower": 150.0, "acceleration": 14.5, "cylinders": 8.0, "displacement": 318.0, "weight": 4498.0}
+train274_plymouth_'cuda_340 {"horsepower": 160.0, "acceleration": 8.0, "cylinders": 8.0, "displacement": 340.0, "weight": 3609.0}
+train275_ford_granada_l {"horsepower": 112.0, "acceleration": 14.7, "cylinders": 6.0, "displacement": 232.0, "weight": 2835.0}
+train276_volkswagen_rabbit_custom {"horsepower": 78.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 97.0, "weight": 1940.0}
+train277_honda_civic_cvcc {"horsepower": 53.0, "acceleration": 17.5, "cylinders": 4.0, "displacement": 91.0, "weight": 1795.0}
+train278_chevrolet_nova_custom {"horsepower": 100.0, "acceleration": 18.0, "cylinders": 6.0, "displacement": 250.0, "weight": 3278.0}
+train279_honda_civic_cvcc {"horsepower": 60.0, "acceleration": 16.4, "cylinders": 4.0, "displacement": 91.0, "weight": 1800.0}
+train280_volkswagen_type_3 {"horsepower": 54.0, "acceleration": 23.5, "cylinders": 4.0, "displacement": 97.0, "weight": 2254.0}
+train281_toyota_corolla_tercel {"horsepower": 60.0, "acceleration": 18.8, "cylinders": 4.0, "displacement": 89.0, "weight": 1968.0}
+train282_datsun_pl510 {"horsepower": 88.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 97.0, "weight": 2130.0}
+train283_ford_maverick {"horsepower": 81.0, "acceleration": 17.6, "cylinders": 6.0, "displacement": 200.0, "weight": 3012.0}
+train284_dodge_omni {"horsepower": 75.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 105.0, "weight": 2230.0}
+train285_plymouth_volare_custom {"horsepower": 100.0, "acceleration": 17.7, "cylinders": 6.0, "displacement": 225.0, "weight": 3630.0}
+train286_datsun_710 {"horsepower": 61.0, "acceleration": 19.0, "cylinders": 4.0, "displacement": 83.0, "weight": 2003.0}
+train287_honda_civic_1300 {"horsepower": 60.0, "acceleration": 16.1, "cylinders": 4.0, "displacement": 81.0, "weight": 1760.0}
+train288_saab_99le {"horsepower": 110.0, "acceleration": 14.0, "cylinders": 4.0, "displacement": 121.0, "weight": 2660.0}
+train289_honda_prelude {"horsepower": 75.0, "acceleration": 14.4, "cylinders": 4.0, "displacement": 107.0, "weight": 2210.0}
+train290_buick_skylark_limited {"horsepower": 90.0, "acceleration": 16.0, "cylinders": 4.0, "displacement": 151.0, "weight": 2670.0}
+train291_pontiac_catalina {"horsepower": 225.0, "acceleration": 10.0, "cylinders": 8.0, "displacement": 455.0, "weight": 4425.0}
+train292_mazda_rx-4 {"horsepower": 110.0, "acceleration": 13.5, "cylinders": 3.0, "displacement": 80.0, "weight": 2720.0}
+train293_volkswagen_super_beetle {"horsepower": 46.0, "acceleration": 21.0, "cylinders": 4.0, "displacement": 97.0, "weight": 1950.0}
+train294_ford_fairmont_(man) {"horsepower": 88.0, "acceleration": 15.4, "cylinders": 4.0, "displacement": 140.0, "weight": 2720.0}
+train295_fiat_131 {"horsepower": 86.0, "acceleration": 15.5, "cylinders": 4.0, "displacement": 107.0, "weight": 2464.0}
+train296_ford_escort_4w {"horsepower": 65.0, "acceleration": 16.2, "cylinders": 4.0, "displacement": 98.0, "weight": 2045.0}
+train297_plymouth_horizon_miser {"horsepower": 63.0, "acceleration": 14.7, "cylinders": 4.0, "displacement": 105.0, "weight": 2125.0}
+train298_ford_mustang_ii {"horsepower": 129.0, "acceleration": 12.0, "cylinders": 8.0, "displacement": 302.0, "weight": 3169.0}
+train299_saab_99e {"horsepower": 95.0, "acceleration": 17.5, "cylinders": 4.0, "displacement": 104.0, "weight": 2375.0}
+train300_fiat_124b {"horsepower": 76.0, "acceleration": 14.5, "cylinders": 4.0, "displacement": 88.0, "weight": 2065.0}
diff --git a/creg/test_data/auto-mpg.trainresp b/creg/test_data/auto-mpg.trainresp
new file mode 100644
index 00000000..ece7fa37
--- /dev/null
+++ b/creg/test_data/auto-mpg.trainresp
@@ -0,0 +1,300 @@
+train1_buick_century_350 13.0
+train2_audi_100_ls 24.0
+train3_chrysler_newport_royal 13.0
+train4_mercury_zephyr_6 19.8
+train5_volkswagen_model_111 27.0
+train6_dodge_monaco_brougham 15.5
+train7_mercedes-benz_240d 30.0
+train8_datsun_510_(sw) 28.0
+train9_opel_manta 24.0
+train10_renault_12_(sw) 26.0
+train11_chevrolet_nova 15.0
+train12_plymouth_arrow_gs 25.5
+train13_toyota_mark_ii 19.0
+train14_chevrolet_caprice_classic 13.0
+train15_ford_maverick 18.0
+train16_pontiac_lemans_v6 21.5
+train17_ford_granada_gl 20.2
+train18_chevrolet_monte_carlo_landau 15.5
+train19_subaru 26.0
+train20_volkswagen_411_(sw) 22.0
+train21_chrysler_lebaron_salon 17.6
+train22_volkswagen_jetta 33.0
+train23_dodge_coronet_brougham 16.0
+train24_pontiac_safari_(sw) 13.0
+train25_mazda_rx-7_gs 23.7
+train26_datsun_210 40.8
+train27_vw_rabbit_c_(diesel) 44.3
+train28_nissan_stanza_xe 36.0
+train29_audi_5000 20.3
+train30_chevrolet_malibu 13.0
+train31_mercury_capri_v6 21.0
+train32_datsun_b210_gx 39.4
+train33_volkswagen_dasher 26.0
+train34_volvo_145e_(sw) 18.0
+train35_chrysler_lebaron_medallion 26.0
+train36_pontiac_catalina 16.0
+train37_toyota_tercel 37.7
+train38_datsun_f-10_hatchback 33.5
+train39_chrysler_lebaron_town_@_country_(sw) 18.5
+train40_buick_century 22.4
+train41_amc_matador_(sw) 15.0
+train42_honda_civic 38.0
+train43_dodge_coronet_custom_(sw) 14.0
+train44_bmw_320i 21.5
+train45_mercury_marquis 11.0
+train46_amc_matador_(sw) 14.0
+train47_ford_ltd 13.0
+train48_toyota_corolla_1200 31.0
+train49_amc_ambassador_brougham 13.0
+train50_ford_galaxie_500 14.0
+train51_amc_concord_d/l 18.1
+train52_amc_matador 18.0
+train53_toyota_corona 24.0
+train54_plymouth_reliant 27.2
+train55_ford_pinto 18.0
+train56_datsun_810 22.0
+train57_fiat_x1.9 31.0
+train58_mercury_zephyr 20.8
+train59_toyota_corolla_1600_(sw) 27.0
+train60_chevrolet_chevette 30.0
+train61_toyota_cressida 25.4
+train62_toyota_corolla 34.0
+train63_datsun_710 24.0
+train64_mercury_grand_marquis 16.5
+train65_plymouth_champ 39.0
+train66_datsun_200-sx 23.9
+train67_chevrolet_nova 18.0
+train68_hi_1200d 9.0
+train69_ford_country 12.0
+train70_plymouth_valiant 22.0
+train71_amc_gremlin 20.0
+train72_ford_pinto_runabout 21.0
+train73_chevrolet_monte_carlo_landau 19.2
+train74_amc_concord_dl_6 20.2
+train75_pontiac_firebird 19.0
+train76_chevrolet_cavalier_2-door 34.0
+train77_mercedes-benz_280s 16.5
+train78_dodge_d200 11.0
+train79_amc_hornet 18.0
+train80_plymouth_reliant 30.0
+train81_amc_hornet 19.0
+train82_toyota_corona_liftback 29.8
+train83_ford_maverick 15.0
+train84_cadillac_eldorado 23.0
+train85_mercury_monarch 15.0
+train86_buick_skylark 20.5
+train87_chevrolet_cavalier 28.0
+train88_chevrolet_vega 20.0
+train89_ford_torino 17.0
+train90_chevrolet_chevelle_malibu 18.0
+train91_toyota_corona 31.0
+train92_buick_opel_isuzu_deluxe 30.0
+train93_volvo_244dl 22.0
+train94_opel_1900 25.0
+train95_peugeot_304 30.0
+train96_toyota_celica_gt 32.0
+train97_buick_estate_wagon_(sw) 16.9
+train98_volvo_245 20.0
+train99_chevrolet_impala 11.0
+train100_chevrolet_bel_air 15.0
+train101_datsun_pl510 27.0
+train102_saab_99gle 21.6
+train103_renault_12tl 27.0
+train104_pontiac_catalina 14.0
+train105_subaru 32.3
+train106_chevrolet_chevette 32.1
+train107_saab_99le 25.0
+train108_amc_rebel_sst 16.0
+train109_ford_gran_torino 16.0
+train110_ford_mustang_ii_2+2 25.5
+train111_ford_pinto 26.0
+train112_toyota_corolla 32.4
+train113_toyota_carina 20.0
+train114_amc_hornet 18.0
+train115_plymouth_horizon_4 34.7
+train116_chevrolet_nova 22.0
+train117_fiat_128 24.0
+train118_dodge_coronet_custom 15.0
+train119_volkswagen_rabbit 29.5
+train120_chevrolet_camaro 27.0
+train121_ford_gran_torino_(sw) 13.0
+train122_subaru_dl 30.0
+train123_mazda_626 31.3
+train124_oldsmobile_cutlass_salon_brougham 23.9
+train125_volvo_144ea 19.0
+train126_plymouth_satellite 18.0
+train127_amc_gremlin 18.0
+train128_chevrolet_malibu_classic_(sw) 19.2
+train129_toyota_corolla 29.0
+train130_buick_skylark_320 15.0
+train131_toyota_corona_mark_ii 24.0
+train132_ford_gran_torino 14.5
+train133_dodge_colt 26.0
+train134_pontiac_ventura_sj 18.5
+train135_oldsmobile_cutlass_ls 26.6
+train136_toyouta_corona_mark_ii_(sw) 23.0
+train137_amc_gremlin 19.0
+train138_chevrolet_malibu 20.5
+train139_oldsmobile_starfire_sx 23.8
+train140_amc_ambassador_dpl 15.0
+train141_volkswagen_scirocco 31.5
+train142_plymouth_satellite_custom_(sw) 14.0
+train143_toyota_corolla_liftback 26.0
+train144_ford_fairmont 26.4
+train145_plymouth_fury_gran_sedan 14.0
+train146_buick_century_luxus_(sw) 13.0
+train147_ford_granada_ghia 18.0
+train148_dodge_charger_2.2 36.0
+train149_chevrolet_concours 17.5
+train150_toyota_corona 27.5
+train151_pontiac_grand_prix_lj 16.0
+train152_dodge_colt_m/m 33.5
+train153_pontiac_astro 23.0
+train154_amc_gremlin 21.0
+train155_fiat_strada_custom 37.3
+train156_toyota_corona_hardtop 24.0
+train157_datsun_b210 31.0
+train158_volkswagen_dasher 30.5
+train159_plymouth_duster 23.0
+train160_mazda_626 31.6
+train161_buick_lesabre_custom 13.0
+train162_chevrolet_monte_carlo 15.0
+train163_peugeot_505s_turbo_diesel 28.1
+train164_datsun_610 22.0
+train165_ford_granada 18.5
+train166_pontiac_grand_prix 16.0
+train167_cadillac_seville 16.5
+train168_amc_concord 24.3
+train169_ford_mustang_gl 27.0
+train170_amc_matador 15.0
+train171_ford_gran_torino_(sw) 14.0
+train172_datsun_510_hatchback 37.0
+train173_dodge_rampage 32.0
+train174_datsun_b-210 32.0
+train175_datsun_210_mpg 37.0
+train176_plymouth_horizon_tc3 34.5
+train177_ford_pinto 19.0
+train178_chrysler_new_yorker_brougham 13.0
+train179_chrysler_cordoba 15.5
+train180_oldsmobile_cutlass_salon_brougham 19.9
+train181_plymouth_satellite_custom 16.0
+train182_maxda_glc_deluxe 34.1
+train183_datsun_1200 35.0
+train184_ford_pinto 26.5
+train185_volkswagen_rabbit_l 36.0
+train186_audi_100ls 23.0
+train187_chevrolet_citation 28.8
+train188_buick_electra_225_custom 12.0
+train189_datsun_200sx 32.9
+train190_dodge_colt_hatchback_custom 35.7
+train191_honda_accord_lx 29.5
+train192_plymouth_custom_suburb 13.0
+train193_toyota_mark_ii 20.0
+train194_oldsmobile_omega_brougham 26.8
+train195_ford_ltd_landau 17.6
+train196_chevy_c10 13.0
+train197_dodge_colt 28.0
+train198_oldsmobile_cutlass_supreme 17.0
+train199_ford_pinto_(sw) 22.0
+train200_chevrolet_vega 25.0
+train201_pontiac_catalina_brougham 14.0
+train202_ford_futura 18.1
+train203_honda_civic 33.0
+train204_ford_mustang 18.0
+train205_chevrolet_vega_(sw) 22.0
+train206_buick_century 17.0
+train207_dodge_aspen 19.1
+train208_subaru_dl 33.8
+train209_plymouth_fury_iii 15.0
+train210_fiat_128 29.0
+train211_volvo_264gl 17.0
+train212_dodge_aries_se 29.0
+train213_datsun_510 27.2
+train214_chevrolet_chevelle_malibu_classic 16.0
+train215_ford_ranger 28.0
+train216_vw_dasher_(diesel) 43.4
+train217_chevy_c20 10.0
+train218_buick_skyhawk 21.0
+train219_peugeot_504 23.0
+train220_ford_f250 10.0
+train221_dodge_diplomat 19.4
+train222_honda_civic_(auto) 32.0
+train223_chevrolet_caprice_classic 17.0
+train224_toyota_corolla_1200 32.0
+train225_plymouth_volare_premier_v8 13.0
+train226_opel_manta 26.0
+train227_mercedes_benz_300d 25.4
+train228_chevrolet_cavalier_wagon 27.0
+train229_vw_rabbit 29.0
+train230_toyota_corolla 32.2
+train231_buick_estate_wagon_(sw) 14.0
+train232_ford_f108 13.0
+train233_oldsmobile_omega 11.0
+train234_oldsmobile_cutlass_ciera_(diesel) 38.0
+train235_chevrolet_impala 14.0
+train236_volkswagen_dasher 25.0
+train237_ford_fairmont_futura 24.0
+train238_datsun_210 31.8
+train239_honda_accord_cvcc 31.5
+train240_mazda_glc 46.6
+train241_chevrolet_citation 28.0
+train242_datsun_810_maxima 24.2
+train243_ford_maverick 21.0
+train244_fiat_124_sport_coupe 26.0
+train245_chevrolet_vega 21.0
+train246_chevrolet_chevelle_malibu_classic 17.5
+train247_buick_skylark 26.6
+train248_renault_5_gtl 36.0
+train249_plymouth_duster 22.0
+train250_buick_regal_sport_coupe_(turbo) 17.7
+train251_mercury_lynx_l 36.0
+train252_dodge_aspen_6 20.6
+train253_oldsmobile_vista_cruiser 12.0
+train254_amc_pacer_d/l 17.5
+train255_ford_fairmont_4 22.3
+train256_chevrolet_chevelle_concours_(sw) 13.0
+train257_honda_accord 32.4
+train258_dodge_colt_hardtop 25.0
+train259_amc_hornet_sportabout_(sw) 18.0
+train260_toyota_corona 25.0
+train261_ford_fiesta 36.1
+train262_datsun_280-zx 32.7
+train263_chevrolet_impala 13.0
+train264_toyota_corolla 28.0
+train265_chevrolet_chevelle_malibu 17.0
+train266_volvo_diesel 30.7
+train267_pontiac_phoenix 27.0
+train268_dodge_colt_(sw) 28.0
+train269_vokswagen_rabbit 29.8
+train270_peugeot_504 27.2
+train271_chevrolet_vega_2300 28.0
+train272_ford_fairmont_(auto) 20.2
+train273_plymouth_grand_fury 16.0
+train274_plymouth_'cuda_340 14.0
+train275_ford_granada_l 22.0
+train276_volkswagen_rabbit_custom 29.0
+train277_honda_civic_cvcc 33.0
+train278_chevrolet_nova_custom 16.0
+train279_honda_civic_cvcc 36.1
+train280_volkswagen_type_3 23.0
+train281_toyota_corolla_tercel 38.1
+train282_datsun_pl510 27.0
+train283_ford_maverick 24.0
+train284_dodge_omni 30.9
+train285_plymouth_volare_custom 19.0
+train286_datsun_710 32.0
+train287_honda_civic_1300 35.1
+train288_saab_99le 24.0
+train289_honda_prelude 33.7
+train290_buick_skylark_limited 28.4
+train291_pontiac_catalina 14.0
+train292_mazda_rx-4 21.5
+train293_volkswagen_super_beetle 26.0
+train294_ford_fairmont_(man) 25.1
+train295_fiat_131 28.0
+train296_ford_escort_4w 34.4
+train297_plymouth_horizon_miser 38.0
+train298_ford_mustang_ii 13.0
+train299_saab_99e 25.0
+train300_fiat_124b 30.0
diff --git a/creg/test_data/iris.testfeat b/creg/test_data/iris.testfeat
new file mode 100644
index 00000000..f7528f81
--- /dev/null
+++ b/creg/test_data/iris.testfeat
@@ -0,0 +1,50 @@
+100 {"sepal-length": 4.9, "sepal-width": 2.5, "petal-length": 4.5, "petal-width": 1.7}
+101 {"sepal-length": 6.5, "sepal-width": 3.0, "petal-length": 5.2, "petal-width": 2.0}
+102 {"sepal-length": 4.4, "sepal-width": 3.0, "petal-length": 1.3, "petal-width": 0.2}
+103 {"sepal-length": 5.0, "sepal-width": 3.4, "petal-length": 1.5, "petal-width": 0.2}
+104 {"sepal-length": 5.0, "sepal-width": 3.0, "petal-length": 1.6, "petal-width": 0.2}
+105 {"sepal-length": 5.1, "sepal-width": 3.4, "petal-length": 1.5, "petal-width": 0.2}
+106 {"sepal-length": 5.5, "sepal-width": 2.3, "petal-length": 4.0, "petal-width": 1.3}
+107 {"sepal-length": 5.5, "sepal-width": 2.6, "petal-length": 4.4, "petal-width": 1.2}
+108 {"sepal-length": 5.4, "sepal-width": 3.4, "petal-length": 1.7, "petal-width": 0.2}
+109 {"sepal-length": 5.5, "sepal-width": 2.4, "petal-length": 3.7, "petal-width": 1.0}
+110 {"sepal-length": 6.7, "sepal-width": 3.0, "petal-length": 5.0, "petal-width": 1.7}
+111 {"sepal-length": 6.4, "sepal-width": 2.8, "petal-length": 5.6, "petal-width": 2.2}
+112 {"sepal-length": 5.5, "sepal-width": 4.2, "petal-length": 1.4, "petal-width": 0.2}
+113 {"sepal-length": 5.9, "sepal-width": 3.0, "petal-length": 4.2, "petal-width": 1.5}
+114 {"sepal-length": 4.9, "sepal-width": 3.1, "petal-length": 1.5, "petal-width": 0.1}
+115 {"sepal-length": 7.7, "sepal-width": 2.6, "petal-length": 6.9, "petal-width": 2.3}
+116 {"sepal-length": 5.0, "sepal-width": 3.6, "petal-length": 1.4, "petal-width": 0.2}
+117 {"sepal-length": 6.3, "sepal-width": 2.3, "petal-length": 4.4, "petal-width": 1.3}
+118 {"sepal-length": 6.7, "sepal-width": 3.3, "petal-length": 5.7, "petal-width": 2.1}
+119 {"sepal-length": 5.8, "sepal-width": 2.7, "petal-length": 5.1, "petal-width": 1.9}
+120 {"sepal-length": 5.2, "sepal-width": 2.7, "petal-length": 3.9, "petal-width": 1.4}
+121 {"sepal-length": 5.0, "sepal-width": 3.5, "petal-length": 1.6, "petal-width": 0.6}
+122 {"sepal-length": 5.0, "sepal-width": 3.2, "petal-length": 1.2, "petal-width": 0.2}
+123 {"sepal-length": 6.7, "sepal-width": 3.0, "petal-length": 5.2, "petal-width": 2.3}
+124 {"sepal-length": 5.5, "sepal-width": 2.5, "petal-length": 4.0, "petal-width": 1.3}
+125 {"sepal-length": 5.6, "sepal-width": 3.0, "petal-length": 4.5, "petal-width": 1.5}
+126 {"sepal-length": 6.6, "sepal-width": 3.0, "petal-length": 4.4, "petal-width": 1.4}
+127 {"sepal-length": 5.1, "sepal-width": 3.8, "petal-length": 1.6, "petal-width": 0.2}
+128 {"sepal-length": 5.9, "sepal-width": 3.0, "petal-length": 5.1, "petal-width": 1.8}
+129 {"sepal-length": 6.2, "sepal-width": 3.4, "petal-length": 5.4, "petal-width": 2.3}
+130 {"sepal-length": 5.6, "sepal-width": 2.8, "petal-length": 4.9, "petal-width": 2.0}
+131 {"sepal-length": 5.7, "sepal-width": 2.9, "petal-length": 4.2, "petal-width": 1.3}
+132 {"sepal-length": 6.2, "sepal-width": 2.9, "petal-length": 4.3, "petal-width": 1.3}
+133 {"sepal-length": 6.0, "sepal-width": 3.4, "petal-length": 4.5, "petal-width": 1.6}
+134 {"sepal-length": 5.4, "sepal-width": 3.9, "petal-length": 1.7, "petal-width": 0.4}
+135 {"sepal-length": 6.3, "sepal-width": 3.3, "petal-length": 6.0, "petal-width": 2.5}
+136 {"sepal-length": 6.5, "sepal-width": 3.2, "petal-length": 5.1, "petal-width": 2.0}
+137 {"sepal-length": 5.1, "sepal-width": 2.5, "petal-length": 3.0, "petal-width": 1.1}
+138 {"sepal-length": 4.3, "sepal-width": 3.0, "petal-length": 1.1, "petal-width": 0.1}
+139 {"sepal-length": 5.7, "sepal-width": 2.5, "petal-length": 5.0, "petal-width": 2.0}
+140 {"sepal-length": 6.0, "sepal-width": 2.2, "petal-length": 5.0, "petal-width": 1.5}
+141 {"sepal-length": 6.4, "sepal-width": 3.2, "petal-length": 5.3, "petal-width": 2.3}
+142 {"sepal-length": 6.5, "sepal-width": 2.8, "petal-length": 4.6, "petal-width": 1.5}
+143 {"sepal-length": 5.5, "sepal-width": 3.5, "petal-length": 1.3, "petal-width": 0.2}
+144 {"sepal-length": 4.7, "sepal-width": 3.2, "petal-length": 1.3, "petal-width": 0.2}
+145 {"sepal-length": 4.6, "sepal-width": 3.4, "petal-length": 1.4, "petal-width": 0.3}
+146 {"sepal-length": 5.7, "sepal-width": 2.6, "petal-length": 3.5, "petal-width": 1.0}
+147 {"sepal-length": 5.8, "sepal-width": 2.8, "petal-length": 5.1, "petal-width": 2.4}
+148 {"sepal-length": 7.7, "sepal-width": 2.8, "petal-length": 6.7, "petal-width": 2.0}
+149 {"sepal-length": 6.3, "sepal-width": 2.9, "petal-length": 5.6, "petal-width": 1.8}
diff --git a/creg/test_data/iris.testresp b/creg/test_data/iris.testresp
new file mode 100644
index 00000000..0952e4da
--- /dev/null
+++ b/creg/test_data/iris.testresp
@@ -0,0 +1,50 @@
+100 Iris-virginica
+101 Iris-virginica
+102 Iris-setosa
+103 Iris-setosa
+104 Iris-setosa
+105 Iris-setosa
+106 Iris-versicolor
+107 Iris-versicolor
+108 Iris-setosa
+109 Iris-versicolor
+110 Iris-versicolor
+111 Iris-virginica
+112 Iris-setosa
+113 Iris-versicolor
+114 Iris-setosa
+115 Iris-virginica
+116 Iris-setosa
+117 Iris-versicolor
+118 Iris-virginica
+119 Iris-virginica
+120 Iris-versicolor
+121 Iris-setosa
+122 Iris-setosa
+123 Iris-virginica
+124 Iris-versicolor
+125 Iris-versicolor
+126 Iris-versicolor
+127 Iris-setosa
+128 Iris-virginica
+129 Iris-virginica
+130 Iris-virginica
+131 Iris-versicolor
+132 Iris-versicolor
+133 Iris-versicolor
+134 Iris-setosa
+135 Iris-virginica
+136 Iris-virginica
+137 Iris-versicolor
+138 Iris-setosa
+139 Iris-virginica
+140 Iris-virginica
+141 Iris-virginica
+142 Iris-versicolor
+143 Iris-setosa
+144 Iris-setosa
+145 Iris-setosa
+146 Iris-versicolor
+147 Iris-virginica
+148 Iris-virginica
+149 Iris-virginica
diff --git a/creg/test_data/iris.trainfeat b/creg/test_data/iris.trainfeat
new file mode 100644
index 00000000..a930a446
--- /dev/null
+++ b/creg/test_data/iris.trainfeat
@@ -0,0 +1,100 @@
+0 {"sepal-length": 5.4, "sepal-width": 3.0, "petal-length": 4.5, "petal-width": 1.5}
+1 {"sepal-length": 5.0, "sepal-width": 3.4, "petal-length": 1.6, "petal-width": 0.4}
+2 {"sepal-length": 5.0, "sepal-width": 3.3, "petal-length": 1.4, "petal-width": 0.2}
+3 {"sepal-length": 5.7, "sepal-width": 2.8, "petal-length": 4.5, "petal-width": 1.3}
+4 {"sepal-length": 6.4, "sepal-width": 3.1, "petal-length": 5.5, "petal-width": 1.8}
+5 {"sepal-length": 7.9, "sepal-width": 3.8, "petal-length": 6.4, "petal-width": 2.0}
+6 {"sepal-length": 5.9, "sepal-width": 3.2, "petal-length": 4.8, "petal-width": 1.8}
+7 {"sepal-length": 6.7, "sepal-width": 2.5, "petal-length": 5.8, "petal-width": 1.8}
+8 {"sepal-length": 6.7, "sepal-width": 3.1, "petal-length": 4.4, "petal-width": 1.4}
+9 {"sepal-length": 6.3, "sepal-width": 2.5, "petal-length": 4.9, "petal-width": 1.5}
+10 {"sepal-length": 6.1, "sepal-width": 2.9, "petal-length": 4.7, "petal-width": 1.4}
+11 {"sepal-length": 6.3, "sepal-width": 3.3, "petal-length": 4.7, "petal-width": 1.6}
+12 {"sepal-length": 6.7, "sepal-width": 3.1, "petal-length": 4.7, "petal-width": 1.5}
+13 {"sepal-length": 6.2, "sepal-width": 2.8, "petal-length": 4.8, "petal-width": 1.8}
+14 {"sepal-length": 5.0, "sepal-width": 3.5, "petal-length": 1.3, "petal-width": 0.3}
+15 {"sepal-length": 5.4, "sepal-width": 3.9, "petal-length": 1.3, "petal-width": 0.4}
+16 {"sepal-length": 7.4, "sepal-width": 2.8, "petal-length": 6.1, "petal-width": 1.9}
+17 {"sepal-length": 7.2, "sepal-width": 3.2, "petal-length": 6.0, "petal-width": 1.8}
+18 {"sepal-length": 5.7, "sepal-width": 3.8, "petal-length": 1.7, "petal-width": 0.3}
+19 {"sepal-length": 4.5, "sepal-width": 2.3, "petal-length": 1.3, "petal-width": 0.3}
+20 {"sepal-length": 5.6, "sepal-width": 3.0, "petal-length": 4.1, "petal-width": 1.3}
+21 {"sepal-length": 6.8, "sepal-width": 3.0, "petal-length": 5.5, "petal-width": 2.1}
+22 {"sepal-length": 6.5, "sepal-width": 3.0, "petal-length": 5.8, "petal-width": 2.2}
+23 {"sepal-length": 4.4, "sepal-width": 3.2, "petal-length": 1.3, "petal-width": 0.2}
+24 {"sepal-length": 6.3, "sepal-width": 2.5, "petal-length": 5.0, "petal-width": 1.9}
+25 {"sepal-length": 4.4, "sepal-width": 2.9, "petal-length": 1.4, "petal-width": 0.2}
+26 {"sepal-length": 4.9, "sepal-width": 3.0, "petal-length": 1.4, "petal-width": 0.2}
+27 {"sepal-length": 5.4, "sepal-width": 3.4, "petal-length": 1.5, "petal-width": 0.4}
+28 {"sepal-length": 5.8, "sepal-width": 2.7, "petal-length": 3.9, "petal-width": 1.2}
+29 {"sepal-length": 5.6, "sepal-width": 2.5, "petal-length": 3.9, "petal-width": 1.1}
+30 {"sepal-length": 5.1, "sepal-width": 3.5, "petal-length": 1.4, "petal-width": 0.3}
+31 {"sepal-length": 5.6, "sepal-width": 2.7, "petal-length": 4.2, "petal-width": 1.3}
+32 {"sepal-length": 5.1, "sepal-width": 3.5, "petal-length": 1.4, "petal-width": 0.2}
+33 {"sepal-length": 6.4, "sepal-width": 2.7, "petal-length": 5.3, "petal-width": 1.9}
+34 {"sepal-length": 5.8, "sepal-width": 4.0, "petal-length": 1.2, "petal-width": 0.2}
+35 {"sepal-length": 5.2, "sepal-width": 3.4, "petal-length": 1.4, "petal-width": 0.2}
+36 {"sepal-length": 7.6, "sepal-width": 3.0, "petal-length": 6.6, "petal-width": 2.1}
+37 {"sepal-length": 5.8, "sepal-width": 2.7, "petal-length": 5.1, "petal-width": 1.9}
+38 {"sepal-length": 6.0, "sepal-width": 2.2, "petal-length": 4.0, "petal-width": 1.0}
+39 {"sepal-length": 7.7, "sepal-width": 3.0, "petal-length": 6.1, "petal-width": 2.3}
+40 {"sepal-length": 5.1, "sepal-width": 3.7, "petal-length": 1.5, "petal-width": 0.4}
+41 {"sepal-length": 6.1, "sepal-width": 2.6, "petal-length": 5.6, "petal-width": 1.4}
+42 {"sepal-length": 6.7, "sepal-width": 3.1, "petal-length": 5.6, "petal-width": 2.4}
+43 {"sepal-length": 7.7, "sepal-width": 3.8, "petal-length": 6.7, "petal-width": 2.2}
+44 {"sepal-length": 5.1, "sepal-width": 3.3, "petal-length": 1.7, "petal-width": 0.5}
+45 {"sepal-length": 6.3, "sepal-width": 2.8, "petal-length": 5.1, "petal-width": 1.5}
+46 {"sepal-length": 5.0, "sepal-width": 2.0, "petal-length": 3.5, "petal-width": 1.0}
+47 {"sepal-length": 5.1, "sepal-width": 3.8, "petal-length": 1.5, "petal-width": 0.3}
+48 {"sepal-length": 4.9, "sepal-width": 3.1, "petal-length": 1.5, "petal-width": 0.1}
+49 {"sepal-length": 6.1, "sepal-width": 3.0, "petal-length": 4.9, "petal-width": 1.8}
+50 {"sepal-length": 6.4, "sepal-width": 2.8, "petal-length": 5.6, "petal-width": 2.1}
+51 {"sepal-length": 6.5, "sepal-width": 3.0, "petal-length": 5.5, "petal-width": 1.8}
+52 {"sepal-length": 6.1, "sepal-width": 2.8, "petal-length": 4.7, "petal-width": 1.2}
+53 {"sepal-length": 6.1, "sepal-width": 2.8, "petal-length": 4.0, "petal-width": 1.3}
+54 {"sepal-length": 4.9, "sepal-width": 3.1, "petal-length": 1.5, "petal-width": 0.1}
+55 {"sepal-length": 6.8, "sepal-width": 2.8, "petal-length": 4.8, "petal-width": 1.4}
+56 {"sepal-length": 6.3, "sepal-width": 2.7, "petal-length": 4.9, "petal-width": 1.8}
+57 {"sepal-length": 4.6, "sepal-width": 3.2, "petal-length": 1.4, "petal-width": 0.2}
+58 {"sepal-length": 6.3, "sepal-width": 3.4, "petal-length": 5.6, "petal-width": 2.4}
+59 {"sepal-length": 5.7, "sepal-width": 4.4, "petal-length": 1.5, "petal-width": 0.4}
+60 {"sepal-length": 6.4, "sepal-width": 2.9, "petal-length": 4.3, "petal-width": 1.3}
+61 {"sepal-length": 7.2, "sepal-width": 3.6, "petal-length": 6.1, "petal-width": 2.5}
+62 {"sepal-length": 5.8, "sepal-width": 2.7, "petal-length": 4.1, "petal-width": 1.0}
+63 {"sepal-length": 6.0, "sepal-width": 3.0, "petal-length": 4.8, "petal-width": 1.8}
+64 {"sepal-length": 4.7, "sepal-width": 3.2, "petal-length": 1.6, "petal-width": 0.2}
+65 {"sepal-length": 6.9, "sepal-width": 3.2, "petal-length": 5.7, "petal-width": 2.3}
+66 {"sepal-length": 6.4, "sepal-width": 3.2, "petal-length": 4.5, "petal-width": 1.5}
+67 {"sepal-length": 6.9, "sepal-width": 3.1, "petal-length": 5.4, "petal-width": 2.1}
+68 {"sepal-length": 5.2, "sepal-width": 3.5, "petal-length": 1.5, "petal-width": 0.2}
+69 {"sepal-length": 5.3, "sepal-width": 3.7, "petal-length": 1.5, "petal-width": 0.2}
+70 {"sepal-length": 5.5, "sepal-width": 2.4, "petal-length": 3.8, "petal-width": 1.1}
+71 {"sepal-length": 4.8, "sepal-width": 3.4, "petal-length": 1.9, "petal-width": 0.2}
+72 {"sepal-length": 5.7, "sepal-width": 2.8, "petal-length": 4.1, "petal-width": 1.3}
+73 {"sepal-length": 4.9, "sepal-width": 2.4, "petal-length": 3.3, "petal-width": 1.0}
+74 {"sepal-length": 6.2, "sepal-width": 2.2, "petal-length": 4.5, "petal-width": 1.5}
+75 {"sepal-length": 6.7, "sepal-width": 3.3, "petal-length": 5.7, "petal-width": 2.5}
+76 {"sepal-length": 6.1, "sepal-width": 3.0, "petal-length": 4.6, "petal-width": 1.4}
+77 {"sepal-length": 4.6, "sepal-width": 3.6, "petal-length": 1.0, "petal-width": 0.2}
+78 {"sepal-length": 7.0, "sepal-width": 3.2, "petal-length": 4.7, "petal-width": 1.4}
+79 {"sepal-length": 6.6, "sepal-width": 2.9, "petal-length": 4.6, "petal-width": 1.3}
+80 {"sepal-length": 5.4, "sepal-width": 3.7, "petal-length": 1.5, "petal-width": 0.2}
+81 {"sepal-length": 4.8, "sepal-width": 3.0, "petal-length": 1.4, "petal-width": 0.3}
+82 {"sepal-length": 7.2, "sepal-width": 3.0, "petal-length": 5.8, "petal-width": 1.6}
+83 {"sepal-length": 7.1, "sepal-width": 3.0, "petal-length": 5.9, "petal-width": 2.1}
+84 {"sepal-length": 6.9, "sepal-width": 3.1, "petal-length": 4.9, "petal-width": 1.5}
+85 {"sepal-length": 4.8, "sepal-width": 3.0, "petal-length": 1.4, "petal-width": 0.1}
+86 {"sepal-length": 7.3, "sepal-width": 2.9, "petal-length": 6.3, "petal-width": 1.8}
+87 {"sepal-length": 6.0, "sepal-width": 2.7, "petal-length": 5.1, "petal-width": 1.6}
+88 {"sepal-length": 6.8, "sepal-width": 3.2, "petal-length": 5.9, "petal-width": 2.3}
+89 {"sepal-length": 4.6, "sepal-width": 3.1, "petal-length": 1.5, "petal-width": 0.2}
+90 {"sepal-length": 4.8, "sepal-width": 3.1, "petal-length": 1.6, "petal-width": 0.2}
+91 {"sepal-length": 5.0, "sepal-width": 2.3, "petal-length": 3.3, "petal-width": 1.0}
+92 {"sepal-length": 6.9, "sepal-width": 3.1, "petal-length": 5.1, "petal-width": 2.3}
+93 {"sepal-length": 5.7, "sepal-width": 3.0, "petal-length": 4.2, "petal-width": 1.2}
+94 {"sepal-length": 5.1, "sepal-width": 3.8, "petal-length": 1.9, "petal-width": 0.4}
+95 {"sepal-length": 6.0, "sepal-width": 2.9, "petal-length": 4.5, "petal-width": 1.5}
+96 {"sepal-length": 4.8, "sepal-width": 3.4, "petal-length": 1.6, "petal-width": 0.2}
+97 {"sepal-length": 5.2, "sepal-width": 4.1, "petal-length": 1.5, "petal-width": 0.1}
+98 {"sepal-length": 5.6, "sepal-width": 2.9, "petal-length": 3.6, "petal-width": 1.3}
+99 {"sepal-length": 5.8, "sepal-width": 2.6, "petal-length": 4.0, "petal-width": 1.2}
diff --git a/creg/test_data/iris.trainresp b/creg/test_data/iris.trainresp
new file mode 100644
index 00000000..d77bc6a2
--- /dev/null
+++ b/creg/test_data/iris.trainresp
@@ -0,0 +1,100 @@
+0 Iris-versicolor
+1 Iris-setosa
+2 Iris-setosa
+3 Iris-versicolor
+4 Iris-virginica
+5 Iris-virginica
+6 Iris-versicolor
+7 Iris-virginica
+8 Iris-versicolor
+9 Iris-versicolor
+10 Iris-versicolor
+11 Iris-versicolor
+12 Iris-versicolor
+13 Iris-virginica
+14 Iris-setosa
+15 Iris-setosa
+16 Iris-virginica
+17 Iris-virginica
+18 Iris-setosa
+19 Iris-setosa
+20 Iris-versicolor
+21 Iris-virginica
+22 Iris-virginica
+23 Iris-setosa
+24 Iris-virginica
+25 Iris-setosa
+26 Iris-setosa
+27 Iris-setosa
+28 Iris-versicolor
+29 Iris-versicolor
+30 Iris-setosa
+31 Iris-versicolor
+32 Iris-setosa
+33 Iris-virginica
+34 Iris-setosa
+35 Iris-setosa
+36 Iris-virginica
+37 Iris-virginica
+38 Iris-versicolor
+39 Iris-virginica
+40 Iris-setosa
+41 Iris-virginica
+42 Iris-virginica
+43 Iris-virginica
+44 Iris-setosa
+45 Iris-virginica
+46 Iris-versicolor
+47 Iris-setosa
+48 Iris-setosa
+49 Iris-virginica
+50 Iris-virginica
+51 Iris-virginica
+52 Iris-versicolor
+53 Iris-versicolor
+54 Iris-setosa
+55 Iris-versicolor
+56 Iris-virginica
+57 Iris-setosa
+58 Iris-virginica
+59 Iris-setosa
+60 Iris-versicolor
+61 Iris-virginica
+62 Iris-versicolor
+63 Iris-virginica
+64 Iris-setosa
+65 Iris-virginica
+66 Iris-versicolor
+67 Iris-virginica
+68 Iris-setosa
+69 Iris-setosa
+70 Iris-versicolor
+71 Iris-setosa
+72 Iris-versicolor
+73 Iris-versicolor
+74 Iris-versicolor
+75 Iris-virginica
+76 Iris-versicolor
+77 Iris-setosa
+78 Iris-versicolor
+79 Iris-versicolor
+80 Iris-setosa
+81 Iris-setosa
+82 Iris-virginica
+83 Iris-virginica
+84 Iris-versicolor
+85 Iris-setosa
+86 Iris-virginica
+87 Iris-versicolor
+88 Iris-virginica
+89 Iris-setosa
+90 Iris-setosa
+91 Iris-versicolor
+92 Iris-virginica
+93 Iris-versicolor
+94 Iris-setosa
+95 Iris-versicolor
+96 Iris-setosa
+97 Iris-setosa
+98 Iris-versicolor
+99 Iris-versicolor
diff --git a/training/liblbfgs/lbfgs++.h b/training/liblbfgs/lbfgs++.h
index 342f9b0e..2b40c19b 100644
--- a/training/liblbfgs/lbfgs++.h
+++ b/training/liblbfgs/lbfgs++.h
@@ -16,28 +16,33 @@
template <typename Function>
class LBFGS {
public:
- LBFGS(size_t n, // number of variables
- const Function& f, // function to optimize
- double l1_c = 0.0, // l1 penalty strength
- size_t m = 10 // number of memory buffers
- // TODO should use custom allocator here:
+ LBFGS(size_t n, // number of variables
+ const Function& f, // function to optimize
+ size_t m = 10, // number of memory buffers
+ double l1_c = 0.0, // l1 penalty strength
+ unsigned l1_start = 0, // l1 penalty starting index
+ double eps = 1e-5 // convergence epsilon
+ // TODO should use custom allocator here:
) : p_x(new std::vector<lbfgsfloatval_t>(n, 0.0)),
owned(true),
m_x(*p_x),
func(f) {
- Init(m, l1_c);
+ Init(m, l1_c, l1_start, eps);
}
// constructor where external vector storage for variables is used
LBFGS(std::vector<lbfgsfloatval_t>* px,
const Function& f,
- double l1_c = 0.0, // l1 penalty strength
- size_t m = 10
+ size_t m = 10, // number of memory buffers
+ double l1_c = 0.0, // l1 penalty strength
+ unsigned l1_start = 0, // l1 penalty starting index
+ double eps = 1e-5 // convergence epsilon
+ // TODO should use custom allocator here:
) : p_x(px),
owned(false),
m_x(*p_x),
func(f) {
- Init(m, l1_c);
+ Init(m, l1_c, l1_start, eps);
}
~LBFGS() {
@@ -60,12 +65,14 @@ class LBFGS {
}
private:
- void Init(size_t m, double l1_c) {
+ void Init(size_t m, double l1_c, unsigned l1_start, double eps) {
lbfgs_parameter_init(&param);
param.m = m;
+ param.epsilon = eps;
if (l1_c > 0.0) {
param.linesearch = LBFGS_LINESEARCH_BACKTRACKING;
- param.orthantwise_c = 1.0;
+ param.orthantwise_c = l1_c;
+ param.orthantwise_start = l1_start;
}
silence = false;
}
@@ -83,6 +90,7 @@ class LBFGS {
lbfgsfloatval_t *g,
const int n,
const lbfgsfloatval_t step) {
+ (void) x;
(void) n;
(void) step;
if (!silence) { ec++; std::cerr << '.'; }
diff --git a/training/liblbfgs/ll_test.cc b/training/liblbfgs/ll_test.cc
index 43c0f214..48bc0366 100644
--- a/training/liblbfgs/ll_test.cc
+++ b/training/liblbfgs/ll_test.cc
@@ -5,7 +5,7 @@ using namespace std;
// Function must be lbfgsfloatval_t f(x.begin, x.end, g.begin)
lbfgsfloatval_t func(const vector<lbfgsfloatval_t>& x, lbfgsfloatval_t* g) {
- int i;
+ unsigned i;
lbfgsfloatval_t fx = 0.0;
for (i = 0;i < x.size();i += 2) {
@@ -24,7 +24,7 @@ void Opt(F& f) {
lbfgs.MinimizeFunction();
}
-int main(int argc, char** argv) {
+int main() {
Opt(func);
return 0;
}
diff --git a/utils/fast_sparse_vector.h b/utils/fast_sparse_vector.h
index af832950..68caa704 100644
--- a/utils/fast_sparse_vector.h
+++ b/utils/fast_sparse_vector.h
@@ -7,8 +7,6 @@
// important: indexes are integers
// important: iterators may return elements in any order
-#include "config.h"
-
#include <cmath>
#include <cstring>
#include <climits>
@@ -16,8 +14,9 @@
#include <cassert>
#include <vector>
-#include <boost/static_assert.hpp>
+#include "config.h"
+#include <boost/static_assert.hpp>
#if HAVE_BOOST_ARCHIVE_TEXT_OARCHIVE_HPP
#include <boost/serialization/map.hpp>
#endif
@@ -119,6 +118,17 @@ class FastSparseVector {
std::memcpy(this, &other, sizeof(FastSparseVector));
if (is_remote_) data_.rbmap = new std::map<int, T>(*data_.rbmap);
}
+ FastSparseVector(std::pair<int, T>* first, std::pair<int, T>* last) {
+ const ptrdiff_t n = last - first;
+ if (n <= LOCAL_MAX) {
+ is_remote_ = false;
+ local_size_ = n;
+ std::memcpy(data_.local, first, sizeof(std::pair<int, T>) * n);
+ } else {
+ is_remote_ = true;
+ data_.rbmap = new std::map<int, T>(first, last);
+ }
+ }
void erase(int k) {
if (is_remote_) {
data_.rbmap->erase(k);