("External Outlier", "external-outlier", TypeUtil.DOUBLE, scores, relation.getDBIDs());
OutlierResult or = new OutlierResult(meta, scoresult);
// Apply scaling
if(scaling instanceof OutlierScalingFunction) {
((OutlierScalingFunction) scaling).prepare(or);
}
DoubleMinMax mm = new DoubleMinMax();
for(DBID id : relation.iterDBIDs()) {
double val = scoresult.get(id); // scores.get(id);
val = scaling.getScaled(val);
scores.putDouble(id, val);
mm.put(val);
}
meta = new BasicOutlierScoreMeta(mm.getMin(), mm.getMax());
or = new OutlierResult(meta, scoresult);
return or;
}
@Override
protected Logging getLogger() {
return logger;
}
@Override
public TypeInformation[] getInputTypeRestriction() {
return TypeUtil.array(TypeUtil.ANY);
}
/**
* Parameterization class
*
* @author Erich Schubert
*
* @apiviz.exclude
*/
public static class Parameterizer extends AbstractParameterizer {
/**
* Parameter that specifies the name of the file to be re-parsed.
*
* Key: {@code -externaloutlier.file}
*
*/
public static final OptionID FILE_ID = OptionID.getOrCreateOptionID("externaloutlier.file", "The file name containing the (external) outlier scores.");
/**
* Parameter that specifies the object ID pattern
*
* Key: {@code -externaloutlier.idpattern}
* Default: ^ID=
*
*/
public static final OptionID ID_ID = OptionID.getOrCreateOptionID("externaloutlier.idpattern", "The pattern to match object ID prefix");
/**
* Parameter that specifies the object score pattern
*
* Key: {@code -externaloutlier.scorepattern}
*
*/
public static final OptionID SCORE_ID = OptionID.getOrCreateOptionID("externaloutlier.scorepattern", "The pattern to match object score prefix");
/**
* Parameter to specify a scaling function to use.
*
* Key: {@code -externaloutlier.scaling}
*
*/
public static final OptionID SCALING_ID = OptionID.getOrCreateOptionID("externaloutlier.scaling", "Class to use as scaling function.");
/**
* Flag parameter for inverted scores.
*/
public static final OptionID INVERTED_ID = OptionID.getOrCreateOptionID("externaloutlier.inverted", "Flag to signal an inverted outlier score.");
/**
* The file to be reparsed
*/
private File file;
/**
* object id pattern
*/
private Pattern idpattern;
/**
* object score pattern
*/
private Pattern scorepattern;
/**
* Scaling function to use
*/
private ScalingFunction scaling;
/**
* Inversion flag.
*/
private boolean inverted = false;
@Override
protected void makeOptions(Parameterization config) {
super.makeOptions(config);
FileParameter fileP = new FileParameter(FILE_ID, FileParameter.FileType.INPUT_FILE);
if(config.grab(fileP)) {
file = fileP.getValue();
}
PatternParameter idP = new PatternParameter(ID_ID, ID_PATTERN_DEFAULT);
if(config.grab(idP)) {
idpattern = idP.getValue();
}
PatternParameter scoreP = new PatternParameter(SCORE_ID);
if(config.grab(scoreP)) {
scorepattern = scoreP.getValue();
}
Flag inverstedF = new Flag(INVERTED_ID);
if(config.grab(inverstedF)) {
inverted = inverstedF.getValue();
}
ObjectParameter scalingP = new ObjectParameter(SCALING_ID, ScalingFunction.class, IdentityScaling.class);
if(config.grab(scalingP)) {
scaling = scalingP.instantiateClass(config);
}
}
@Override
protected ExternalDoubleOutlierScore makeInstance() {
return new ExternalDoubleOutlierScore(file, idpattern, scorepattern, inverted, scaling);
}
}
}