API reference

This page highlights the main supported entry points without attempting to expose every internal helper in the broad NMFk codebase. Use Julia help mode, for example ?NMFk.execute, for the same source-attached documentation in a REPL.

Result and configuration types

NMFk.ExecuteOptions — Type
ExecuteOptions

Configuration container for NMFk.execute.

This is an additive, backwards-compatible way to avoid very long keyword lists at call sites. The existing keyword-based execute methods remain the primary implementation; these options-based overloads simply forward to them.

source
NMFk.NMFkResult — Type
NMFkResult

Container for results produced by NMFk.execute(X, nk, nNMF; ...).

The core factorization outputs are stored in W and H, along with common quality metrics (fit, robustness, aic). Additional run configuration is captured for provenance.

source

Factorization and persistence

NMFk.execute — Function

Execute NMFk analysis for a range of number of signals (options overload)

source

Execute NMFk analysis for a given number of signals (options overload)

source

Execute NMFk analysis for a range of number of signals

source

Execute NMFk analysis for a given number of signals

source

Data checks and preprocessing

The grid-data manual documents the current NMFk.griddata methods. Additional validation helpers, including NMFk.checkmatrix, retain legacy generated help text and can be inspected in Julia help mode while their static docstrings are modernized incrementally.

Structure-aware information

NMFk.structure_information — Function

structureinformation(tensor; validmask=trues(size(tensor)), bins=16, temporaldim=ndims(tensor), residualcoding=:shannon, computespectral=true, quantization=:linear, lagoffsets=nothing, lagsign=:canonical, dimensionnames=nothing, dimensionsteps=nothing, dimensionunits=nothing, dimension_roles=nothing)

Measure information that depends on tensor structure rather than only on flattened cell weights.

Values are quantized globally before cells at the requested integer lag_offsets are compared. nothing preserves the original positive unit-axis comparisons. In canonical mode, opposite purely spatial directions are equivalent and every temporal offset points forward. Use lag_sign=:directed to retain input signs.

The default quantization=:linear preserves the original global linear bins. Use quantization=:zero_preserving for nonnegative sparse count or mass fields when exact zeros must remain distinct from every positive cell; the remaining bins are assigned linearly across the positive values. Negative valid values are rejected in this mode so symbol order and prediction residuals remain monotone.

The returned axis_information reports mutual information, conditional entropy, normalized variation, and predictive-residual entropy along every axis. The temporal axis uses the same inter-frame residual principle as lossless movie compression.

spectral_information reports entropy and effective rank of every tensor unfolding.

residual_coding selects fixed-width residuals (:none), the ideal Shannon limit (:shannon), or a realizable binary Huffman code (:huffman).

Coding results are reported as residual_coding within each entry of axis_information.

lag_information reports arbitrary axis-aligned, diagonal, or mixed space-time offsets. Existing axis_information and top-level summaries always remain based on positive unit-axis offsets for backward compatibility.

Use explicit dimension_roles, such as (:horizontal, :horizontal, :depth, :temporal), to prevent a depth axis from being averaged into the legacy horizontal spatial summary.

Set compute_spectral=false for tensors whose unfoldings are too large for SVD.

source
NMFk.aggregate_lag_information — Function

aggregatelaginformation(information; lagoffsets=nothing, minimumpaircount=1, requirecomplete_shells=true)

Summarize arbitrary directional lags without letting the number of sampled directions determine the result. Directions are averaged equally within sign-invariant grid-distance shells, shells are averaged equally within each spatial, temporal, depth, or mixed family, and families are reported separately.

lag_offsets can restrict the summary to an explicitly comparable support. With require_complete_shells=true, the default, an entire requested shell is excluded if any of its directions lacks the minimum pair support. Unavailable lags are never treated as zero. Residual coding also reports the exact pooled savings obtained from summed encoded and fixed-width bit counts. These values describe cell-relative structure and compressibility, not the fraction of raw information preserved by gridding.

source
NMFk.compare_lag_information — Function

comparelaginformation(informationsteps; minimumpaircount=1, requirecomplete_shells=true)

Build comparable lag-structure profiles for several tensor discretizations. Only offsets applicable in every tensor are eligible. With require_complete_shells=true, the entire direction shell is removed whenever any intended direction in that shell is unavailable in any tensor. This is the recommended mode for comparing grids with different axis lengths.

source
NMFk.optimize_binning_information — Function

optimizebinninginformation(gridcellcounts, retentionmetrics, labels; primarymetric=first(keys(retentionmetrics)), minimumretentions=NamedTuple(), retentiontargets=[0.8, 0.9, 0.95], nearbestfractions=[0.9, 0.95, 0.99], cellbudgets=Int[], constraintmetrics=nothing, kneeminimum_score=0.05)

Compare candidate binning schemes without hiding the preservation/cost trade-off inside an arbitrary weighted score. The primary result is the Pareto frontier. Optional epsilon constraints select the least expensive scheme meeting explicit retention requirements. Target, budget, near-best, maximum-retention, and normalized log-cost knee choices are returned as separately labeled policies.

The knee is an exploratory candidate-set-dependent heuristic, not a unique physical optimum. near_best_fractions require every selected constraint metric to retain the requested fraction of that metric's best observed value. Targets apply only to primary_metric; cell budgets maximize balanced relative retention across constraint_metrics. knee_minimum_score is the minimum normalized perpendicular distance required to call a knee pronounced.

source
NMFk.rawdata_information — Function

rawdatainformation(data; precisions, origins=nothing, statefeatures=keys(data), ...)

Measure the empirical information in unbinned observation records. data is a named tuple of equal-length feature vectors. Numeric and date/time features are quantized on fixed, origin-anchored lattices; pass precision=nothing for an already discrete or categorical feature.

The joint state_entropy_bits is computed from state_features, not by adding their marginal entropies. Optional nonnegative weights define observation probabilities. Prediction residuals are computed separately for each ordered numeric/date feature and never from arbitrary joint-state identifiers.

source
NMFk.compare_rawdata_grid — Function

comparerawdatagrid(rawinformation, gridassignments; gridcellcount=nothing)

Compare paired raw observation states with their grid assignments. The retained empirical state distinguishability is mutual information I(raw; grid) and the merging loss is conditional entropy H(raw | grid). This is an observed-support collision measure, not physical reconstruction or numeric precision loss. mapping_uncertainty_bits = H(grid | raw) accompanies an exact observed-support mapping-conflict diagnostic.

source

Visualization and notebooks

NMFk.mapbox_contour — Function

mapbox_contour(lon, lat, values; resolution=50, power=2, smoothing=0.0, filename="", kw...)

Create GeoJSON-based continuous contour heatmap using IDW (Inverse Distance Weighting) interpolation.

Arguments

  • preset::Symbol=:balanced: Preset tuning for large datasets. Supported: :fast, :balanced, :quality
  • lon::AbstractVector: Vector of longitude coordinates
  • lat::AbstractVector: Vector of latitude coordinates
  • values::AbstractVector: Vector of values to interpolate
  • resolution::Int=50: Grid resolution for interpolation (higher = smoother but slower)
  • max_features::Int=50000: Maximum number of GeoJSON tiles to emit; resolution is auto-reduced to stay within this limit
  • hover_max_features::Int=5000: Disable hover tooltips for the interpolated layer when the number of tiles exceeds this threshold (0 disables hover always)
  • neighbors::Int=0: Use KNN-IDW interpolation with this many neighbors (0 = auto for large datasets)
  • power::Real=2: IDW power parameter (higher = more localized interpolation)
  • smoothing::Real=0.0: Smoothing parameter for interpolation
  • contour_levels::Int=10: Number of contour levels
  • filename::AbstractString="": Output filename for saving the plot
  • title::AbstractString="": Plot title
  • title_colorbar::AbstractString=title: Colorbar title
  • title_length::Number=0: Non-breaking space padding inserted ahead of the colorbar title to widen the right margin
  • colorscale::Symbol=:turbo: Color scale for the heatmap
  • opacity::Real=0.7: Opacity of the contour layer
  • colorbar_bgcolor::AbstractString="#5a5a5a": Background color for the colorbar
  • colorbar_font_color::AbstractString="white": Color for colorbar title and tick labels
  • colorbar_font_family::AbstractString="Arial": Base font family for colorbar text
  • colorbar_font_bold::Bool=true: Whether to render colorbar title/tick labels in bold
  • colorbar_font_size::Number=font_size: Font size for the colorbar title and ticks
  • paper_bgcolor::AbstractString=colorbar_bgcolor: Canvas background color for the plot
  • show_points::Bool=false: Whether to show original data points
  • concave_hull::Bool=true: If true, derive extent/masking from a ConcaveHull envelope
  • hull_padding::Real=0.02: Fractional padding applied to the concave hull shape itself
  • extra_margin::Real=0.0: Absolute degree margin added radially outside the hull
  • hull_max_points::Int=10000: If the point set is larger, thin points before hull computation (grid-based) for speed
  • hull_grid_bins::Int=0: Optional fixed number of grid bins used for hull thinning (0 = auto from hull_max_points)
  • hull_force_convex_above::Int=200000: If the point set exceeds this size, skip concave hull and use convex hull
  • hull_concave_max_points::Int=12000: Safety cap for ConcaveHull input size; concave hull is computed on a thinned subset when needed
  • hull_mode::Symbol=:direct: Hull strategy. :direct runs concave hull on a thinned point set; :stepwise runs convex hull first, then keeps only points near the hull boundary before concave hull
  • hull_stepwise_max_points::Int=20000: Maximum points to pass to the stepwise concave hull stage (closest-to-boundary points are kept)
  • hull_stepwise_min_points::Int=5000: Minimum points to pass to the stepwise concave hull stage (if the distance threshold yields fewer, the closest-to-boundary points are used instead)
  • hull_stepwise_buffer_cells::Real=2.5: How far from the fast hull boundary (in "grid cell" units) a point must be to be included in the stepwise subset
  • hull_stepwise_passes::Int=2: Number of stepwise refinement passes (pass 1 uses convex hull; later passes refine using the previously computed hull)
  • show_locations::Bool=false: Display input locations as colored circular markers
  • location_color::AbstractString="purple": Marker color used for the location circles
  • location_size::Number=10: Marker diameter for the location circles
  • location_names_above::AbstractVector=String[]: Optional labels plotted above each location marker
  • location_names_below::AbstractVector=String[]: Optional labels plotted below each location marker
  • show_hull::Bool=false: Overlay the computed hull polygon for debugging
  • hull_color::AbstractString="magenta": Hull trace color when show_hull=true
  • hull_line_width::Number=3: Line width for the hull outline
  • hull_opacity::Real=0.35: Opacity applied to the hull trace
  • kw...: Additional keyword arguments passed to the mapbox function

Debugging

  • progress::Bool=false: If true, prints stage-by-stage timing/progress information to help diagnose slowdowns
  • progress_every::Int=0: Row stride for progress logs (0 = auto)

Example

lon = [-105.0, -104.5, -104.0, -103.5]
lat = [35.5, 36.0, 36.5, 37.0]
values = [10.0, 15.0, 20.0, 25.0]
p = mapbox_contour(lon, lat, values; resolution=100, power=2, filename="contour_map.html")
source
mapbox_contour(df, column; kw...)

Create GeoJSON-based continuous contour heatmap from a DataFrame using IDW interpolation.

Arguments

  • df::DataFrames.DataFrame: DataFrame containing longitude, latitude, and value columns
  • column::Union{Symbol, AbstractString}: Column name containing values to interpolate
  • kw...: Additional keyword arguments passed to mapbox_contour

Returns

  • PlotlyJS plot object with contour heatmap overlay

Example

df = DataFrames.DataFrame(
	lon=[-105.0, -104.5, -104.0, -103.5],
	lat=[35.5, 36.0, 36.5, 37.0],
	temperature=[10.0, 15.0, 20.0, 25.0]
)
p = mapbox_contour(df, :temperature; resolution=100, filename="temp_contour.html")
source

See the Mapbox manual, the README visualization example, and the notebooks directory for the broader legacy plotting and notebook interfaces.