use of edu.cmu.tetrad.data.DataSet in project tetrad by cmu-phil.
the class TsFci method search.
@Override
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt("bootstrapSampleSize") < 1) {
edu.cmu.tetrad.search.TsFci search = new edu.cmu.tetrad.search.TsFci(test.getTest(dataSet, parameters));
search.setDepth(parameters.getInt("depth"));
search.setKnowledge(dataSet.getKnowledge());
return search.search();
} else {
TsFci tsFci = new TsFci(test, algorithm);
DataSet data = (DataSet) dataSet;
GeneralBootstrapTest search = new GeneralBootstrapTest(data, tsFci, parameters.getInt("bootstrapSampleSize"));
search.setKnowledge(knowledge);
BootstrapEdgeEnsemble edgeEnsemble = BootstrapEdgeEnsemble.Highest;
switch(parameters.getInt("bootstrapEnsemble", 1)) {
case 0:
edgeEnsemble = BootstrapEdgeEnsemble.Preserved;
break;
case 1:
edgeEnsemble = BootstrapEdgeEnsemble.Highest;
break;
case 2:
edgeEnsemble = BootstrapEdgeEnsemble.Majority;
}
search.setEdgeEnsemble(edgeEnsemble);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean("verbose"));
return search.search();
}
}
use of edu.cmu.tetrad.data.DataSet in project tetrad by cmu-phil.
the class CpcStable method search.
@Override
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt("bootstrapSampleSize") < 1) {
Graph init = null;
if (algorithm != null) {
// init = algorithm.search(dataSet, parameters);
}
edu.cmu.tetrad.search.PcAll search = new edu.cmu.tetrad.search.PcAll(test.getTest(dataSet, parameters), init);
search.setDepth(parameters.getInt("depth"));
search.setKnowledge(knowledge);
search.setFasRule(PcAll.FasRule.FAS_STABLE);
search.setColliderDiscovery(edu.cmu.tetrad.search.PcAll.ColliderDiscovery.CONSERVATIVE);
search.setConflictRule(edu.cmu.tetrad.search.PcAll.ConflictRule.PRIORITY);
search.setVerbose(parameters.getBoolean("verbose"));
return search.search();
} else {
CpcStable cpcStable = new CpcStable(test, algorithm);
// cpcStable.setKnowledge(knowledge);
DataSet data = (DataSet) dataSet;
GeneralBootstrapTest search = new GeneralBootstrapTest(data, algorithm, parameters.getInt("bootstrapSampleSize"));
search.setKnowledge(knowledge);
BootstrapEdgeEnsemble edgeEnsemble = BootstrapEdgeEnsemble.Highest;
switch(parameters.getInt("bootstrapEnsemble", 1)) {
case 0:
edgeEnsemble = BootstrapEdgeEnsemble.Preserved;
break;
case 1:
edgeEnsemble = BootstrapEdgeEnsemble.Highest;
break;
case 2:
edgeEnsemble = BootstrapEdgeEnsemble.Majority;
}
search.setEdgeEnsemble(edgeEnsemble);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean("verbose"));
return search.search();
}
}
use of edu.cmu.tetrad.data.DataSet in project tetrad by cmu-phil.
the class Fges method search.
@Override
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt("bootstrapSampleSize") < 1) {
if (algorithm != null) {
// initialGraph = algorithm.search(dataSet, parameters);
}
edu.cmu.tetrad.search.Fges search = new edu.cmu.tetrad.search.Fges(score.getScore(dataSet, parameters));
search.setFaithfulnessAssumed(parameters.getBoolean("faithfulnessAssumed"));
search.setKnowledge(knowledge);
search.setVerbose(parameters.getBoolean("verbose"));
search.setMaxDegree(parameters.getInt("maxDegree"));
search.setSymmetricFirstStep(parameters.getBoolean("symmetricFirstStep"));
Object obj = parameters.get("printStream");
if (obj instanceof PrintStream) {
search.setOut((PrintStream) obj);
}
if (initialGraph != null) {
search.setInitialGraph(initialGraph);
}
return search.search();
} else {
Fges fges = new Fges(score, algorithm);
// fges.setKnowledge(knowledge);
DataSet data = (DataSet) dataSet;
GeneralBootstrapTest search = new GeneralBootstrapTest(data, fges, parameters.getInt("bootstrapSampleSize"));
search.setKnowledge(knowledge);
BootstrapEdgeEnsemble edgeEnsemble = BootstrapEdgeEnsemble.Highest;
switch(parameters.getInt("bootstrapEnsemble", 1)) {
case 0:
edgeEnsemble = BootstrapEdgeEnsemble.Preserved;
break;
case 1:
edgeEnsemble = BootstrapEdgeEnsemble.Highest;
break;
case 2:
edgeEnsemble = BootstrapEdgeEnsemble.Majority;
}
search.setEdgeEnsemble(edgeEnsemble);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean("verbose"));
return search.search();
}
}
use of edu.cmu.tetrad.data.DataSet in project tetrad by cmu-phil.
the class Lingam method search.
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt("bootstrapSampleSize") < 1) {
edu.cmu.tetrad.search.Lingam lingam = new edu.cmu.tetrad.search.Lingam();
lingam.setPenaltyDiscount(parameters.getDouble("penaltyDiscount"));
return lingam.search(DataUtils.getContinuousDataSet(dataSet));
} else {
Lingam algorithm = new Lingam();
DataSet data = (DataSet) dataSet;
GeneralBootstrapTest search = new GeneralBootstrapTest(data, algorithm, parameters.getInt("bootstrapSampleSize"));
BootstrapEdgeEnsemble edgeEnsemble = BootstrapEdgeEnsemble.Highest;
switch(parameters.getInt("bootstrapEnsemble", 1)) {
case 0:
edgeEnsemble = BootstrapEdgeEnsemble.Preserved;
break;
case 1:
edgeEnsemble = BootstrapEdgeEnsemble.Highest;
break;
case 2:
edgeEnsemble = BootstrapEdgeEnsemble.Majority;
}
search.setEdgeEnsemble(edgeEnsemble);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean("verbose"));
return search.search();
}
}
use of edu.cmu.tetrad.data.DataSet in project tetrad by cmu-phil.
the class StabilitySelection method search.
@Override
public Graph search(DataModel dataSet, Parameters parameters) {
DataSet _dataSet = (DataSet) dataSet;
double percentageB = parameters.getDouble("percentSubsampleSize");
int numSubsamples = parameters.getInt("numSubsamples");
Map<Edge, Integer> counts = new HashMap<>();
List<Graph> graphs = new ArrayList<>();
final ForkJoinPool pool = ForkJoinPoolInstance.getInstance().getPool();
class StabilityAction extends RecursiveAction {
private int chunk;
private int from;
private int to;
private StabilityAction(int chunk, int from, int to) {
this.chunk = chunk;
this.from = from;
this.to = to;
}
@Override
protected void compute() {
if (to - from <= chunk) {
for (int s = from; s < to; s++) {
BootstrapSampler sampler = new BootstrapSampler();
sampler.setWithoutReplacements(true);
DataSet sample = sampler.sample(_dataSet, (int) (percentageB * _dataSet.getNumRows()));
Graph graph = algorithm.search(sample, parameters);
graphs.add(graph);
}
} else {
final int mid = (to + from) / 2;
StabilityAction left = new StabilityAction(chunk, from, mid);
StabilityAction right = new StabilityAction(chunk, mid, to);
left.fork();
right.compute();
left.join();
}
}
}
final int chunk = 2;
pool.invoke(new StabilityAction(chunk, 0, numSubsamples));
// }
for (Graph graph : graphs) {
for (Edge edge : graph.getEdges()) {
increment(edge, counts);
}
}
initialGraph = new EdgeListGraph(dataSet.getVariables());
double percentStability = parameters.getDouble("percentStability");
for (Edge edge : counts.keySet()) {
if (counts.get(edge) > percentStability * numSubsamples) {
initialGraph.addEdge(edge);
}
}
return initialGraph;
}
Aggregations