use of edu.cmu.tetrad.annotation.Gaussian in project tetrad by cmu-phil.
the class GeneralAlgorithmEditor method refreshScoreList.
private void refreshScoreList() {
updatingScoreModels = true;
scoreComboBox.removeAllItems();
AlgorithmModel algoModel = algorithmList.getSelectedValue();
if (algoModel != null && algoModel.isRequiredScore()) {
boolean linear = linearVarChkBox.isSelected();
boolean gaussian = gaussianVarChkBox.isSelected();
List<ScoreModel> models = ScoreModels.getInstance().getModels(dataType);
List<ScoreModel> scoreModels = new LinkedList<>();
if (linear && gaussian) {
models.stream().filter(e -> e.getScore().getClazz().isAnnotationPresent(Linear.class)).filter(e -> e.getScore().getClazz().isAnnotationPresent(Gaussian.class)).forEach(e -> scoreModels.add(e));
} else if (linear) {
models.stream().filter(e -> e.getScore().getClazz().isAnnotationPresent(Linear.class)).filter(e -> !e.getScore().getClazz().isAnnotationPresent(Gaussian.class)).forEach(e -> scoreModels.add(e));
} else if (gaussian) {
models.stream().filter(e -> !e.getScore().getClazz().isAnnotationPresent(Linear.class)).filter(e -> e.getScore().getClazz().isAnnotationPresent(Gaussian.class)).forEach(e -> scoreModels.add(e));
} else {
models.stream().forEach(e -> scoreModels.add(e));
}
// or BDeu score for discrete data
if (TsImages.class.equals(algoModel.getAlgorithm().getClazz())) {
switch(dataType) {
case Continuous:
scoreModels.stream().filter(e -> e.getScore().getClazz().equals(SemBicScore.class)).forEach(e -> scoreComboBox.addItem(e));
break;
case Discrete:
scoreModels.stream().filter(e -> e.getScore().getClazz().equals(BdeuScore.class)).forEach(e -> scoreComboBox.addItem(e));
break;
}
} else {
scoreModels.forEach(e -> scoreComboBox.addItem(e));
}
}
updatingScoreModels = false;
if (scoreComboBox.getItemCount() > 0) {
scoreComboBox.setEnabled(true);
Map<DataType, ScoreModel> map = defaultScoreModels.get(algoModel);
if (map == null) {
map = new EnumMap<>(DataType.class);
defaultScoreModels.put(algoModel, map);
}
ScoreModel scoreModel = map.get(dataType);
if (scoreModel == null) {
scoreModel = ScoreModels.getInstance().getDefaultModel(dataType);
if (scoreModel == null) {
scoreModel = scoreComboBox.getItemAt(0);
}
}
scoreComboBox.setSelectedItem(scoreModel);
} else {
scoreComboBox.setEnabled(false);
}
}
use of edu.cmu.tetrad.annotation.Gaussian in project tetrad by cmu-phil.
the class GeneralAlgorithmEditor method refreshTestList.
private void refreshTestList() {
updatingTestModels = true;
indTestComboBox.removeAllItems();
AlgorithmModel algoModel = algorithmList.getSelectedValue();
if (algoModel != null && algoModel.isRequiredTest()) {
boolean linear = linearVarChkBox.isSelected();
boolean gaussian = gaussianVarChkBox.isSelected();
List<IndependenceTestModel> models = IndependenceTestModels.getInstance().getModels(dataType);
if (linear && gaussian) {
models.stream().filter(e -> e.getIndependenceTest().getClazz().isAnnotationPresent(Linear.class)).filter(e -> e.getIndependenceTest().getClazz().isAnnotationPresent(Gaussian.class)).forEach(e -> indTestComboBox.addItem(e));
} else if (linear) {
models.stream().filter(e -> e.getIndependenceTest().getClazz().isAnnotationPresent(Linear.class)).filter(e -> !e.getIndependenceTest().getClazz().isAnnotationPresent(Gaussian.class)).forEach(e -> indTestComboBox.addItem(e));
} else if (gaussian) {
models.stream().filter(e -> !e.getIndependenceTest().getClazz().isAnnotationPresent(Linear.class)).filter(e -> e.getIndependenceTest().getClazz().isAnnotationPresent(Gaussian.class)).forEach(e -> indTestComboBox.addItem(e));
} else {
models.stream().forEach(e -> indTestComboBox.addItem(e));
}
}
updatingTestModels = false;
if (indTestComboBox.getItemCount() > 0) {
indTestComboBox.setEnabled(true);
Map<DataType, IndependenceTestModel> map = defaultIndTestModels.get(algoModel);
if (map == null) {
map = new EnumMap<>(DataType.class);
defaultIndTestModels.put(algoModel, map);
}
IndependenceTestModel testModel = map.get(dataType);
if (testModel == null) {
testModel = IndependenceTestModels.getInstance().getDefaultModel(dataType);
if (testModel == null) {
testModel = indTestComboBox.getItemAt(0);
}
}
indTestComboBox.setSelectedItem(testModel);
} else {
indTestComboBox.setEnabled(false);
}
}
Aggregations