public RegressionDataSet(List<DataPoint> data,int predicting){
  DataPoint tmp=data.get(0);
  categories=new CategoricalData[tmp.numCategoricalValues()];
  System.arraycopy(tmp.getCategoricalData(),0,categories,0,categories.length);
  numNumerVals=tmp.numNumericalValues() - 1;
  dataPoints=new ArrayList<DataPointPair<Double>>(data.size());
  for (  DataPoint dp : data) {
    Vec origV=dp.getNumericalValues();
    Vec newVec;
    double target=0;
    if (origV.isSparse())     newVec=new SparseVector(origV.length() - 1,origV.nnz());
 else     newVec=new DenseVector(origV.length() - 1);
    for (    IndexValue iv : origV)     if (iv.getIndex() < predicting)     newVec.set(iv.getIndex(),iv.getValue());
 else     if (iv.getIndex() == predicting)     target=iv.getValue();
 else     newVec.set(iv.getIndex() - 1,iv.getValue());
    DataPoint newDp=new DataPoint(newVec,dp.getCategoricalValues(),categories,dp.getWeight());
    DataPointPair<Double> dpp=new DataPointPair<Double>(newDp,target);
    dataPoints.add(dpp);
  }
  this.numericalVariableNames=new ArrayList<String>(getNumNumericalVars());
  setUpGenericNumericNames();
}

public RegressionDataSet ( List < DataPoint > data , int predicting ) { DataPoint tmp = data . get ( 0 ) ; categories = new CategoricalData [ tmp . numCategoricalValues ( ) ] ; System . arraycopy ( tmp . getCategoricalData ( ) , 0 , categories , 0 , categories . length ) ; numNumerVals = tmp . numNumericalValues ( ) - 1 ; dataPoints = new ArrayList < DataPointPair < Double > > ( data . size ( ) ) ; for ( DataPoint dp : data ) { Vec origV = dp . getNumericalValues ( ) ; Vec newVec ; double target = 0 ; if ( origV . isSparse ( ) ) newVec = new SparseVector ( origV . length ( ) - 1 , origV . nnz ( ) ) ; else newVec = new DenseVector ( origV . length ( ) - 1 ) ; for ( IndexValue iv : origV ) if ( iv . getIndex ( ) < predicting ) newVec . set ( iv . getIndex ( ) , iv . getValue ( ) ) ; else if ( iv . getIndex ( ) == predicting ) target = iv . getValue ( ) ; else newVec . set ( iv . getIndex ( ) - 1 , iv . getValue ( ) ) ; DataPoint newDp = new DataPoint ( newVec , dp . getCategoricalValues ( ) , categories , dp . getWeight ( ) ) ; DataPointPair < Double > dpp = new DataPointPair < Double > ( newDp , target ) ; dataPoints . add ( dpp ) ; } this . numericalVariableNames = new ArrayList < String > ( getNumNumericalVars ( ) ) ; setUpGenericNumericNames ( ) ; }
creates a new data set for the given list of data points . the data points will be copied , changes in one will not effect the other .
