use of edu.cmu.tetrad.data.DataModel in project tetrad by cmu-phil.
the class LoadDataAction method isDataEmpty.
// ======================= private methods =========================//
/**
* States whether the data is empty.
*/
private boolean isDataEmpty() {
DataWrapper wrapper = this.dataEditor.getDataWrapper();
DataModelList dataModels = wrapper.getDataModelList();
for (DataModel model : dataModels) {
if (model instanceof DataSet) {
return ((DataSet) model).getNumRows() == 0;
} else {
// how do you know in this case? Just say false
return false;
}
}
return true;
}
use of edu.cmu.tetrad.data.DataModel in project tetrad by cmu-phil.
the class LogisticRegressionParamsPanel method getVarsFromData.
private List<String> getVarsFromData(Object[] parentModels) {
DataModel dataModel = null;
for (Object parentModel : parentModels) {
if (parentModel instanceof DataWrapper) {
DataWrapper dataWrapper = (DataWrapper) parentModel;
dataModel = dataWrapper.getSelectedDataModel();
}
}
if (dataModel == null) {
return null;
} else {
return new ArrayList<>(dataModel.getVariableNames());
}
}
use of edu.cmu.tetrad.data.DataModel in project tetrad by cmu-phil.
the class MbSearchParamEditor method getVarsFromData.
private List<String> getVarsFromData(Object[] parentModels) {
DataModel dataModel = null;
for (Object parentModel : parentModels) {
if (parentModel instanceof DataWrapper) {
DataWrapper dataWrapper = (DataWrapper) parentModel;
dataModel = dataWrapper.getSelectedDataModel();
} else if (parentModel instanceof IndependenceFactsModel) {
dataModel = ((IndependenceFactsModel) parentModel).getFacts();
}
}
if (dataModel == null) {
return null;
} else {
return new ArrayList<>(dataModel.getVariableNames());
}
}
use of edu.cmu.tetrad.data.DataModel in project tetrad by cmu-phil.
the class MimSearchEditor method getIndTestParamBox.
/**
* Factory to return the correct param editor for independence test params.
* This will go in a little box in the search editor.
*/
private JComponent getIndTestParamBox(Parameters params) {
if (params == null) {
throw new NullPointerException();
}
if (params instanceof Parameters) {
MimRunner runner = getMimRunner();
params.set("varNames", runner.getParams().get("varNames", null));
DataModel dataModel = runner.getData();
if (dataModel instanceof DataSet) {
DataSet data = (DataSet) runner.getData();
boolean discrete = data.isDiscrete();
return new BuildPureClustersIndTestParamsEditor(params, discrete);
} else if (dataModel instanceof ICovarianceMatrix) {
return new BuildPureClustersIndTestParamsEditor(params, false);
}
}
if (params instanceof Parameters) {
MimRunner runner = getMimRunner();
params.set("varNames", runner.getParams().get("varNames", null));
boolean discreteData = false;
if (runner.getData() instanceof DataSet) {
discreteData = ((DataSet) runner.getData()).isDiscrete();
}
return new PurifyIndTestParamsEditor(params, discreteData);
}
if (params instanceof Parameters) {
MimRunner runner = getMimRunner();
params.set("varNames", runner.getParams().get("varNames", null));
return new MimBuildIndTestParamsEditor(params);
}
throw new IllegalArgumentException("Unrecognized IndTestParams: " + params.getClass());
}
use of edu.cmu.tetrad.data.DataModel in project tetrad by cmu-phil.
the class MissingDataInjectorAction method actionPerformed.
/**
* Performs the action of loading a session from a file.
*/
public void actionPerformed(ActionEvent e) {
DataModel dataModel = getDataEditor().getSelectedDataModel();
if (dataModel instanceof DataSet) {
DataSet dataSet = (DataSet) dataModel;
JComponent editor = editor();
int selection = JOptionPane.showOptionDialog(JOptionUtils.centeringComp(), editor, "Probability", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Done", "Cancel" }, "Done");
if (selection != 0) {
return;
}
int numVars = dataSet.getNumColumns();
double prob = getProb();
double[] probs = new double[numVars];
for (int i = 0; i < probs.length; i++) {
probs[i] = prob;
}
DataSet newDataSet = DataUtils.addMissingData(dataSet, probs);
DataModelList list = new DataModelList();
list.add(newDataSet);
getDataEditor().reset(list);
getDataEditor().selectFirstTab();
} else {
JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Must be a tabular data set.");
}
}
Aggregations