TransformAnomalies
TransformAnomalies[data,tspec]
transforms anomalies in data using the transformation tspec.
TransformAnomalies[data,dspectspec]
detects the anomalies using the specification dspec.
TransformAnomalies[tab,{col1spec1,…}]
transforms tabular data tab using the specification speci for column coli.
Details
- TransformAnomalies is also known as anomaly detection or outlier treatment.
- TransformAnomalies helps maintain data quality by effectively identifying and managing anomalies, ensuring reliable analysis.
- Possible forms of data include:
-
{el1,el2,…} a list of indivudual elements tab tabular data - Possible forms of tabular data tab include:
-
Tabular a tabular object Dataset a dataset object {assoc1,assoc2,…} a list of associations matrix a matrix - Possible transformations tspec for managing the anomalies include:
-
"Clip" limit extreme values to non-anomalies range "Replace" replace anomalies with a calculated value {"Replace",method} replace anomalies using method "Trim" drop the anomalous elements "Flag" replace anomalies with Missing["Anomalous"] tfun use the function tfun to transform the anomalies - Possible "Replace" methods are the same as in TransformMissing:
-
" Mean" the mean value "Median" the median value "Mode" the most frequent value {"Constant", val} a constant value val "RandomElement" randomly selected value {"RandomVariate",dist} value sampled from dist "NearestElement" use the closest non-missing element "NextElement" use the next non-missing element "PreviousElement" use the previous non-missing element "Interpolation" use interpolation {"Interpolation",InterpolationOrderdegree} specify the interpolation order degree - Excluding the anomalies minimizes their influence on analysis. Clipping or replacing minimizes the impact of anomalies while preserving the dataset's structure. Flagging allows keeping all data points for further analysis while highlighting anomalies for review.
- Available methods dspec to detect the anomalies include:
-
"IQR" interquartile range thresholds "ZScore" standard deviations from the mean "ModifiedZScore" robust version using median and MAD {spec,t} specifies the threshold t for anomaly detection {spec,{t1,t2}} specifies the lower and upper thresholds - Additionally, the following specifications are supported:
-
Scaled[f] a fraction f of the smallest and largest elements Scaled[{f1,f2}] separate thresholds for smallest and largest elements dfun a custom function fun - A custom anomaly detector dfun is applied to each element individually and must return a Boolean value.
- When specifying the desired columns, coli can have the following format:
-
n the n column "name" the column "name" TypeSpecifier[…] columns matching the specified type All all the columns Automatic automatically find columns based on spec (default)
Examples
open allclose allBasic Examples (2)
Scope (15)
Data Types (4)
Detection Methods (6)
Transformation Methods (5)
Clip the anomalies with the closest valid value:
Replace the anomalies with missing elements:
Apply any TransformMissing specification:
Text
Wolfram Research (2025), TransformAnomalies, Wolfram Language function, https://reference.wolfram.com/language/ref/TransformAnomalies.html.
CMS
Wolfram Language. 2025. "TransformAnomalies." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TransformAnomalies.html.
APA
Wolfram Language. (2025). TransformAnomalies. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TransformAnomalies.html