public static ExampleSet createExampleSet(double[][] data,double[] labels){
  if (data.length == 0) {
    throw new RuntimeException("ExampleSetFactory.createExampleSet(double[][], double[]): data matrix is not allowed to be empty.");
  }
  int numberOfAttributes=data[0].length;
  List<Attribute> attributeList=new ArrayList<Attribute>(numberOfAttributes + (labels != null ? 1 : 0));
  for (int a=0; a < numberOfAttributes; a++) {
    attributeList.add(AttributeFactory.createAttribute("att" + (a + 1),Ontology.NUMERICAL));
  }
  Attribute labelAttribute=null;
  if (labels != null) {
    labelAttribute=AttributeFactory.createAttribute("label",Ontology.NUMERICAL);
    attributeList.add(labelAttribute);
  }
  MemoryExampleTable table=new MemoryExampleTable(attributeList);
  for (int e=0; e < data.length; e++) {
    double[] dataRow=data[e];
    if (labelAttribute != null) {
      dataRow=new double[numberOfAttributes + 1];
      System.arraycopy(data[e],0,dataRow,0,data[e].length);
      dataRow[dataRow.length - 1]=labels[e];
    }
    table.addDataRow(new DoubleArrayDataRow(dataRow));
  }
  return table.createExampleSet(labelAttribute);
}

public static ExampleSet createExampleSet ( double [ ] [ ] data , double [ ] labels ) { if ( data . length == 0 ) { throw new RuntimeException ( "ExampleSetFactory.createExampleSet(double[][], double[]): data matrix is not allowed to be empty." ) ; } int numberOfAttributes = data [ 0 ] . length ; List < Attribute > attributeList = new ArrayList < Attribute > ( numberOfAttributes + ( labels != null ? 1 : 0 ) ) ; for ( int a = 0 ; a < numberOfAttributes ; a ++ ) { attributeList . add ( AttributeFactory . createAttribute ( "att" + ( a + 1 ) , Ontology . NUMERICAL ) ) ; } Attribute labelAttribute = null ; if ( labels != null ) { labelAttribute = AttributeFactory . createAttribute ( "label" , Ontology . NUMERICAL ) ; attributeList . add ( labelAttribute ) ; } MemoryExampleTable table = new MemoryExampleTable ( attributeList ) ; for ( int e = 0 ; e < data . length ; e ++ ) { double [ ] dataRow = data [ e ] ; if ( labelAttribute != null ) { dataRow = new double [ numberOfAttributes + 1 ] ; System . arraycopy ( data [ e ] , 0 , dataRow , 0 , data [ e ] . length ) ; dataRow [ dataRow . length - 1 ] = labels [ e ] ; } table . addDataRow ( new DoubleArrayDataRow ( dataRow ) ) ; } return table . createExampleSet ( labelAttribute ) ; }
create a numerical example set from the given data matrix . the label of the resulting example set be build from the given double array . the example set consists of numerical attributes only .
