Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Conformal AI package, including all data IO, transformations, machine learning models and predictor classes. Without inclusion of chemistry-dependent code.
/*
* Copyright (C) Aros Bio AB.
*
* CPSign is an Open Source Software that is dual licensed to allow you to choose a license that best suits your requirements:
*
* 1) GPLv3 (GNU General Public License Version 3) with Additional Terms, including an attribution clause as well as a limitation to use the software for commercial purposes.
*
* 2) CPSign Proprietary License that allows you to use CPSign for commercial activities, such as in a revenue-generating operation or environment, or integrate CPSign in your proprietary software without worrying about disclosing the source code of your proprietary software, which is required if you choose to use the software under GPLv3 license. See arosbio.com/cpsign/commercial-license for details.
*/
package com.arosbio.ml.cp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.arosbio.ml.IntervalUtils;
import com.google.common.collect.Range;
import com.google.common.math.DoubleMath;
/**
* The CPRegressionPrediction holds the result of a Conformal Regressor prediction.
*
* @author staffan
*/
public class CPRegressionPrediction {
private static final double EQUIV_TOL=1e-5;
private double y_hat; //The midpoint
private double intervalScaling;
private double minObs;
private double maxObs;
/** Confidence dependent prediction intervals */
private Map intervals = new HashMap<>();
/** Width dependent prediction intervals */
private Map predictionWidthBasedIntervals = new HashMap<>();
public class PredictedInterval implements Comparable{
private double predictedHalfIntervalWidth;
private double confidence;
public PredictedInterval(double confidence, double intervalHalfWidth) {
this.confidence = confidence;
if (intervalHalfWidth < 0)
throw new IllegalArgumentException("Interval widths must be positive, got: " + intervalHalfWidth);
this.predictedHalfIntervalWidth=intervalHalfWidth; // Width must be positive
}
public double getIntervalHalfWidth() {
return predictedHalfIntervalWidth;
}
public double getIntervalWidth() {
return predictedHalfIntervalWidth*2;
}
public Range getInterval(){
return IntervalUtils.getInterval(y_hat, predictedHalfIntervalWidth);
}
public Range getCappedInterval(){
return IntervalUtils.getCappedInterval(y_hat, predictedHalfIntervalWidth, minObs, maxObs);
}
public double getConfidence() {
return confidence;
}
public Map