   _dim = isSparse ? findMaxDimension(fin) : findDimension(fin);
   size_t N = getLineNumber(fin);
 
-  _hx.resize(N, _dim + 1);
-  _hy.resize(N, 1);
+  _hx.resize(_dim + 1, N);
+  _hy.resize(1, N);
 
   if (isSparse)
     readSparseFeature(fin);


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


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

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

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

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

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

