Search in sources :

Example 1 with BoxDataSet

use of edu.cmu.tetrad.data.BoxDataSet 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)

Example 2 with BoxDataSet

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

the class DataConvertUtils method toContinuousDataModel.

public static DataModel toContinuousDataModel(ContinuousTabularDataset dataset) {
    DataBox dataBox = new DoubleDataBox(dataset.getData());
    List<Node> variables = toNodes(dataset.getVariables());
    return new BoxDataSet(dataBox, variables);
}
Also used : Node(edu.cmu.tetrad.graph.Node) DoubleDataBox(edu.cmu.tetrad.data.DoubleDataBox) BoxDataSet(edu.cmu.tetrad.data.BoxDataSet) DoubleDataBox(edu.cmu.tetrad.data.DoubleDataBox) MixedDataBox(edu.cmu.tetrad.data.MixedDataBox) DataBox(edu.cmu.tetrad.data.DataBox) VerticalIntDataBox(edu.cmu.tetrad.data.VerticalIntDataBox)

Example 3 with BoxDataSet

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

the class DataConvertUtils method toVerticalDiscreteDataModel.

public static DataModel toVerticalDiscreteDataModel(VerticalDiscreteTabularDataset dataset) {
    DataBox dataBox = new VerticalIntDataBox(dataset.getData());
    List<Node> variables = toNodes(dataset.getVariableInfos());
    return new BoxDataSet(dataBox, variables);
}
Also used : Node(edu.cmu.tetrad.graph.Node) BoxDataSet(edu.cmu.tetrad.data.BoxDataSet) DoubleDataBox(edu.cmu.tetrad.data.DoubleDataBox) MixedDataBox(edu.cmu.tetrad.data.MixedDataBox) DataBox(edu.cmu.tetrad.data.DataBox) VerticalIntDataBox(edu.cmu.tetrad.data.VerticalIntDataBox) VerticalIntDataBox(edu.cmu.tetrad.data.VerticalIntDataBox)

Aggregations

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