Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

datarust-profile

One-call data profiling and data-quality reports for the datarust ecosystem.

crates.io docs.rs CI License: MIT

#![allow(unused)]
fn main() {
use datarust::Matrix;
use datarust_profile::{profile_matrix, report};

let m = Matrix::from_rows(vec![
    vec![1.0, 10.0],
    vec![2.0, 12.0],
    vec![3.0, f64::NAN], // missing income in row 3
])?;

let profile = profile_matrix(&m, Some(&["age".into(), "income".into()]))?;
println!("{}x{}, {} duplicate rows",
    profile.n_rows, profile.n_columns, profile.duplicate_rows);

// Self-contained HTML report — no dependencies, no JavaScript.
std::fs::write("profile.html", report::to_html(&profile))?;
}

Default build has zero external dependencies beyond datarust itself. Statistics flow through datarust::stats; the profiling crate owns the interpretation (summaries, quality flags, reports). JSON output is opt-in via the serde feature.


What it computes

For each column, depending on its inferred type:

NumericCategorical
count, missing_count, missing_fractioncount, missing_count, missing_fraction
mean, std (sample, ddof = 1)unique (cardinality)
five-number summary: min / Q1 / median / Q3 / maxtop (most frequent value)
skewness, kurtosis (excess, Fisher)freq (count of top)
histogram (equal-width, Sturges bins)imbalance_ratio (freq / present)
outlier_count, outlier_fraction (IQR rule)top_values (top-N value/count pairs)

Pairwise Relationships (Relationships block):

  • Pearson correlation matrix over numeric columns (CorrelationMatrix).
  • Cramér’s V matrix over categorical columns (pure-Rust χ² association).
  • Point-biserial correlation between binary categorical and numeric columns (PointBiserialEntry).

Dataset-wide: n_rows, n_columns, estimated memory_bytes, exact duplicate_rows and duplicate_fraction, optional target_column.

Data-quality findings

quality::run_checks scans the profile against configurable Thresholds and emits QualityIssues across 8 categories:

  • HighMissing — missing fraction at/above threshold.
  • ConstantColumn — numeric column with near-zero variance.
  • NearUnique — categorical column whose cardinality ≈ row count (likely an identifier).
  • DuplicateRows — exact-duplicate rows present.
  • Outliers — values outside Tukey IQR fences.
  • Imbalance — categorical column dominated by a single value.
  • HighCorrelation — pair of numeric columns exceeding correlation threshold (|r| >= 0.95).
  • TargetLeakage — feature column strongly correlated (|r| >= 0.90 or V >= 0.90) with designated target column.

Each finding carries a Severity (Info / Warning / Critical) and an optional column name. The HTML and JSON renderers include findings and correlation heatmaps by default.

Output formats

FormatFeatureNotes
HTMLSingle self-contained .html, inline CSS, no JS.
JSONserdePretty-printed; schema mirrors the in-memory types.
#![allow(unused)]
fn main() {
#[cfg(feature = "serde")]
{
    use datarust_profile::report::{to_json, JsonReport};
    let json = to_json(&JsonReport::from_profile(&profile))?;
    std::fs::write("profile.json", json)?;
}
}

Relationship to datarust

datarust-profile is a sibling crate in the datarust workspace. It reuses datarust’s Matrix / StrMatrix containers and its stats module (mean, std, quantile, median_sorted) rather than reimplementing them. Column-type inference, missing-value handling, cardinality counting, and the report renderers live in this crate.

Next steps

  • New to profiling? Start with the Quick Start.
  • Want the full API surface? It’s on docs.rs.