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
ExecuteOptionsConfiguration 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.
NMFk.NMFkResult — Type
NMFkResultContainer 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.
NMFk.NMFkSweepResult — Type
NMFkSweepResultContainer for results produced by NMFk.execute(X, nkrange, nNMF; ...).
Factorization and persistence
NMFk.execute — Function
Execute NMFk analysis for a range of number of signals (options overload)
Execute NMFk analysis for a given number of signals (options overload)
Execute NMFk analysis for a range of number of signals
Execute NMFk analysis for a given number of signals
Data checks and preprocessing
NMFk.normalizematrix_col — Function
Normalize matrix (by columns)
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.
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.
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.
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.
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.
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.
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,:qualitylon::AbstractVector: Vector of longitude coordinateslat::AbstractVector: Vector of latitude coordinatesvalues::AbstractVector: Vector of values to interpolateresolution::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 limithover_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 interpolationcontour_levels::Int=10: Number of contour levelsfilename::AbstractString="": Output filename for saving the plottitle::AbstractString="": Plot titletitle_colorbar::AbstractString=title: Colorbar titletitle_length::Number=0: Non-breaking space padding inserted ahead of the colorbar title to widen the right margincolorscale::Symbol=:turbo: Color scale for the heatmapopacity::Real=0.7: Opacity of the contour layercolorbar_bgcolor::AbstractString="#5a5a5a": Background color for the colorbarcolorbar_font_color::AbstractString="white": Color for colorbar title and tick labelscolorbar_font_family::AbstractString="Arial": Base font family for colorbar textcolorbar_font_bold::Bool=true: Whether to render colorbar title/tick labels in boldcolorbar_font_size::Number=font_size: Font size for the colorbar title and tickspaper_bgcolor::AbstractString=colorbar_bgcolor: Canvas background color for the plotshow_points::Bool=false: Whether to show original data pointsconcave_hull::Bool=true: If true, derive extent/masking from a ConcaveHull envelopehull_padding::Real=0.02: Fractional padding applied to the concave hull shape itselfextra_margin::Real=0.0: Absolute degree margin added radially outside the hullhull_max_points::Int=10000: If the point set is larger, thin points before hull computation (grid-based) for speedhull_grid_bins::Int=0: Optional fixed number of grid bins used for hull thinning (0 = auto fromhull_max_points)hull_force_convex_above::Int=200000: If the point set exceeds this size, skip concave hull and use convex hullhull_concave_max_points::Int=12000: Safety cap for ConcaveHull input size; concave hull is computed on a thinned subset when neededhull_mode::Symbol=:direct: Hull strategy.:directruns concave hull on a thinned point set;:stepwiseruns convex hull first, then keeps only points near the hull boundary before concave hullhull_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 subsethull_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 markerslocation_color::AbstractString="purple": Marker color used for the location circleslocation_size::Number=10: Marker diameter for the location circleslocation_names_above::AbstractVector=String[]: Optional labels plotted above each location markerlocation_names_below::AbstractVector=String[]: Optional labels plotted below each location markershow_hull::Bool=false: Overlay the computed hull polygon for debugginghull_color::AbstractString="magenta": Hull trace color whenshow_hull=truehull_line_width::Number=3: Line width for the hull outlinehull_opacity::Real=0.35: Opacity applied to the hull tracekw...: Additional keyword arguments passed to the mapbox function
Debugging
progress::Bool=false: If true, prints stage-by-stage timing/progress information to help diagnose slowdownsprogress_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")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 columnscolumn::Union{Symbol, AbstractString}: Column name containing values to interpolatekw...: 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")See the Mapbox manual, the README visualization example, and the notebooks directory for the broader legacy plotting and notebook interfaces.