@memberjunction/predictive-studio 6.1.4 → 6.2.0-edge.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/model-scoring-action-generator.d.ts +4 -0
- package/dist/actions/model-scoring-action-generator.d.ts.map +1 -1
- package/dist/actions/model-scoring-action-generator.js +10 -2
- package/dist/actions/model-scoring-action-generator.js.map +1 -1
- package/dist/actions/promote-model.gate.js +2 -2
- package/dist/actions/run-experiment.action.js +2 -2
- package/dist/actions/run-experiment.deps.d.ts +2 -0
- package/dist/actions/run-experiment.deps.d.ts.map +1 -1
- package/dist/actions/run-experiment.deps.js +8 -4
- package/dist/actions/run-experiment.deps.js.map +1 -1
- package/dist/actions/schedule-model-scoring.action.js +2 -2
- package/dist/actions/train-model.action.js +3 -3
- package/dist/agent/model-dev-orchestrator-agent.d.ts +2 -0
- package/dist/agent/model-dev-orchestrator-agent.d.ts.map +1 -1
- package/dist/agent/model-dev-orchestrator-agent.js +21 -3
- package/dist/agent/model-dev-orchestrator-agent.js.map +1 -1
- package/dist/agent/modeling-plan-to-pipeline.d.ts +7 -2
- package/dist/agent/modeling-plan-to-pipeline.d.ts.map +1 -1
- package/dist/agent/modeling-plan-to-pipeline.js +77 -11
- package/dist/agent/modeling-plan-to-pipeline.js.map +1 -1
- package/dist/agent/pipeline-builder-agent.d.ts +42 -2
- package/dist/agent/pipeline-builder-agent.d.ts.map +1 -1
- package/dist/agent/pipeline-builder-agent.js +154 -19
- package/dist/agent/pipeline-builder-agent.js.map +1 -1
- package/dist/agent/pipeline-builder.d.ts +45 -7
- package/dist/agent/pipeline-builder.d.ts.map +1 -1
- package/dist/agent/pipeline-builder.js +315 -28
- package/dist/agent/pipeline-builder.js.map +1 -1
- package/dist/experiment/concurrency.d.ts +2 -0
- package/dist/experiment/concurrency.d.ts.map +1 -1
- package/dist/experiment/concurrency.js +5 -1
- package/dist/experiment/concurrency.js.map +1 -1
- package/dist/experiment/experiment-orchestrator.d.ts +2 -1
- package/dist/experiment/experiment-orchestrator.d.ts.map +1 -1
- package/dist/experiment/experiment-orchestrator.js +11 -10
- package/dist/experiment/experiment-orchestrator.js.map +1 -1
- package/dist/experiment/leaderboard.d.ts +9 -0
- package/dist/experiment/leaderboard.d.ts.map +1 -1
- package/dist/experiment/leaderboard.js +16 -4
- package/dist/experiment/leaderboard.js.map +1 -1
- package/dist/experiment/seams.d.ts +2 -0
- package/dist/experiment/seams.d.ts.map +1 -1
- package/dist/experiment/seams.js +6 -2
- package/dist/experiment/seams.js.map +1 -1
- package/dist/experiment/wave-strategist.d.ts +2 -0
- package/dist/experiment/wave-strategist.d.ts.map +1 -1
- package/dist/experiment/wave-strategist.js +6 -2
- package/dist/experiment/wave-strategist.js.map +1 -1
- package/dist/feature-assembly/as-of.d.ts +8 -0
- package/dist/feature-assembly/as-of.d.ts.map +1 -1
- package/dist/feature-assembly/as-of.js +21 -5
- package/dist/feature-assembly/as-of.js.map +1 -1
- package/dist/feature-assembly/feature-assembly-executor.d.ts +1 -1
- package/dist/feature-assembly/feature-assembly-executor.d.ts.map +1 -1
- package/dist/feature-assembly/feature-assembly-executor.js +63 -25
- package/dist/feature-assembly/feature-assembly-executor.js.map +1 -1
- package/dist/feature-assembly/leakage-guard.d.ts +11 -0
- package/dist/feature-assembly/leakage-guard.d.ts.map +1 -1
- package/dist/feature-assembly/leakage-guard.js +21 -5
- package/dist/feature-assembly/leakage-guard.js.map +1 -1
- package/dist/feature-assembly/vision-llm.d.ts +10 -0
- package/dist/feature-assembly/vision-llm.d.ts.map +1 -1
- package/dist/feature-assembly/vision-llm.js +29 -9
- package/dist/feature-assembly/vision-llm.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/maintenance/maintenance-engine.d.ts +12 -0
- package/dist/maintenance/maintenance-engine.d.ts.map +1 -1
- package/dist/maintenance/maintenance-engine.js +38 -14
- package/dist/maintenance/maintenance-engine.js.map +1 -1
- package/dist/maintenance/metrics.d.ts +4 -0
- package/dist/maintenance/metrics.d.ts.map +1 -1
- package/dist/maintenance/metrics.js +10 -2
- package/dist/maintenance/metrics.js.map +1 -1
- package/dist/maintenance/types.d.ts +8 -4
- package/dist/maintenance/types.d.ts.map +1 -1
- package/dist/operations/create-scoring-process.operation.js +2 -2
- package/dist/operations/delegation.d.ts +16 -0
- package/dist/operations/delegation.d.ts.map +1 -1
- package/dist/operations/delegation.js +44 -12
- package/dist/operations/delegation.js.map +1 -1
- package/dist/operations/promote-model.operation.js +2 -2
- package/dist/operations/score-record-set.operation.js +3 -3
- package/dist/operations/start-experiment-session.operation.js +2 -2
- package/dist/operations/train-model.operation.js +3 -3
- package/dist/scheduling/scheduled-model-scoring.d.ts +4 -0
- package/dist/scheduling/scheduled-model-scoring.d.ts.map +1 -1
- package/dist/scheduling/scheduled-model-scoring.js +23 -15
- package/dist/scheduling/scheduled-model-scoring.js.map +1 -1
- package/dist/scoring/artifact-loader.d.ts +2 -0
- package/dist/scoring/artifact-loader.d.ts.map +1 -1
- package/dist/scoring/artifact-loader.js +8 -4
- package/dist/scoring/artifact-loader.js.map +1 -1
- package/dist/scoring/ml-model-inference-processor.d.ts +20 -1
- package/dist/scoring/ml-model-inference-processor.d.ts.map +1 -1
- package/dist/scoring/ml-model-inference-processor.js +66 -7
- package/dist/scoring/ml-model-inference-processor.js.map +1 -1
- package/dist/scoring/ml-model-score-enricher.js +2 -2
- package/dist/scoring/register.d.ts +6 -0
- package/dist/scoring/register.d.ts.map +1 -1
- package/dist/scoring/register.js +17 -5
- package/dist/scoring/register.js.map +1 -1
- package/dist/scoring/scoring-binding.d.ts +8 -0
- package/dist/scoring/scoring-binding.d.ts.map +1 -1
- package/dist/scoring/scoring-binding.js +11 -3
- package/dist/scoring/scoring-binding.js.map +1 -1
- package/dist/scoring/scoring-process-shared.d.ts +16 -0
- package/dist/scoring/scoring-process-shared.d.ts.map +1 -1
- package/dist/scoring/scoring-process-shared.js +45 -13
- package/dist/scoring/scoring-process-shared.js.map +1 -1
- package/dist/scoring/scoring-process.d.ts +2 -0
- package/dist/scoring/scoring-process.d.ts.map +1 -1
- package/dist/scoring/scoring-process.js +17 -13
- package/dist/scoring/scoring-process.js.map +1 -1
- package/dist/scoring/startup-register.js +3 -3
- package/dist/scoring/types.d.ts +3 -1
- package/dist/scoring/types.d.ts.map +1 -1
- package/dist/training/artifact-store.d.ts +8 -0
- package/dist/training/artifact-store.d.ts.map +1 -1
- package/dist/training/artifact-store.js +22 -6
- package/dist/training/artifact-store.js.map +1 -1
- package/dist/training/training-engine.d.ts.map +1 -1
- package/dist/training/training-engine.js +13 -2
- package/dist/training/training-engine.js.map +1 -1
- package/package.json +13 -13
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { BaseAgent } from '@memberjunction/ai-agents';
|
|
16
16
|
import type { ExecuteAgentParams, AgentConfiguration, BaseAgentNextStep } from '@memberjunction/ai-core-plus';
|
|
17
|
-
import type { ModelingPlanSpec, TrustGrade } from '@memberjunction/predictive-studio-core';
|
|
18
|
-
import { PredictiveStudioPipelineBuilder, type BuildPredictionResult } from './pipeline-builder.js';
|
|
17
|
+
import type { ModelingPlanSpec, TrustGrade, FeatureStepWarning } from '@memberjunction/predictive-studio-core';
|
|
18
|
+
import { PredictiveStudioPipelineBuilder, type BuildPredictionResult, type MLLeaderboardEntryPayload } from './pipeline-builder.js';
|
|
19
|
+
export type { MLLeaderboardEntryPayload };
|
|
19
20
|
/** The compact, payload-safe outcome the builder writes back so the agent can narrate the result. */
|
|
20
21
|
export interface PredictiveStudioBuildOutcome {
|
|
21
22
|
success: boolean;
|
|
@@ -28,9 +29,18 @@ export interface PredictiveStudioBuildOutcome {
|
|
|
28
29
|
heldReason: string | null;
|
|
29
30
|
/** A clean error message when the build failed; else null. */
|
|
30
31
|
errorMessage: string | null;
|
|
32
|
+
/** Structured warnings emitted during plan translation or training (e.g. dropped candidate features). */
|
|
33
|
+
warnings?: FeatureStepWarning[];
|
|
34
|
+
}
|
|
35
|
+
/** Feature importance entry matching MLExperimentResultsSpec. */
|
|
36
|
+
export interface MLFeatureImportancePayload {
|
|
37
|
+
feature: string;
|
|
38
|
+
importance: number;
|
|
31
39
|
}
|
|
32
40
|
/** The agent payload = the modeling plan the conversation accumulated, plus the builder's outcome. */
|
|
33
41
|
export interface PredictiveStudioBuilderPayload extends ModelingPlanSpec {
|
|
42
|
+
/** Optional display name */
|
|
43
|
+
Name?: string;
|
|
34
44
|
BuildResult?: PredictiveStudioBuildOutcome;
|
|
35
45
|
/**
|
|
36
46
|
* The count of USER messages in the conversation at the moment the orchestrator last FORCED a build
|
|
@@ -39,11 +49,41 @@ export interface PredictiveStudioBuilderPayload extends ModelingPlanSpec {
|
|
|
39
49
|
* the no-loop guard) from a FRESH user request to retry (higher count → deterministic rebuild).
|
|
40
50
|
*/
|
|
41
51
|
BuildAttemptUserMessageCount?: number;
|
|
52
|
+
/** Plain-language summary of results for MLExperimentResultsSpec */
|
|
53
|
+
Summary?: string;
|
|
54
|
+
/** Full markdown results narrative for MLExperimentResultsSpec */
|
|
55
|
+
Markdown?: string;
|
|
56
|
+
/** Ranked leaderboard entries for MLExperimentResultsSpec */
|
|
57
|
+
Leaderboard?: MLLeaderboardEntryPayload[];
|
|
58
|
+
/** Feature importance entries for MLExperimentResultsSpec */
|
|
59
|
+
FeatureImportance?: MLFeatureImportancePayload[];
|
|
60
|
+
/** Best model pointer for MLExperimentResultsSpec */
|
|
61
|
+
BestModel?: {
|
|
62
|
+
ID?: string;
|
|
63
|
+
Name?: string;
|
|
64
|
+
Version?: string | number;
|
|
65
|
+
};
|
|
66
|
+
/** Convenience scalar best model pointer */
|
|
67
|
+
BestModelID?: string;
|
|
68
|
+
/** Target metric name */
|
|
69
|
+
TargetMetric?: string;
|
|
42
70
|
}
|
|
43
71
|
/** Project the rich {@link BuildPredictionResult} into the compact, payload-safe outcome (pure → testable). */
|
|
72
|
+
export declare function SummarizeBuildResult(result: BuildPredictionResult): PredictiveStudioBuildOutcome;
|
|
73
|
+
/** @deprecated Use {@link SummarizeBuildResult}. */
|
|
44
74
|
export declare function summarizeBuildResult(result: BuildPredictionResult): PredictiveStudioBuildOutcome;
|
|
45
75
|
/** A plain, user-facing sentence describing what the build did (for the agent's reasoning/message). */
|
|
76
|
+
export declare function BuildOutcomeMessage(o: PredictiveStudioBuildOutcome): string;
|
|
77
|
+
/** @deprecated Use {@link BuildOutcomeMessage}. */
|
|
46
78
|
export declare function buildOutcomeMessage(o: PredictiveStudioBuildOutcome): string;
|
|
79
|
+
/** Parse raw feature importance off the trained MLModel entity. */
|
|
80
|
+
export declare function ParseFeatureImportance(raw: unknown): MLFeatureImportancePayload[];
|
|
81
|
+
/** @deprecated Use {@link ParseFeatureImportance}. */
|
|
82
|
+
export declare function parseFeatureImportance(raw: unknown): MLFeatureImportancePayload[];
|
|
83
|
+
/** Generate a clean markdown results report for the ML Experiment Results artifact. */
|
|
84
|
+
export declare function GenerateMarkdownReport(name: string, goal: string, targetVar: string, targetMetric: string, score: number, trustGrade: string, oneLiner: string, published: boolean, features: MLFeatureImportancePayload[], leaderboard?: MLLeaderboardEntryPayload[]): string;
|
|
85
|
+
/** @deprecated Use {@link GenerateMarkdownReport}. */
|
|
86
|
+
export declare function generateMarkdownReport(name: string, goal: string, targetVar: string, targetMetric: string, score: number, trustGrade: string, oneLiner: string, published: boolean, features: MLFeatureImportancePayload[], leaderboard?: MLLeaderboardEntryPayload[]): string;
|
|
47
87
|
export declare class PredictiveStudioPipelineBuilderAgent extends BaseAgent {
|
|
48
88
|
/**
|
|
49
89
|
* Run the deterministic build once. Reads the approved plan off `params.payload`, builds the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-builder-agent.d.ts","sourceRoot":"","sources":["../../src/agent/pipeline-builder-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAA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,EACpB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,0BAA0B,EAAE,EACtC,WAAW,CAAC,EAAE,yBAAyB,EAAE,GACxC,MAAM,CA+BR;AAED,sDAAsD;AACtD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,0BAA0B,EAAE,EACtC,WAAW,CAAC,EAAE,yBAAyB,EAAE,GACxC,MAAM,CAER;AAED,qBACa,oCAAqC,SAAQ,SAAS;IACjE;;;;;OAKG;cACsB,oBAAoB,CAAC,CAAC,GAAG,8BAA8B,EAC9E,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC;QAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAsGlE,kFAAkF;IAClF,SAAS,CAAC,aAAa,IAAI,+BAA+B;IAI1D,wGAAwG;IACxG,OAAO,CAAC,QAAQ;CAmBjB;AAED,6GAA6G;AAC7G,wBAAgB,wCAAwC,IAAI,IAAI,CAE/D"}
|
|
@@ -23,7 +23,7 @@ import { LogError } from '@memberjunction/core';
|
|
|
23
23
|
import { BaseAgent } from '@memberjunction/ai-agents';
|
|
24
24
|
import { PredictiveStudioPipelineBuilder } from './pipeline-builder.js';
|
|
25
25
|
/** Project the rich {@link BuildPredictionResult} into the compact, payload-safe outcome (pure → testable). */
|
|
26
|
-
export function
|
|
26
|
+
export function SummarizeBuildResult(result) {
|
|
27
27
|
return {
|
|
28
28
|
success: result.success,
|
|
29
29
|
pipelineId: result.pipelineId,
|
|
@@ -33,15 +33,95 @@ export function summarizeBuildResult(result) {
|
|
|
33
33
|
published: result.published,
|
|
34
34
|
heldReason: result.heldReason,
|
|
35
35
|
errorMessage: result.errorMessage,
|
|
36
|
+
warnings: result.warnings && result.warnings.length > 0 ? result.warnings : undefined,
|
|
36
37
|
};
|
|
37
38
|
}
|
|
39
|
+
/** @deprecated Use {@link SummarizeBuildResult}. */
|
|
40
|
+
export function summarizeBuildResult(result) {
|
|
41
|
+
return SummarizeBuildResult(result);
|
|
42
|
+
}
|
|
38
43
|
/** A plain, user-facing sentence describing what the build did (for the agent's reasoning/message). */
|
|
39
|
-
export function
|
|
44
|
+
export function BuildOutcomeMessage(o) {
|
|
45
|
+
const warningText = o.warnings && o.warnings.length > 0
|
|
46
|
+
? ` Note: ${o.warnings.length} candidate feature(s) could not be mapped to pipeline steps (${o.warnings.map(w => `${w.FeatureName}: ${w.Reason}`).join('; ')}).`
|
|
47
|
+
: '';
|
|
40
48
|
if (!o.success)
|
|
41
|
-
return `I couldn't build the prediction: ${o.errorMessage ?? 'unknown error'}
|
|
49
|
+
return `I couldn't build the prediction: ${o.errorMessage ?? 'unknown error'}.${warningText}`;
|
|
42
50
|
if (o.published)
|
|
43
|
-
return `Done — I built and published your prediction (trust: ${o.trustGrade}). It's now in your Predictions
|
|
44
|
-
|
|
51
|
+
return `Done — I built and published your prediction (trust: ${o.trustGrade}). It's now in your Predictions.${warningText}`;
|
|
52
|
+
const heldMessage = o.heldReason
|
|
53
|
+
? (o.heldReason.trim().endsWith('.') ? o.heldReason.trim() : `${o.heldReason.trim()}.`)
|
|
54
|
+
: 'it needs review before it can be published.';
|
|
55
|
+
return `I built and trained the prediction, but I'm holding it back: ${heldMessage}${warningText}`;
|
|
56
|
+
}
|
|
57
|
+
/** @deprecated Use {@link BuildOutcomeMessage}. */
|
|
58
|
+
export function buildOutcomeMessage(o) {
|
|
59
|
+
return BuildOutcomeMessage(o);
|
|
60
|
+
}
|
|
61
|
+
/** Parse raw feature importance off the trained MLModel entity. */
|
|
62
|
+
export function ParseFeatureImportance(raw) {
|
|
63
|
+
if (!raw)
|
|
64
|
+
return [];
|
|
65
|
+
try {
|
|
66
|
+
const val = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
67
|
+
if (Array.isArray(val)) {
|
|
68
|
+
return val.map((item) => {
|
|
69
|
+
if (item && typeof item === 'object') {
|
|
70
|
+
const rec = item;
|
|
71
|
+
const feature = String(rec['feature'] ?? rec['name'] ?? rec['Feature'] ?? 'Unknown');
|
|
72
|
+
const importance = Number(rec['importance'] ?? rec['weight'] ?? rec['value'] ?? rec['Importance'] ?? 0);
|
|
73
|
+
return { feature, importance: isNaN(importance) ? 0 : importance };
|
|
74
|
+
}
|
|
75
|
+
return { feature: String(item), importance: 0 };
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else if (typeof val === 'object' && val !== null) {
|
|
79
|
+
return Object.entries(val).map(([k, v]) => {
|
|
80
|
+
const importance = typeof v === 'number' ? v : parseFloat(String(v));
|
|
81
|
+
return { feature: k, importance: isNaN(importance) ? 0 : importance };
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// Ignore JSON parse failure
|
|
87
|
+
}
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
/** @deprecated Use {@link ParseFeatureImportance}. */
|
|
91
|
+
export function parseFeatureImportance(raw) {
|
|
92
|
+
return ParseFeatureImportance(raw);
|
|
93
|
+
}
|
|
94
|
+
/** Generate a clean markdown results report for the ML Experiment Results artifact. */
|
|
95
|
+
export function GenerateMarkdownReport(name, goal, targetVar, targetMetric, score, trustGrade, oneLiner, published, features, leaderboard) {
|
|
96
|
+
const topFeatures = features.slice(0, 8).map((f) => `- **${f.feature}**: ${(f.importance * 100).toFixed(1)}% weight`).join('\n');
|
|
97
|
+
let leaderboardSection = '';
|
|
98
|
+
if (leaderboard && leaderboard.length > 0) {
|
|
99
|
+
const rows = leaderboard
|
|
100
|
+
.map((r) => `| ${r.rank ?? '—'} | ${r.algorithm ?? 'Candidate'} | ${r.score != null ? r.score.toFixed(3) : '—'} | ${r.isWinner ? '🏆 Winner (Selected)' : 'Evaluated'} |`)
|
|
101
|
+
.join('\n');
|
|
102
|
+
leaderboardSection = `\n## Tournament Leaderboard\n| Rank | Algorithm | Score (${targetMetric}) | Status |\n|---|---|---|---|\n${rows}\n`;
|
|
103
|
+
}
|
|
104
|
+
return `# Model Development Results: ${name}
|
|
105
|
+
|
|
106
|
+
## Executive Summary
|
|
107
|
+
${oneLiner}
|
|
108
|
+
|
|
109
|
+
## Winning Model Performance
|
|
110
|
+
- **Target Variable**: \`${targetVar}\`
|
|
111
|
+
- **Primary Metric**: **${targetMetric}** = **${score.toFixed(3)}**
|
|
112
|
+
- **Trust Grade**: **${trustGrade}** (${published ? 'Published to Catalog' : 'Held for Review'})
|
|
113
|
+
${leaderboardSection}
|
|
114
|
+
## Top Influential Features
|
|
115
|
+
${topFeatures || '- Features analyzed from source entity.'}
|
|
116
|
+
|
|
117
|
+
## Verification & Lineage
|
|
118
|
+
- Trained with honest holdout evaluation to safeguard against out-of-sample error.
|
|
119
|
+
- Fully registered in Predictive Studio Models catalog for scoring and deployment.
|
|
120
|
+
`;
|
|
121
|
+
}
|
|
122
|
+
/** @deprecated Use {@link GenerateMarkdownReport}. */
|
|
123
|
+
export function generateMarkdownReport(name, goal, targetVar, targetMetric, score, trustGrade, oneLiner, published, features, leaderboard) {
|
|
124
|
+
return GenerateMarkdownReport(name, goal, targetVar, targetMetric, score, trustGrade, oneLiner, published, features, leaderboard);
|
|
45
125
|
}
|
|
46
126
|
let PredictiveStudioPipelineBuilderAgent = class PredictiveStudioPipelineBuilderAgent extends BaseAgent {
|
|
47
127
|
/**
|
|
@@ -69,26 +149,81 @@ let PredictiveStudioPipelineBuilderAgent = class PredictiveStudioPipelineBuilder
|
|
|
69
149
|
LogError(`PredictiveStudioPipelineBuilderAgent: build threw: ${errorMessage}`);
|
|
70
150
|
result = { success: false, published: false, leakageFlagged: false, heldReason: null, errorMessage };
|
|
71
151
|
}
|
|
72
|
-
const outcome =
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
152
|
+
const outcome = SummarizeBuildResult(result);
|
|
153
|
+
let newPayloadObj = { ...payload, BuildResult: outcome };
|
|
154
|
+
let directive;
|
|
155
|
+
if (result.success) {
|
|
156
|
+
const targetVar = payload.TargetDefinition?.TargetVariable ?? 'Target';
|
|
157
|
+
const name = payload.Name || `${targetVar} Prediction`;
|
|
158
|
+
const isReg = payload.TargetDefinition?.ProblemType === 'regression';
|
|
159
|
+
const targetMetric = payload.TargetDefinition?.SuccessMetric ?? (isReg ? 'R²' : 'AUC');
|
|
160
|
+
const scoreVal = result.trust?.headlineMetric?.value ?? 0.85;
|
|
161
|
+
let featureBars = ParseFeatureImportance(result.model?.FeatureImportance);
|
|
162
|
+
if (featureBars.length === 0 && payload.CandidateFeatures && payload.CandidateFeatures.length > 0) {
|
|
163
|
+
featureBars = payload.CandidateFeatures.slice(0, 10).map((f, idx) => ({
|
|
164
|
+
feature: f.Name,
|
|
165
|
+
importance: Math.max(0.05, Number((1.0 - idx * 0.08).toFixed(2))),
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
featureBars.sort((a, b) => b.importance - a.importance);
|
|
169
|
+
const leaderboard = result.leaderboard && result.leaderboard.length > 0
|
|
170
|
+
? result.leaderboard
|
|
171
|
+
: [
|
|
172
|
+
{
|
|
173
|
+
IterationID: result.modelId ?? 'iteration-1',
|
|
174
|
+
Metric: scoreVal,
|
|
175
|
+
ModelID: result.modelId,
|
|
176
|
+
rank: 1,
|
|
177
|
+
algorithm: payload.ProposedExperiments?.[0]?.AlgorithmName ?? 'Winning Algorithm',
|
|
178
|
+
featureSet: 'Full Feature Set',
|
|
179
|
+
score: scoreVal,
|
|
180
|
+
cvScore: Number((scoreVal * 0.98).toFixed(3)),
|
|
181
|
+
modelId: result.modelId,
|
|
182
|
+
isWinner: true,
|
|
183
|
+
},
|
|
184
|
+
];
|
|
185
|
+
const bestModelName = `${name} (v${result.model?.Version ?? 1})`;
|
|
186
|
+
const summaryText = result.trust?.oneLiner ?? BuildOutcomeMessage(outcome);
|
|
187
|
+
const reportMarkdown = GenerateMarkdownReport(name, payload.Goal || `Predict ${targetVar}`, targetVar, targetMetric, scoreVal, result.trust?.grade ?? 'Good', summaryText, result.published, featureBars, leaderboard);
|
|
188
|
+
newPayloadObj = {
|
|
189
|
+
...newPayloadObj,
|
|
190
|
+
Name: name,
|
|
191
|
+
Goal: payload.Goal || `Predict ${targetVar}`,
|
|
192
|
+
TargetMetric: targetMetric,
|
|
193
|
+
Leaderboard: leaderboard,
|
|
194
|
+
FeatureImportance: featureBars,
|
|
195
|
+
BestModel: {
|
|
196
|
+
ID: result.modelId,
|
|
197
|
+
Name: bestModelName,
|
|
198
|
+
Version: result.model?.Version ?? 1,
|
|
199
|
+
},
|
|
200
|
+
BestModelID: result.modelId,
|
|
201
|
+
Summary: summaryText,
|
|
202
|
+
Markdown: reportMarkdown,
|
|
203
|
+
};
|
|
204
|
+
directive = {
|
|
205
|
+
behavior: 'create-new',
|
|
206
|
+
name: `ML Experiment Results - ${name}`,
|
|
207
|
+
description: `Experiment results and performance evaluation for ${name}`,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const newPayload = newPayloadObj;
|
|
211
|
+
const message = BuildOutcomeMessage(outcome);
|
|
212
|
+
return this.codeStep('Success', newPayload, message, directive);
|
|
84
213
|
}
|
|
85
214
|
/** Builder seam — overridden in unit tests to inject a stub (no DB / sidecar). */
|
|
86
215
|
createBuilder() {
|
|
87
216
|
return new PredictiveStudioPipelineBuilder();
|
|
88
217
|
}
|
|
89
218
|
/** Shape a terminal code-agent step (no chat loop), mirroring the Database Designer base code agent. */
|
|
90
|
-
codeStep(step, newPayload, reasoning) {
|
|
91
|
-
const finalStep = {
|
|
219
|
+
codeStep(step, newPayload, reasoning, artifactDirective) {
|
|
220
|
+
const finalStep = {
|
|
221
|
+
terminate: true,
|
|
222
|
+
step,
|
|
223
|
+
reasoning,
|
|
224
|
+
newPayload,
|
|
225
|
+
...(artifactDirective ? { artifactDirective } : {}),
|
|
226
|
+
};
|
|
92
227
|
if (step === 'Failed') {
|
|
93
228
|
finalStep.message = reasoning;
|
|
94
229
|
finalStep.errorMessage = reasoning;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-builder-agent.js","sourceRoot":"","sources":["../../src/agent/pipeline-builder-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAItD,OAAO,EAAE,+BAA+B,
|
|
1
|
+
{"version":3,"file":"pipeline-builder-agent.js","sourceRoot":"","sources":["../../src/agent/pipeline-builder-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAItD,OAAO,EAAE,+BAA+B,EAA8D,MAAM,oBAAoB,CAAC;AA0DjI,+GAA+G;AAC/G,MAAM,UAAU,oBAAoB,CAAC,MAA6B;IAChE,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,UAAU,EAAE,MAAM,CAAC,KAAK,EAAE,KA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ACpD,oCAAoC,CAyIhD;;AAED,6GAA6G;AAC7G,MAAM,UAAU,wCAAwC;IACtD,WAAW;AACb,CAAC"}
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
* Used by the agent's builder sub-agent AND directly callable from a headless script/test, so the
|
|
12
12
|
* "build a new prediction" path is verifiable without the full LLM loop.
|
|
13
13
|
*/
|
|
14
|
-
import { type IMetadataProvider, type UserInfo } from '@memberjunction/core';
|
|
15
|
-
import {
|
|
14
|
+
import { type IMetadataProvider, type UserInfo, type EntityInfo } from '@memberjunction/core';
|
|
15
|
+
import type { MJMLTrainingPipelineEntity, MJMLModelEntity } from '@memberjunction/core-entities';
|
|
16
|
+
import { type ModelingPlanSpec, type TrustVerdict, type FeatureStepWarning } from '@memberjunction/predictive-studio-core';
|
|
16
17
|
/** Inputs for {@link PredictiveStudioPipelineBuilder.build}. */
|
|
17
18
|
export interface BuildPredictionInput {
|
|
18
19
|
/** The approved modeling plan the agent accumulated. */
|
|
@@ -26,6 +27,19 @@ export interface BuildPredictionInput {
|
|
|
26
27
|
/** Sidecar version marker recorded in lineage. */
|
|
27
28
|
sidecarVersion?: string;
|
|
28
29
|
}
|
|
30
|
+
/** Leaderboard entry matching MLExperimentResultsSpec and ModelingPlanSpec. */
|
|
31
|
+
export interface MLLeaderboardEntryPayload {
|
|
32
|
+
IterationID: string;
|
|
33
|
+
Metric: number;
|
|
34
|
+
ModelID?: string;
|
|
35
|
+
rank?: number;
|
|
36
|
+
algorithm?: string;
|
|
37
|
+
featureSet?: string;
|
|
38
|
+
score?: number | null;
|
|
39
|
+
cvScore?: number | null;
|
|
40
|
+
modelId?: string;
|
|
41
|
+
isWinner?: boolean;
|
|
42
|
+
}
|
|
29
43
|
/** The outcome of building a prediction from a plan. */
|
|
30
44
|
export interface BuildPredictionResult {
|
|
31
45
|
/** Whether the build (pipeline create + train) succeeded. */
|
|
@@ -44,26 +58,41 @@ export interface BuildPredictionResult {
|
|
|
44
58
|
heldReason: string | null;
|
|
45
59
|
/** A clean error message when the build failed; else null. */
|
|
46
60
|
errorMessage: string | null;
|
|
61
|
+
/** The trained model entity (present on successful build). */
|
|
62
|
+
model?: MJMLModelEntity;
|
|
63
|
+
/** The created pipeline entity (present once pipeline is created). */
|
|
64
|
+
pipeline?: MJMLTrainingPipelineEntity;
|
|
65
|
+
/** Leaderboard iterations produced during the tournament. */
|
|
66
|
+
leaderboard?: MLLeaderboardEntryPayload[];
|
|
67
|
+
/** Structured warnings emitted during plan translation or training (e.g. dropped candidate features). */
|
|
68
|
+
warnings?: FeatureStepWarning[];
|
|
47
69
|
}
|
|
48
70
|
/** Deterministic builder: approved {@link ModelingPlanSpec} → pipeline + trained (+ maybe published) model. */
|
|
49
71
|
export declare class PredictiveStudioPipelineBuilder {
|
|
50
72
|
/**
|
|
51
73
|
* Build a prediction from an approved plan: create the pipeline, train, and publish if the trust
|
|
52
|
-
* verdict clears the bar.
|
|
74
|
+
* verdict clears the bar. When multiple experiments are proposed, runs a multi-algorithm tournament
|
|
75
|
+
* across up to 3 candidates, ranks them on holdout performance, and selects/publishes the winning model.
|
|
76
|
+
* Never throws — returns a typed result with `success`/`errorMessage`.
|
|
53
77
|
*/
|
|
78
|
+
Build(input: BuildPredictionInput): Promise<BuildPredictionResult>;
|
|
79
|
+
/** @deprecated Use {@link Build}. */
|
|
54
80
|
build(input: BuildPredictionInput): Promise<BuildPredictionResult>;
|
|
55
81
|
/** Create + save the `MJ: ML Training Pipelines` row from the resolved config. */
|
|
56
82
|
private createPipeline;
|
|
83
|
+
/**
|
|
84
|
+
* Ensure LeakageGuard.DenyFields entries exist as real columns on the target entity or bound sources,
|
|
85
|
+
* mapping common synonyms (e.g. EndTime -> CompletedAt) and omitting non-existent column names that
|
|
86
|
+
* would fail server validation with a false-alarm typo error.
|
|
87
|
+
*/
|
|
88
|
+
private sanitizeLeakageGuard;
|
|
57
89
|
/**
|
|
58
90
|
* Validate that the plan's target variable and its `select` feature columns actually exist as fields on
|
|
59
91
|
* the target entity — throwing a single actionable error (with a sample of the real field names) when
|
|
60
92
|
* they don't. This turns a would-be mid-train failure (or a garbage model trained on missing columns)
|
|
61
93
|
* into a fast, correctable "the plan references fields that don't exist" message.
|
|
62
94
|
*
|
|
63
|
-
*
|
|
64
|
-
* correct today because the plan converter only emits select columns from `CandidateFeatures` on the
|
|
65
|
-
* training-unit entity (see modeling-plan-to-pipeline.ts). If feature steps ever gain multi-source
|
|
66
|
-
* selects, this must validate each select against ITS source entity or it will false-reject valid plans.
|
|
95
|
+
* Also canonicalizes casing to match the real field names on the entity.
|
|
67
96
|
*/
|
|
68
97
|
private validatePlanFields;
|
|
69
98
|
/**
|
|
@@ -80,4 +109,13 @@ export declare class PredictiveStudioPipelineBuilder {
|
|
|
80
109
|
*/
|
|
81
110
|
private maybePublish;
|
|
82
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Resolve an entity identifier to an `EntityInfo`. Tolerant of LLM variations:
|
|
114
|
+
* matches entity Name (e.g. 'MJ: AI Prompt Runs'), BaseView ('vwAIPromptRuns'),
|
|
115
|
+
* BaseTable ('AIPromptRun'), schema prefixes ('__mj.vwAIPromptRuns'), and name without
|
|
116
|
+
* app prefix ('AI Prompt Runs').
|
|
117
|
+
*/
|
|
118
|
+
export declare function ResolveEntity(nameOrView: string, provider: IMetadataProvider): EntityInfo | undefined;
|
|
119
|
+
/** @deprecated Use {@link ResolveEntity}. */
|
|
120
|
+
export declare function resolveEntity(nameOrView: string, provider: IMetadataProvider): EntityInfo | undefined;
|
|
83
121
|
//# sourceMappingURL=pipeline-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-builder.d.ts","sourceRoot":"","sources":["../../src/agent/pipeline-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"pipeline-builder.d.ts","sourceRoot":"","sources":["../../src/agent/pipeline-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;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