PredictorMeasurements
✖
PredictorMeasurements
gives measurements associated with the property prop when predictor is evaluated on testset.
yields a measurement report that can be applied to any property.
Details and Options




- Measurements are used to determine the performance of a classifier on data that was not used for training purposes (the test set).
- Possible measurements include classification metrics (accuracy, likelihood, etc.), visualizations (confusion matrix, ROC curve, etc.) or specific examples (such as the worst classified examples).
- The predictor is typically a PredictorFunction object as generated by Predict.
- In PredictorMeasurements[data,…], the predictions data can have the following forms:
-
{y1,y2,…} predictions from a predictor (human, algorithm, etc.) {dist1,dist2,…} predictive distributions obtained by a predictor - PredictorMeasurements[…,opts] specifies that the predictor should use the options opts when applied to the test set. Possible options are as given in PredictorFunction.
- PredictorMeasurements[predictor,testset] returns a PredictorMeasurementsObject[…] that displays as a report panel, such as:
-
- PredictorMeasurementsObject[…][prop] can be used to look up prop from a PredictorMeasurementsObject. When repeated property lookups are required, this is typically more efficient than using PredictorMeasurements every time.
- PredictorMeasurementsObject[…][prop,opts] specifies that the predictor should use the options opts when applied to the test set. These options supersede original options given to PredictorMeasurements.
- PredictorMeasurements has the same options as PredictorFunction[…], with the following additions:
-
Weights Automatic weights to be associated with test set examples ComputeUncertainty False whether measures should be given with their statistical uncertainty - When ComputeUncertaintyTrue, numerical measures will be returned as Around[result,err], where err represents the standard error (corresponding to a 68% confidence interval) associated with measure result.
- Possible settings for Weights include:
-
Automatic associates weight 1 with all test examples {w1,w2,…} associates weight wi with the i test examples
- Changing the weight of a test example from 1 to 2 is equivalent to duplicating the example.
- Weights affect measures as well as their uncertainties.
- Properties returning a single numeric value related to prediction abilities on the test set include:
-
"StandardDeviation" root mean square of the residuals "StandardDeviationBaseline" standard deviation of test set values "LogLikelihood" log-likelihood of the model given the test data "MeanCrossEntropy" mean cross entropy over test examples "MeanDeviation" mean absolute value of the residuals "MeanSquare" mean square of the residuals "RSquared" coefficient of determination "FractionVarianceUnexplained" fraction of variance unexplained "Perplexity" exponential of the mean cross entropy "RejectionRate" fraction of examples predicted as Indeterminate "GeometricMeanProbabilityDensity" geometric mean of the actual-class probability densities - Test examples classified as Indeterminate will be discarded when measuring properties related to prediction abilities on the test set, such as "StandardDeviation" or "MeanCrossEntropy".
- Properties returning graphics include:
-
"ComparisonPlot" plot of predicted values versus test values "ICEPlots" Individual Conditional Expectation (ICE) plots "ProbabilityDensityHistogram" histogram of actual-class probability densities "Report" panel reporting main measurements "ResidualHistogram" histogram of residuals "ResidualPlot" plot of the residuals "SHAPPlots" Shapley additive feature explanations plot for each class - Timing-related properties include:
-
"EvaluationTime" time needed to predict one example of the test set "BatchEvaluationTime" marginal time to predict one example in a batch - Properties returning one value for each test-set example include:
-
"Residuals" list of differences between predicted and test values "ProbabilityDensities" actual-class prediction probability densities "SHAPValues" Shapley additive feature explanations for each example - "SHAPValues" assesses the contribution of features by comparing predictions with different sets of features removed and then synthesized. The option MissingValueSynthesis can be used to specify how the missing features are synthesized. SHAP explanations are given as deviation from the training output mean. "SHAPValues"n can be used to control the number of samples used for the numeric estimations of SHAP explanations.
- Properties returning examples from the test set include:
-
"BestPredictedExamples" examples having the highest actual-class probability density "Examples" all test examples "Examples"{i1,i2} all examples in the interval i1 predicted in the interval i2 "LeastCertainExamples" examples having the highest distribution entropy "MostCertainExamples" examples having the lowest distribution entropy "WorstPredictedExamples" examples having the lowest actual-class probability density - Examples are given in the form inputivaluei, where valuei is the actual value.
- Properties such as "WorstPredictedExamples" or "MostCertainExamples" output up to 10 examples. PredictorMeasurementsObject[…][propn] can be used to output n examples.
- Other properties include:
-
"PredictorFunction" PredictorFunction[…] being measured "Properties" list of measurement properties available
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Train a predictor on a training set:

https://wolfram.com/xid/0fq5rt0583bcj-cgrfnb


https://wolfram.com/xid/0fq5rt0583bcj-zefo51
Measure the standard deviation of the predictor on the test set:

https://wolfram.com/xid/0fq5rt0583bcj-4svu8i


https://wolfram.com/xid/0fq5rt0583bcj-ianu4o

Visualize a scatter plot of the actual and predicted values:

https://wolfram.com/xid/0fq5rt0583bcj-k7fr3n

Measure several properties at once:

https://wolfram.com/xid/0fq5rt0583bcj-ow3v5p

Train a predictor on a training set:

https://wolfram.com/xid/0fq5rt0583bcj-btpoj7

Generate a measurement object of the predictor on the test set:

https://wolfram.com/xid/0fq5rt0583bcj-njqae6

Obtain the list of measurement properties available:

https://wolfram.com/xid/0fq5rt0583bcj-mmkv1w

Measure the standard deviation of the predictor on the test set:

https://wolfram.com/xid/0fq5rt0583bcj-iwve7t

Obtain the standard deviation along with its statistical uncertainty due to finite test-set size:

https://wolfram.com/xid/0fq5rt0583bcj-eo6qwz


https://wolfram.com/xid/0fq5rt0583bcj-xvbf6j

Measure the standard deviation directly from classified examples:

https://wolfram.com/xid/0fq5rt0583bcj-zlbna9


https://wolfram.com/xid/0fq5rt0583bcj-ilqudd

https://wolfram.com/xid/0fq5rt0583bcj-prvy29
Measure the log-likelihood from predictive distributions:

https://wolfram.com/xid/0fq5rt0583bcj-dtmenz

Scope (3)Survey of the scope of standard use cases
Residual-Based Metrics (1)
Visualize the residuals of predicted examples against their true values:

https://wolfram.com/xid/0fq5rt0583bcj-mdxba4

Measure the standard deviation:

https://wolfram.com/xid/0fq5rt0583bcj-cw1rai

This is equivalent to computing the root mean square of the residuals:

https://wolfram.com/xid/0fq5rt0583bcj-pgeez2

Obtain the statistical uncertainty on this measure:

https://wolfram.com/xid/0fq5rt0583bcj-1j8guf

Compare the standard deviation to a baseline (always predicting the mean of the test-set values):

https://wolfram.com/xid/0fq5rt0583bcj-hzxbnj


https://wolfram.com/xid/0fq5rt0583bcj-rizj8d

This is equivalent to the proportion of variance that is explained:

https://wolfram.com/xid/0fq5rt0583bcj-0t654v

Measure the fraction of variance unexplained:

https://wolfram.com/xid/0fq5rt0583bcj-pa2e0g


https://wolfram.com/xid/0fq5rt0583bcj-tbd8d3

Comparison Plot and Example Extraction (1)
Create a training set and a test set on the Boston homes data:

https://wolfram.com/xid/0fq5rt0583bcj-pyoo4i

https://wolfram.com/xid/0fq5rt0583bcj-7aoe1o

Train a model on the training set:

https://wolfram.com/xid/0fq5rt0583bcj-21d6pb

Create a classifier measurements object for this classifier on the test set:

https://wolfram.com/xid/0fq5rt0583bcj-4q52n7

Find the two test examples that have the worst predictions:

https://wolfram.com/xid/0fq5rt0583bcj-rpwh8c


https://wolfram.com/xid/0fq5rt0583bcj-uvq0w0

Find the two test examples that have the best predictions:

https://wolfram.com/xid/0fq5rt0583bcj-vpr8tw


https://wolfram.com/xid/0fq5rt0583bcj-y48qyk

Compare the predicted and correct values:

https://wolfram.com/xid/0fq5rt0583bcj-ujsxrz

Extract the examples whose true values are between 30 and 40 and whose predictions are between 40 and 50:

https://wolfram.com/xid/0fq5rt0583bcj-dtzgm1

Probabilistic Metrics (1)
Create and visualize an artificial dataset from the expression Cos[x*y]:

https://wolfram.com/xid/0fq5rt0583bcj-j0yb8r


https://wolfram.com/xid/0fq5rt0583bcj-lpxlmd

https://wolfram.com/xid/0fq5rt0583bcj-gpi61p

Split the dataset into a training set and a test set:

https://wolfram.com/xid/0fq5rt0583bcj-jxalvz
Train a predictor on the training set:

https://wolfram.com/xid/0fq5rt0583bcj-pvobk1

Measure the log-likelihood of the test set (total log-PDF of actual value):

https://wolfram.com/xid/0fq5rt0583bcj-i8c4e6

Measure the mean cross-entropy:

https://wolfram.com/xid/0fq5rt0583bcj-wlydgl

The mean cross-entropy is the average negative log-likelihood:

https://wolfram.com/xid/0fq5rt0583bcj-z09nmu

Options (5)Common values & functionality for each option
IndeterminateThreshold (1)
Create an artificial dataset and visualize it:

https://wolfram.com/xid/0fq5rt0583bcj-80hqll

https://wolfram.com/xid/0fq5rt0583bcj-3mw01s

Split the dataset into a training set and a test set:

https://wolfram.com/xid/0fq5rt0583bcj-ltivz7
Train a predictor on the training set:

https://wolfram.com/xid/0fq5rt0583bcj-07q9td

Plot the predicted distribution for a few feature values:

https://wolfram.com/xid/0fq5rt0583bcj-eqpzvo

Compute the root mean square of the residuals:

https://wolfram.com/xid/0fq5rt0583bcj-dkyl33

Perform the same computation with a different threshold value for the predictor:

https://wolfram.com/xid/0fq5rt0583bcj-670wy6

This operation can also be done on the PredictorMeasurementsObject:

https://wolfram.com/xid/0fq5rt0583bcj-vlbmy9


https://wolfram.com/xid/0fq5rt0583bcj-nthx6z

Plot the standard deviation and the rejection rate as a function of the threshold:

https://wolfram.com/xid/0fq5rt0583bcj-tz4f79


https://wolfram.com/xid/0fq5rt0583bcj-o8xjwj

TargetDevice (1)
Train a predictor using a neural network:

https://wolfram.com/xid/0fq5rt0583bcj-gnlysk
Measure the standard deviation of the predictor on a test set for different setting of TargetDevice:

https://wolfram.com/xid/0fq5rt0583bcj-4fgmey

https://wolfram.com/xid/0fq5rt0583bcj-dqg5pp

https://wolfram.com/xid/0fq5rt0583bcj-osicmu
UtilityFunction (1)
Define a training and a test set:

https://wolfram.com/xid/0fq5rt0583bcj-d5e35w

https://wolfram.com/xid/0fq5rt0583bcj-c1yd0z
Train a predictor on the training set:

https://wolfram.com/xid/0fq5rt0583bcj-fg10uw

Define and visualize a utility function that penalizes the predicted value's being smaller than the actual value:

https://wolfram.com/xid/0fq5rt0583bcj-0p1sgu

https://wolfram.com/xid/0fq5rt0583bcj-ygfxmi

Compute the residuals of the predictor on the test set with this utility function:

https://wolfram.com/xid/0fq5rt0583bcj-ynz2ar

The residuals with the default utility function are higher:

https://wolfram.com/xid/0fq5rt0583bcj-m2orow

The utility function can also be specified when using the PredictorMeasurementsObject:

https://wolfram.com/xid/0fq5rt0583bcj-qg0op0


https://wolfram.com/xid/0fq5rt0583bcj-5j54kc

"Uncertainty" (1)
Train a predictor on the "WineQuality" dataset:

https://wolfram.com/xid/0fq5rt0583bcj-nfgpho

https://wolfram.com/xid/0fq5rt0583bcj-xxoqad

Generate a PredictorMeasurements[…] object using a test set:

https://wolfram.com/xid/0fq5rt0583bcj-vpffp

https://wolfram.com/xid/0fq5rt0583bcj-72st1s

Obtain a measure of the standard deviation along with its uncertainty:

https://wolfram.com/xid/0fq5rt0583bcj-6iopsc

Obtain a measure of other properties along with their uncertainties:

https://wolfram.com/xid/0fq5rt0583bcj-mat67g

Weights (1)
Create a predictor on a training set:

https://wolfram.com/xid/0fq5rt0583bcj-undf2n

Generate a measurement object while specifying the weights that each test example has:

https://wolfram.com/xid/0fq5rt0583bcj-u0r98b

Compute the standard deviation:

https://wolfram.com/xid/0fq5rt0583bcj-ttvh6t

Weights can also be modified when using the measurement object:

https://wolfram.com/xid/0fq5rt0583bcj-4oromz

Uncertainties are also affected by weights:

https://wolfram.com/xid/0fq5rt0583bcj-us8urh


https://wolfram.com/xid/0fq5rt0583bcj-yyigru

Applications (2)Sample problems that can be solved with this function
Load a dataset of the average monthly temperature as a function of the city, the year and the month:

https://wolfram.com/xid/0fq5rt0583bcj-38fkv

https://wolfram.com/xid/0fq5rt0583bcj-lw5ujc

Split the dataset into a training set and a test set:

https://wolfram.com/xid/0fq5rt0583bcj-txgfzg

https://wolfram.com/xid/0fq5rt0583bcj-0qu7d1
Train a predictor on the training set:

https://wolfram.com/xid/0fq5rt0583bcj-oinmn3

Generate a PredictorMeasurementsObject from the predictor and the test set:

https://wolfram.com/xid/0fq5rt0583bcj-c0qrii

Compute the mean cross entropy of the classifier on the test set:

https://wolfram.com/xid/0fq5rt0583bcj-fn1wqz

Visualize the scatter plot of the test values as a function of the predicted values:

https://wolfram.com/xid/0fq5rt0583bcj-8zeap

Extract the test examples that are in a given region of the comparison plot:

https://wolfram.com/xid/0fq5rt0583bcj-1mu2vg

Extract the 20 worst predicted examples:

https://wolfram.com/xid/0fq5rt0583bcj-9hbb76

Train a predictor that predicts the median value of properties in a neighborhood of Boston, given some features of the neighborhood:

https://wolfram.com/xid/0fq5rt0583bcj-cs8a11

Generate a predictor measurements object to analyze the performance of the predictor on a test set:

https://wolfram.com/xid/0fq5rt0583bcj-fiomr4


https://wolfram.com/xid/0fq5rt0583bcj-47j7fi

Plot a histogram of the residuals:

https://wolfram.com/xid/0fq5rt0583bcj-oh305

Compute the standard deviation of the predicted values from the actual values (root mean square of the residuals):

https://wolfram.com/xid/0fq5rt0583bcj-lxrlde

Obtain the statistical uncertainty of the above measure:

https://wolfram.com/xid/0fq5rt0583bcj-sd02k8

Wolfram Research (2014), PredictorMeasurements, Wolfram Language function, https://reference.wolfram.com/language/ref/PredictorMeasurements.html (updated 2021).
Text
Wolfram Research (2014), PredictorMeasurements, Wolfram Language function, https://reference.wolfram.com/language/ref/PredictorMeasurements.html (updated 2021).
Wolfram Research (2014), PredictorMeasurements, Wolfram Language function, https://reference.wolfram.com/language/ref/PredictorMeasurements.html (updated 2021).
CMS
Wolfram Language. 2014. "PredictorMeasurements." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/PredictorMeasurements.html.
Wolfram Language. 2014. "PredictorMeasurements." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/PredictorMeasurements.html.
APA
Wolfram Language. (2014). PredictorMeasurements. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PredictorMeasurements.html
Wolfram Language. (2014). PredictorMeasurements. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PredictorMeasurements.html
BibTeX
@misc{reference.wolfram_2025_predictormeasurements, author="Wolfram Research", title="{PredictorMeasurements}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/PredictorMeasurements.html}", note=[Accessed: 16-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_predictormeasurements, organization={Wolfram Research}, title={PredictorMeasurements}, year={2021}, url={https://reference.wolfram.com/language/ref/PredictorMeasurements.html}, note=[Accessed: 16-April-2025
]}