Profile data and plot the evidence
Capture bounded diagnostics during loading and build native figures from the cached report.
// Twelve synthetic observations: teaching data, not measured research evidence.
// Run from the repository root. No Python runtime or map packs are needed.
import aner.data
import aner.plot
import aner.units
var schema = data.schema()
schema = schema.column("row_id", "Int64", false)
schema = schema.column("RecordedAt", "DateTime", false)
schema = schema.unit_column("Temperature_DegC", "degC", true)
schema = schema.unit_column("Distance_cm", "cm", false)
schema = schema.column("signal", "Float64", true)
schema = schema.column("cohort", "String", false)
schema = schema.column("active", "Bool", false)
schema = schema.column("note", "String", false)
let source = data.scan_csv("examples/fixtures/data_profiling.csv", schema, "NA")
// Profile and retain the same validated rows in one source pass. This small
// sample bound retains all present values; larger sources disclose sampling.
let table = source.with_profile(sample_rows: 16, max_categories: 16)
.collect(max_rows: 0, max_bytes: 1048576, batch_rows: 3)
let report = table.profile()
print("Profile attached to a complete immutable table")
print(table.has_profile() && report.is_profile() && report.complete() && report.origin_complete())
print(table.rows() == 12 && report.rows() == 12 && report.scanned_rows() == 12)
print(report.summary())
print("Exact observation ID extrema and nearest-rank 50th percentile")
print(report.minimum_text("row_id"))
print(report.maximum_text("row_id"))
print(report.quantile_text("row_id", q: 0.5))
print("UTC timestamp bounds preserve exact temporal ordering")
print(report.minimum_text("RecordedAt"))
print(report.maximum_text("RecordedAt"))
print("Missing temperature, observed temperature mean and interval spread")
print(report.missing("Temperature_DegC"))
print(report.unit_mean("Temperature_DegC", "degC"))
print(report.unit_std("Temperature_DegC", "delta_degC"))
print("Exact category diagnostics and Boolean counts")
print(report.distinct_complete("cohort"))
print(report.distinct_count("cohort"))
print(report.true_count("active"))
print(report.false_count("active"))
print("Empty string is present when only NA is the missing token")
print(report.empty_count("note"))
print(report.missing("note"))
// Cached access returns the same report without re-reading CSV or table values.
let cached = table.profile()
print("Cached structured profile retains its population and execution lineage")
print(cached.profile_json() == report.profile_json())
print(cached.provenance() == report.provenance())
// Derived data has its own selected population, recipe and profile. It leaves
// the raw table unchanged; no source CSV is reopened by this snapshot scan.
let warm = table.filter(data.col("Temperature_DegC") >= 30.0@degC)
.select(List("row_id", "Temperature_DegC", "signal", "cohort"))
.with_profile()
.collect(max_rows: 0, max_bytes: 1048576, batch_rows: 2)
print("Source and selected profiles describe different populations")
print(table.rows() == 12 && warm.rows() == 6 && warm.profile().rows() == 6)
print(warm.profile().missing("Temperature_DegC") == 0)
// A small retained sample still keeps exact full-population counts/extrema.
// This is a bounded standalone traversal of the snapshot, not of the CSV.
let sampled = table.scan_table().profile(max_bytes: 1048576, batch_rows: 2,
sample_rows: 4, max_categories: 2)
print("Sampling and category overflow are explicit")
print(!sampled.quantiles_exact("signal"))
print(sampled.sample_count("signal") == 4)
print(!sampled.distinct_complete("cohort"))
print(sampled.missing("signal") == 2 && sampled.maximum_text("signal") == "12")
// A validated prefix is useful for feedback; it is not a complete-file profile.
let prefix = source.bounded(max_scanned_rows: 4, max_read_bytes: 0, timeout_ms: 0)
.profile(max_bytes: 1048576, batch_rows: 2)
print("Prefix profiling preserves its stop reason")
print(!prefix.complete() && prefix.stop_reason() == "scan_rows")
print(prefix.rows() == 4 && prefix.scanned_rows() == 4)
// Reading all rows of a preview snapshot completes that snapshot, while its
// lineage continues to disclose the unread original acquisition tail.
let preview_table = source.with_profile().preview(4, 1048576, 2)
let snapshot_report = preview_table.scan_table().profile(1048576, 2)
print("Complete snapshot profiling retains incomplete acquisition ancestry")
print(snapshot_report.complete() && !snapshot_report.origin_complete())
print(snapshot_report.rows() == 4 && !preview_table.origin_complete())
// Named native adapters carry physical labels, lineage and approximation
// disclosures into ordinary immutable charts. Charts need no scalar loops.
let missingness = plot.missingness(report)
.title("Synthetic sensors: missing observations")
let distribution = plot.distribution(sampled, "signal", bins: 5)
.title("Synthetic signal: bounded sample distribution")
let cohorts = plot.categories(report, "cohort")
.title("Synthetic cohorts: exact observed counts")
let relationship = plot.scatter(table, x: "Distance_cm", y: "Temperature_DegC",
max_points: 12)
.title("Synthetic temperature and distance")
print("Native charts retain structured lineage")
print(missingness.provenance().contains("source_sha256"))
print(relationship.provenance().contains("max_points"))
missingness.show()
distribution.show()
cohorts.show()
relationship.show()
// Archive report.profile_json(), report.provenance(), chart.provenance(), the
// source snapshot and this program with scientific results. See the guide for
// training/held-out separation and limits; a profile does not prove validity.
Make it your experiment.
Use Aner 0.0.5 or newer. Save this program as examples/data_profiling.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/data_profiling.aner
aner run examples/data_profiling.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Requires the native Aner 0.0.5 or newer and VS Code 0.1.48 candidate integration. These APIs require Aner 0.0.5 or newer. Save supplied fixtures in the shown working directory paths. No external service or credentials are required for the included analysis. Save each supplied fixture beneath the exact examples/fixtures path shown in the source and run from the project root.
Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution