Skip to content

matlab/matlab-agentic-toolkit / skills-catalog/ai-and-statistics/matlab-engineer-tabular-features

matlab-engineer-tabular-features

Unverified

Use when engineering or selecting the best features for single-response classification or regression in MATLAB, whatever the data's modality — for non-tabular data it routes extraction to a domain skill, then selects, assesses, and delivers on the resulting table. Not for multi-response problems, model training, or raw data acquisition.

FileKindSize
SKILL.mdskill md18.9 KB
manifest.yamlconfig570 B
references/assess.mdmarkdown16.7 KB
references/deliver.mdmarkdown13.0 KB
references/domain-routing.mdmarkdown18.1 KB
references/feature-pool.mdmarkdown10.9 KB
references/intake.mdmarkdown16.9 KB
references/internal-helpers.mdmarkdown12.2 KB
references/provider-protocol.mdmarkdown12.3 KB
references/report.mdmarkdown9.7 KB
references/reproduce-pool.mdmarkdown7.1 KB
references/select.mdmarkdown7.1 KB
scripts/BordaVoter.mother2.3 KB
scripts/ConsensusVoter.mother2.5 KB
scripts/MajorityVoter.mother2.0 KB
scripts/RRFVoter.mother1.9 KB
scripts/assessGenerationStability.mother11.9 KB
scripts/assessKFold.mother20.6 KB
scripts/assessSelectionStability.mother9.8 KB
scripts/baselineComparison.mother18.9 KB
scripts/buildRecipe.mother8.2 KB
scripts/chooseNumBins.mother5.0 KB
scripts/chooseStandardization.mother4.5 KB
scripts/computeNSelect.mother2.9 KB
scripts/createConsensusVoter.mother2.2 KB
scripts/describeFeatures.mother5.1 KB
scripts/expandBlockMap.pbinary440 B
scripts/featureSetQuality.mother12.3 KB
scripts/generateFeatureReport.mother67.2 KB
scripts/generateFeatureReportPdf.mother64.9 KB
scripts/generateFeatures.mother14.6 KB
scripts/hasReportGenerator.mother630 B
scripts/isDomainRecipe.mother1.4 KB
scripts/isStringEmpty.mother577 B
scripts/lambdaSequence.pbinary637 B
scripts/lassoFeatureRanking.pbinary971 B
scripts/macroF1Score.mother931 B
scripts/mrmrFeatureRanking.pbinary239 B
scripts/mutualInformationPanel.pbinary1.1 KB
scripts/ncaFeatureRanking.pbinary464 B
scripts/nogueiraStability.mother3.8 KB
scripts/oobFeatureRanking.pbinary414 B
scripts/plotSelectionConsensus.mother2.7 KB
scripts/plotSelectionDecision.mother6.3 KB
scripts/plotSelectionStability.mother10.2 KB
scripts/plotValidationBaseline.mother6.1 KB
scripts/printSummary.mother18.3 KB
scripts/profileForSplit.mother6.2 KB
scripts/rankAgreement.mother1.3 KB
scripts/rankFeatures.mother6.2 KB
scripts/reserveHoldoutForUser.mother5.5 KB
scripts/runConsensusSelection.mother9.4 KB
scripts/sampleSkewness.mother600 B
scripts/saveResults.mother2.1 KB
scripts/scoreFeaturePanel.pbinary1.6 KB
scripts/screenPredictors.mother13.3 KB
scripts/selectFeatures.mother2.3 KB
scripts/splitStrategy.mother5.4 KB
scripts/stratifiedDownsampleRows.mother2.2 KB
scripts/stratifiedSubsampleIndices.mother3.4 KB
scripts/transformFeatures.mother6.1 KB
scripts/validateRecipe.mother12.3 KB
scripts/writeInferenceScript.mother10.5 KB

scripts/buildRecipe.m

View on GitHub
function Recipe = buildRecipe(Apply, Describe, Provider, FeatureTable, RawInput, Options)
%buildRecipe Assemble a domain recipe and prove it against its pool in one call.
%
%   Recipe = buildRecipe(Apply, Describe, Provider, FeatureTable, RawInput)
%   assembles a capture-time domain recipe struct (Kind == "domain") from the
%   pieces a domain extraction produced, and returns it ONLY if it faithfully
%   reproduces and describes the pool it was captured from. It is the single
%   choke point both routing paths pass through -- the subagent-dispatch path
%   (main) and the inline same-session path (fallback) call it with the same
%   arguments, so downstream receives an identical, already-verified recipe and
%   never knows which path produced it (see domain-routing.md, provider-protocol.md).
%
%   It replaces the earlier "assemble a struct by hand, then remember to call
%   validateRecipe" protocol with one function that:
%     1. assembles the struct  -- Kind = "domain", Apply, Describe, Provider;
%     2. checks its shape       -- Apply is a function handle, Describe has the
%        Feature|Type|Definition variables, Provider is non-empty text;
%     3. runs the round-trip gate inline -- validateRecipe replays Apply against
%        the pool and confirms Describe lists exactly the pool's features.
%   Anything missing or unfaithful is a hard error here, at construction, rather
%   than a silent failure downstream. A returned recipe is a proven one.
%
%   This is the CAPTURE-TIME constructor: it builds the four fields generation,
%   selection, and assessment need (Kind/Apply/Describe/Provider). ApplySelected
%   is the inference-only path and is requested separately at deliver time, once
%   selection has fixed the feature set, and validated then (see deliver.md);
%   buildRecipe neither builds nor requires it.
%
%   OPTIONAL Fit -- unlock generation-variance assessment. Apply replays a recipe
%   fit ONCE (frozen); it cannot regenerate the pool on new rows, so it alone
%   cannot answer "how much would the pool itself move if refit?". A domain path
%   that CAN re-run its extraction fitting may pass that as Options.Fit -- a
%   re-runnable producer with the same signature assessKFold/assessGenerationStability
%   consume:
%     [EngTrain, Apply, ExcludeFeatures] = Fit(RawRows, Response, ProblemType, TargetModel)
%   When supplied it is verified here (fitting on the captured rows must reproduce
%   the pool's feature names) and stored as Recipe.Fit, which the orchestrator
%   passes as the Producer to enable cross-validated performance and the
%   generation-stability read. Fit is DIAGNOSTIC-time only: inference always ships
%   the frozen Apply, never a refit (refitting at inference would drift). Absent
%   Fit, those reads degrade to N/A on the domain path (see assess.md).
%
%   Inputs:
%     Apply        - (1,1) function_handle mapping the RAW DATA (in whatever form
%                    the extraction consumes) to the FULL feature table (the
%                    replayed extraction). The only hard contract is that Apply
%                    RETURNS a table; its input type is the extractor's business.
%     Describe     - table with Feature|Type|Definition, one row per pool feature
%     Provider     - (1,1) string, free-text label for the source skill
%     FeatureTable - the materialized pool the recipe was captured from
%                    (predictors + response), one row per observation
%     RawInput     - the raw data Apply consumes, row-aligned with FeatureTable
%                    (one raw observation per pool row). Any row-indexable form:
%                    a table, a numeric/categorical matrix, a cell array, etc. --
%                    NOT constrained to a table, so a matrix-consuming extractor
%                    is passed its matrix unchanged rather than silently coerced.
%     Options.ResponseVar (1,1) string = ""  response column, excluded from the
%                                            checked feature set if present
%     Options.CheckIdx    (1,:) double = []  rows to verify against; pass the
%                                            HELD-OUT (test) indices so response-
%                                            based encodings do not false-alarm
%                                            (forwarded to validateRecipe)
%     Options.Fit         (1,1) function_handle  OPTIONAL re-runnable producer (see
%                                            above); when set, verified and stored
%                                            as Recipe.Fit
%     Options.ProblemType (1,1) string       "classification"/"regression"; required
%                                            when Fit is supplied (it drives Fit)
%     Options.TargetModel (1,1) string = "agnostic"  model family passed to Fit
%
%   Output:
%     Recipe - a scalar struct with fields Kind, Apply, Describe, Provider (and
%              Fit when supplied), verified to reproduce and describe FeatureTable
%
%   Errors (raised before returning a recipe):
%     - buildRecipe:invalidProvider          Provider is empty/blank
%     - buildRecipe:fitNotReproducible        supplied Fit does not regenerate the pool
%     - validateRecipe:missingArtifact        a required field is absent/malformed
%     - validateRecipe:poolMismatch           Apply reproduces wrong/missing values
%     - validateRecipe:describeMismatch       Describe lists the wrong features
%   (the validateRecipe:* ids are re-raised from the inline gate, so a caller
%   catches the same ids whether it validated by hand or built through here.)

% Copyright 2026 The MathWorks, Inc.

    arguments
        Apply
        Describe
        Provider (1,1) string
        FeatureTable table
        RawInput
        Options.ResponseVar (1,1) string = ""
        Options.CheckIdx (1,:) double = []
        Options.Fit function_handle = function_handle.empty
        Options.ProblemType (1,1) string = ""
        Options.TargetModel (1,1) string = "agnostic"
    end

    if strlength(strtrim(Provider)) == 0
        error("buildRecipe:invalidProvider", ...
            "Provider must be a non-empty label for the source skill.");
    end

    Recipe = struct( ...
        Kind = "domain", ...
        Apply = Apply, ...
        Describe = Describe, ...
        Provider = Provider);

    % The round-trip gate is the proof: it re-checks presence/shape of Apply and
    % Describe against ground truth and replays Apply on a sample of rows. Capture
    % mode (no SelectedNames) is exactly the four-field contract assembled above.
    validateRecipe(Recipe, FeatureTable, RawInput, ...
        ResponseVar = Options.ResponseVar, CheckIdx = Options.CheckIdx);

    % A supplied Fit unlocks the generation-variance reads, so prove it here: run
    % it on the captured rows and confirm it regenerates the pool's feature names.
    % (Values may differ from the frozen Apply -- Fit REFITS -- so names, not
    % values, are the contract.) Stored only once proven.
    if ~isempty(Options.Fit)
        verifyFit(Options.Fit, FeatureTable, RawInput, ...
            Options.ResponseVar, Options.ProblemType, Options.TargetModel);
        Recipe.Fit = Options.Fit;
    end
end


function verifyFit(Fit, FeatureTable, RawInput, ResponseVar, ProblemType, TargetModel)
%verifyFit Confirm a re-runnable producer regenerates the pool's feature names.
    if ProblemType == ""
        error("buildRecipe:fitNotReproducible", ...
            "ProblemType is required when Fit is supplied (it drives Fit).");
    end
    try
        EngTrain = Fit(RawInput, ResponseVar, ProblemType, TargetModel);
    catch Err
        error("buildRecipe:fitNotReproducible", ...
            "Fit errored when re-run on the captured rows: %s", Err.message);
    end
    if ~istable(EngTrain)
        error("buildRecipe:fitNotReproducible", ...
            "Fit must return an engineered table as its first output.");
    end
    Regen = string(EngTrain.Properties.VariableNames);
    PoolFeatures = setdiff(string(FeatureTable.Properties.VariableNames), ...
        ResponseVar, "stable");
    Missing = setdiff(PoolFeatures, Regen, "stable");
    if ~isempty(Missing)
        error("buildRecipe:fitNotReproducible", ...
            ['Fit does not regenerate the captured pool -- missing feature(s): ' ...
            '%s. It must reproduce the same feature names Apply does.'], ...
            strjoin(Missing, ", "));
    end
end
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 467kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 319kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 319kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 319kUpdated Claude CodeCodexVerifiedInstall