#NEWLINE# def abs_error_inv( prediction , nc , significance , norm = None , beta = 0 ) : #NEWLINE# #INDENT# 'Calculates a prediction from an absolute-error nonconformity function.\n\n\tCalculates the partial inverse of the ``absolute_error`` nonconformity\n\tfunction, i.e., the minimum and maximum boundaries of the prediction\n\tinterval for each point prediction, given a significance level.\n\n\tParameters\n\t----------\n\tprediction : numpy array of shape [n_samples]\n\t\tPoint (regression) predictions of a test examples.\n\n\tnc : numpy array of shape [n_calibration_samples]\n\t\tNonconformity scores obtained for conformal predictor.\n\n\tsignificance : float\n\t\tSignificance level (0, 1).\n\n\tnorm : numpy array of shape [n_samples]\n\t\tNormalization values for normalized nonconformity.\n\n\tbeta : float\n\t\tBeta parameter for normalized nonconformity. Larger beta reduces\n\t\tinfluence of normalization model.\n\n\tReturns\n\t-------\n\tinterval : numpy array of shape [n_samples, 2]\n\t\tMinimum and maximum interval boundaries for each prediction.\n\t' #NEWLINE# norm = ( np . array ( ( [ 1 ] * prediction . shape [ 0 ] ) ) if ( norm is None ) else norm ) #NEWLINE# beta = ( 0 if ( beta is None ) else beta ) #NEWLINE# nc = np . sort ( nc ) [ : : ( - 1 ) ] #NEWLINE# border = ( int ( np . floor ( ( significance * ( nc . size + 1 ) ) ) ) - 1 ) #NEWLINE# border = min ( max ( border , 0 ) , ( nc . size - 1 ) ) #NEWLINE# return np . vstack ( [ ( prediction - ( nc [ border ] * ( norm + beta ) ) ) , ( prediction + ( nc [ border ] * ( norm + beta ) ) ) ] ) . T