Search in sources :

Example 1 with MixedDataBox

use of edu.cmu.tetrad.data.MixedDataBox in project tetrad by cmu-phil.

the class DataConvertUtils method toMixedDataBox.

public static DataModel toMixedDataBox(MixedTabularDataset mixedTabularDataset) {
    int numOfRows = mixedTabularDataset.getNumOfRows();
    MixedVarInfo[] mixedVarInfos = mixedTabularDataset.getMixedVarInfos();
    double[][] continuousData = mixedTabularDataset.getContinuousData();
    int[][] discreteData = mixedTabularDataset.getDiscreteData();
    List<Node> nodes = new LinkedList<>();
    for (MixedVarInfo mixedVarInfo : mixedVarInfos) {
        if (mixedVarInfo.isContinuous()) {
            nodes.add(new ContinuousVariable(mixedVarInfo.getName()));
        } else {
            nodes.add(new DiscreteVariable(mixedVarInfo.getName(), mixedVarInfo.getCategories()));
        }
    }
    return new BoxDataSet(new MixedDataBox(nodes, numOfRows, continuousData, discreteData), nodes);
}
Also used : ContinuousVariable(edu.cmu.tetrad.data.ContinuousVariable) DiscreteVariable(edu.cmu.tetrad.data.DiscreteVariable) Node(edu.cmu.tetrad.graph.Node) BoxDataSet(edu.cmu.tetrad.data.BoxDataSet) MixedDataBox(edu.cmu.tetrad.data.MixedDataBox) LinkedList(java.util.LinkedList) MixedVarInfo(edu.pitt.dbmi.data.reader.tabular.MixedVarInfo)

Aggregations

BoxDataSet (edu.cmu.tetrad.data.BoxDataSet)1 ContinuousVariable (edu.cmu.tetrad.data.ContinuousVariable)1 DiscreteVariable (edu.cmu.tetrad.data.DiscreteVariable)1 MixedDataBox (edu.cmu.tetrad.data.MixedDataBox)1 Node (edu.cmu.tetrad.graph.Node)1 MixedVarInfo (edu.pitt.dbmi.data.reader.tabular.MixedVarInfo)1 LinkedList (java.util.LinkedList)1