   size_t nClasses = classes.size();
 
   // Convert labels to posterior probabilities
-  _hp.resize(_hy.getRows(), nClasses);
+  _hp.resize(nClasses, _hy.getCols());
   _hp.fillwith(0);
 
-  for (size_t i=0; i<_hp.getRows(); ++i)
-    _hp(i, (_hy[i] - 1)) = 1;
+  for (size_t i=0; i<_hp.getCols(); ++i)
+    _hp((_hy[i] - 1), i) = 1;
 }
 
 bool isFileSparse(string train_fn) {


void DataSet::rescaleFeature(float lower, float upper) {

  size_t rows = this->size(),
	 cols = this->_dim;

  for (size_t i=0; i<this->size(); ++i) {
    float min = _hx(i, 0),
	  max = _hx(i, 0);

    for (size_t j=0; j<cols; ++j) {
      float x = _hx(i, j);
      if (x > max) max = x;
      if (x < min) min = x;
    }

    if (max == min) {
      for (size_t j=0; j<cols; ++j)
	_hx(i, j) = upper;
      continue;
    }

    float ratio = (upper - lower) / (max - min);
    for (size_t j=0; j<cols; ++j)
      _hx(i, j) = (_hx(i, j) - min) * ratio + lower;
  }
}



    size_t j = 0;
    while (ss >> token)
      _hx(j++, i) = str2float(token);
    ++i;
  }
}
