本文整理汇总了Java中de.lmu.ifi.dbs.elki.result.ResultUtil.filterResults方法的典型用法代码示例。如果您正苦于以下问题:Java ResultUtil.filterResults方法的具体用法?Java ResultUtil.filterResults怎么用?Java ResultUtil.filterResults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.lmu.ifi.dbs.elki.result.ResultUtil
的用法示例。
在下文中一共展示了ResultUtil.filterResults方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newContext
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
/**
* Make a new visualization context
*
* @param hier Result hierarchy
* @param start Starting result
* @return New context
*/
public VisualizerContext newContext(ResultHierarchy hier, Result start) {
Collection<Relation<?>> rels = ResultUtil.filterResults(hier, Relation.class);
for(Relation<?> rel : rels) {
if(samplesize == 0) {
continue;
}
if(!ResultUtil.filterResults(hier, rel, SamplingResult.class).isEmpty()) {
continue;
}
if(rel.size() > samplesize) {
SamplingResult sample = new SamplingResult(rel);
sample.setSample(DBIDUtil.randomSample(sample.getSample(), samplesize, rnd));
ResultUtil.addChildResult(rel, sample);
}
}
return new VisualizerContext(hier, start, stylelib, factories);
}
示例2: processNewResult
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
@Override
public void processNewResult(ResultHierarchy hier, Result newResult) {
Database db = ResultUtil.findDatabase(hier);
Collection<String> header = null;
final ArrayList<IndexTree<?, ?>> indexes = ResultUtil.filterResults(hier, newResult, IndexTree.class);
if (indexes == null || indexes.isEmpty()) {
return;
}
for(IndexTree<?, ?> index : indexes) {
header = new ArrayList<>();
header.add(index.toString());
}
Collection<Pair<String, String>> col = new ArrayList<>();
IndexMetaResult analysis = new IndexMetaResult(col, header);
db.getHierarchy().add(db, analysis);
}
示例3: processNewResult
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
@Override
public void processNewResult(ResultHierarchy hier, Result result) {
Database db = ResultUtil.findDatabase(hier);
List<OutlierResult> ors = ResultUtil.filterResults(hier, OutlierResult.class);
if (ors == null || ors.isEmpty()) {
// logger.warning("No results found for "+JudgeOutlierScores.class.getSimpleName());
return;
}
ModifiableDBIDs ids = DBIDUtil.newHashSet(ors.iterator().next().getScores().getDBIDs());
DBIDs outlierIds = DatabaseUtil.getObjectsByLabelMatch(db, positiveClassName);
ids.removeDBIDs(outlierIds);
for (OutlierResult or : ors) {
db.getHierarchy().add(or, computeScore(ids, outlierIds, or));
}
}
示例4: testAUC
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
/**
* Test the AUC value for an outlier result.
*
* @param db Database
* @param positive Positive class name
* @param result Outlier result to process
* @param expected Expected AUC value
*/
protected void testAUC(Database db, String positive, OutlierResult result, double expected) {
OutlierROCCurve rocCurve = new ELKIBuilder<>(OutlierROCCurve.class)//
.with(OutlierROCCurve.Parameterizer.POSITIVE_CLASS_NAME_ID, positive).build();
// Ensure the result has been added to the hierarchy:
ResultHierarchy hier = db.getHierarchy();
if(hier.numParents(result) < 1) {
hier.add(db, result);
}
// Compute ROC and AUC:
rocCurve.processNewResult(hier, result);
// Find the ROC results
Collection<OutlierROCCurve.ROCResult> rocs = ResultUtil.filterResults(hier, result, OutlierROCCurve.ROCResult.class);
assertTrue("No ROC result found.", !rocs.isEmpty());
double auc = rocs.iterator().next().getAUC();
assertFalse("More than one ROC result found.", rocs.size() > 1);
assertEquals("ROC value does not match.", expected, auc, 0.0001);
}
示例5: processNewResult
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
@Override
public void processNewResult(ResultHierarchy hier, Result newResult) {
ArrayList<PointerHierarchyRepresentationResult> hrs = ResultUtil.filterResults(hier, newResult, PointerHierarchyRepresentationResult.class);
for(PointerHierarchyRepresentationResult pointerresult : hrs) {
pointerresult.addChildResult(inner.run(pointerresult));
}
}
示例6: processNewResult
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
@Override
public void processNewResult(ResultHierarchy hier, Result newResult) {
ArrayList<PointerHierarchyRepresentationResult> hrs = ResultUtil.filterResults(hier, newResult, PointerHierarchyRepresentationResult.class);
for(PointerHierarchyRepresentationResult pointerresult : hrs) {
Clustering<DendrogramModel> result = inner.run(pointerresult);
pointerresult.addChildResult(result);
}
}
示例7: getClusteringResults
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
/**
* Collect all clustering results from a Result
*
* @param r Result
* @return List of clustering results
*/
public static List<Clustering<? extends Model>> getClusteringResults(Result r) {
if(r instanceof Clustering<?>) {
List<Clustering<?>> crs = new ArrayList<>(1);
crs.add((Clustering<?>) r);
return crs;
}
if(r instanceof HierarchicalResult) {
return ResultUtil.filterResults(((HierarchicalResult) r).getHierarchy(), r, Clustering.class);
}
return Collections.emptyList();
}
示例8: processNewResult
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
@Override
public void processNewResult(ResultHierarchy hier, Result newResult) {
// Get all new outlier results
ArrayList<OutlierResult> ors = ResultUtil.filterResults(hier, newResult, OutlierResult.class);
for (OutlierResult o : ors) {
DoubleRelation scores = o.getScores();
for (DBIDIter iter = scores.iterDBIDs(); iter.valid(); iter.advance()) {
System.out.println(DBIDUtil.toString(iter) + " " + scores.doubleValue(iter));
}
}
}
示例9: processNewResult
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
@Override
public void processNewResult(ResultHierarchy hier, Result newResult) {
List<OutlierResult> ors = ResultUtil.filterResults(hier, newResult, OutlierResult.class);
for(OutlierResult or : ors) {
hier.add(or, split(or));
}
}
示例10: autoEvaluateClusterings
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
protected void autoEvaluateClusterings(ResultHierarchy hier, Result newResult) {
Collection<Clustering<?>> clusterings = ResultUtil.filterResults(hier, newResult, Clustering.class);
if(LOG.isDebugging()) {
LOG.warning("Number of new clustering results: " + clusterings.size());
}
for(Iterator<Clustering<?>> c = clusterings.iterator(); c.hasNext();) {
Clustering<?> test = c.next();
if("allinone-clustering".equals(test.getShortName())) {
c.remove();
}
else if("allinnoise-clustering".equals(test.getShortName())) {
c.remove();
}
else if("bylabel-clustering".equals(test.getShortName())) {
c.remove();
}
else if("bymodel-clustering".equals(test.getShortName())) {
c.remove();
}
}
if(!clusterings.isEmpty()) {
try {
new EvaluateClustering(new ByLabelClustering(), false, true).processNewResult(hier, newResult);
}
catch(NoSupportedDataTypeException e) {
// Pass - the data probably did not have labels.
}
}
}
示例11: ensureClusteringResult
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
/**
* Ensure that the result contains at least one Clustering.
*
* @param db Database to process
* @param result result
*/
public static void ensureClusteringResult(final Database db, final Result result) {
Collection<Clustering<?>> clusterings = ResultUtil.filterResults(db.getHierarchy(), result, Clustering.class);
if(clusterings.isEmpty()) {
ResultUtil.addChildResult(db, new ByLabelOrAllInOneClustering().run(db));
}
}
示例12: processNewResult
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
@Override
public void processNewResult(ResultHierarchy hier, Result newResult) {
final Database db = ResultUtil.findDatabase(hier);
List<OutlierResult> ors = ResultUtil.filterResults(hier, newResult, OutlierResult.class);
if(ors == null || ors.isEmpty()) {
// logger.warning("No outlier results found for
// "+ComputeOutlierHistogram.class.getSimpleName());
return;
}
for(OutlierResult or : ors) {
db.getHierarchy().add(or, evaluateOutlierResult(db, or));
}
}
示例13: getOutlierResult
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
/**
* Find an OutlierResult to work with.
*
* @param hier Result hierarchy
* @param result Result object
* @return Iterator to work with
*/
private OutlierResult getOutlierResult(ResultHierarchy hier, Result result) {
List<OutlierResult> ors = ResultUtil.filterResults(hier, result, OutlierResult.class);
if(!ors.isEmpty()) {
return ors.get(0);
}
throw new IllegalStateException("Comparison algorithm expected at least one outlier result.");
}
示例14: executeForCorrectness
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
public double executeForCorrectness(
String inDens,
ArrayList<ArrayList<Double>> normalized,
ArrayList<String> labels,
ArrayList<String> minpts,
double eps
)
throws IOException
{
ClusteringTools tools=new ClusteringTools();
//build the database from the normalized matrix
//the column of timestamp values is not present in the variable "normalized"
Database db=tools.buildDatabaseFromMatrix(normalized);
//fill in the feature hashmap only with single features
HashMap<Integer, String> featuresMap=tools.getFeaturesMap(labels);
//fill in the deltad hashmap
HashMap<String, Double> deltadMap=tools.getDeltadMap(labels, minpts);
//% of cells
Double density=normalized.size()*0.9;
CSVDataIO dataIO=new CSVDataIO();
List<CSVRecord> listDens=dataIO.readCSVFile(inDens);
ArrayList<Pair<Double, Double>> boundaries = tools.getFeatureBoundariesFromCSV(listDens);
//Run GEOSUBCLU algorithm and get the clustering result
Clustering<?> result = tools.runGEOSUBCLU(db, boundaries, featuresMap, deltadMap, density.intValue(), eps, new StringBuilder());
ArrayList<Clustering<?>> cs = ResultUtil.filterResults(result, Clustering.class);
//Get the SSE
double sse=tools.getClusteringSSE(db, cs, featuresMap);
return sse;
}
示例15: autoEvaluateOutliers
import de.lmu.ifi.dbs.elki.result.ResultUtil; //导入方法依赖的package包/类
protected void autoEvaluateOutliers(ResultHierarchy hier, Result newResult) {
Collection<OutlierResult> outliers = ResultUtil.filterResults(hier, newResult, OutlierResult.class);
if(LOG.isDebugging()) {
LOG.debug("Number of new outlier results: " + outliers.size());
}
if(!outliers.isEmpty()) {
Database db = ResultUtil.findDatabase(hier);
ensureClusteringResult(db, db);
Collection<Clustering<?>> clusterings = ResultUtil.filterResults(hier, db, Clustering.class);
if(clusterings.isEmpty()) {
LOG.warning("Could not find a clustering result, even after running 'ensureClusteringResult'?!?");
return;
}
Clustering<?> basec = clusterings.iterator().next();
// Find minority class label
int min = Integer.MAX_VALUE;
int total = 0;
String label = null;
if(basec.getAllClusters().size() > 1) {
for(Cluster<?> c : basec.getAllClusters()) {
final int csize = c.getIDs().size();
total += csize;
if(csize < min) {
min = csize;
label = c.getName();
}
}
}
if(label == null) {
LOG.warning("Could not evaluate outlier results, as I could not find a minority label.");
return;
}
if(min == 1) {
LOG.warning("The minority class label had a single object. Try using 'ClassLabelFilter' to identify the class label column.");
}
if(min > 0.05 * total) {
LOG.warning("The minority class I discovered (labeled '" + label + "') has " + (min * 100. / total) + "% of objects. Outlier classes should be more rare!");
}
LOG.verbose("Evaluating using minority class: " + label);
Pattern pat = Pattern.compile("^" + Pattern.quote(label) + "$");
// Evaluate rankings.
new OutlierRankingEvaluation(pat).processNewResult(hier, newResult);
// Compute ROC curve
new OutlierROCCurve(pat).processNewResult(hier, newResult);
// Compute Precision at k
new OutlierPrecisionAtKCurve(pat, min << 1).processNewResult(hier, newResult);
// Compute ROC curve
new OutlierPrecisionRecallCurve(pat).processNewResult(hier, newResult);
// Compute outlier histogram
new ComputeOutlierHistogram(pat, 50, new LinearScaling(), false).processNewResult(hier, newResult);
}
}