For the complete documentation index, see llms.txt. This page is also available as Markdown.

Analysis

DataVec data analysis tools — profiling datasets, detecting quality issues, and computing statistics locally and on Spark

Before transforming data, it helps to understand what you are working with. DataVec provides analysis tools that scan a dataset and return per-column statistics: type distribution, missing value counts, histograms, min/max, mean, and standard deviation. The same API works locally (via a RecordReader) and at scale (via Apache Spark).

Local analysis

AnalyzeLocal scans data through a RecordReader and returns a DataAnalysis object.

import org.datavec.local.transforms.AnalyzeLocal;
import org.datavec.api.records.reader.impl.csv.CSVRecordReader;
import org.datavec.api.split.FileSplit;
import org.datavec.api.transform.analysis.DataAnalysis;
import org.datavec.api.transform.analysis.DataQualityAnalysis;

Schema schema = new Schema.Builder()
    .addColumnString("Name")
    .addColumnDouble("Score")
    .addColumnInteger("Age")
    .build();

RecordReader rr = new CSVRecordReader(1, ',');
rr.initialize(new FileSplit(new File("data.csv")));

int maxHistogramBuckets = 10;
DataAnalysis analysis = AnalyzeLocal.analyze(schema, rr, maxHistogramBuckets);
System.out.println(analysis);

Quality analysis

Quality analysis reports missing values, values that cannot be parsed according to the schema, and values that violate column metadata constraints.

For sequence data:

AnalyzeLocal API

source


Spark analysis

AnalyzeSpark mirrors the local API but operates on JavaRDD<List<Writable>> datasets already loaded into Apache Spark. It also adds methods for sampling individual column values.

Extracting min and max

Sampling values

AnalyzeSpark API

source


Analysis result types

DataAnalysis

Contains a ColumnAnalysis entry for each column in the schema.

ColumnAnalysis implementations

Class
Applies to

IntegerAnalysis

Integer columns

LongAnalysis

Long columns

DoubleAnalysis

Double/float columns

StringAnalysis

String columns

CategoricalAnalysis

Categorical columns

TimeAnalysis

Time columns

BytesAnalysis

Binary (bytes) columns

NDArrayAnalysis

NDArray columns

Each numeric analysis includes: count, min, max, mean, standard deviation, and a histogram. String and categorical analyses include count, unique-value count, and length statistics.

DataQualityAnalysis

Reports data quality per column.

SequenceDataAnalysis

In addition to per-column statistics, reports sequence-level information: min/max/mean sequence length, and histogram of sequence lengths.


Workflow: analyze then transform

A common pattern is to analyze the data first, then use the results to configure a TransformProcess.

The normalize builder method accepts a DataAnalysis directly, extracting the per-column statistics needed to apply min-max or standardize normalization inline within a transform pipeline.

Last updated

Was this helpful?