@@ -0,0 +1,1342 @@
+package edu.neu.ccs.pyramid.dataset;%0A%0Aimport mltk.core.Attribute;%0Aimport mltk.core.Instance;%0Aimport mltk.core.Instances;%0Aimport mltk.core.NumericalAttribute;%0Aimport org.apache.mahout.math.Vector;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Created by chengli on 11/18/14.%0A */%0Apublic class MLTKFormat %7B%0A    public static Instances toInstances(ClfDataSet dataSet)%7B%0A        List%3CAttribute%3E attributes = new ArrayList%3C%3E();%0A        for (int j=0;j%3CdataSet.getNumFeatures();j++)%7B%0A            String name = dataSet.getFeatureSetting(j).getFeatureName();%0A            attributes.add(new NumericalAttribute(name));%0A        %7D%0A        Instances instances = new Instances(attributes);%0A        for (int i=0;i%3CdataSet.getNumDataPoints();i++)%7B%0A            instances.add(toInstance(dataSet,i));%0A        %7D%0A        return instances;%0A    %7D%0A    %0A    public static Instance toInstance(ClfDataSet dataSet, int dataPointIndex)%7B%0A        double%5B%5D features = new double%5BdataSet.getNumFeatures()%5D;%0A        Vector vector = dataSet.getRow(dataPointIndex);%0A        for (Vector.Element element: vector.nonZeroes())%7B%0A            int index = element.index();%0A            double value = element.get();%0A            features%5Bindex%5D = value;%0A        %7D%0A        double label = dataSet.getLabels()%5BdataPointIndex%5D;%0A        return new Instance(features,label);%0A    %7D%0A%7D%0A

add class MLTKFormat