Skip to main content

Understanding the Draft Model Optimizer

Improve a draft model automatically. Learn what the Optimizer changes, how to guide it, and how to review the new version before you use it.

Understanding the Draft Model Optimizer

Improving a model usually means repeating the same loop by hand: change an attribute, train a new draft, check the score, and try again. The Draft Model Optimizer runs that loop for you. It takes a draft model you've already trained and keeps trying improvements in the background, one change at a time. When it finds a better version, it gives it to you as a new draft. Your original draft is never changed.

The Optimizer is in beta. It's ready to use, and we're still improving it. That's why you'll see a Beta label when you start a run and on the Optimization summary.

What the Optimizer Changes

The Optimizer works only on your attribute queries. In each round, which we call an iteration, it makes one focused change, trains a new draft, and keeps the change only if the result is better.

The changes it makes are of three kinds:

  • Brings in more of your data. It adds tables, or columns your queries don't use yet. It can use any table you've already imported into Pecan, including tables your notebook doesn't use yet.

  • Adjusts time windows. It changes how far back in time an attribute looks.

  • Creates new features. It builds features from your data, including ones that combine columns from different tables.

It works through your data step by step and builds on what's already working in your model. Every feature it creates uses only data from before the prediction date, and never uses your target.

If you have a lot of data, a run may not get to every table. If you know a table matters, name it in your instructions when you start the run (see Guiding the Optimizer below).

What it never changes: your predictive question, entity, target, horizon, core set logic and data split settings stay exactly as you set them. It also doesn't remove columns from your existing queries, except to fix leakage. The one exception to the core set rule is related to label drift, explained under Health checks during optimization below. If the Optimizer drops older rows because of drift, your split settings are applied to the data that remains.

When to Use It

You get the most out of the Optimizer when you run it on a thin draft: one where your core set is ready and you've added your first attribute or two. A thin draft leaves the Optimizer the most room to find new signal in your data.

You can also run it on a more developed draft. Just expect fewer and smaller improvements, because more of the useful signal may already be in your model.

Using the Optimizer is optional. You can keep building and training drafts yourself, and combine both approaches.

Starting an Optimization

  1. Open the Draft Models view of your notebook.

  2. On the draft you want to improve, hover over the sparkles icon and click Optimize.
    ​

  3. If there's something the Optimizer should know about your data, click Guide the optimizer (optional) and type it in. See Guiding the Optimizer below.

  4. Click Start optimization.
    ​

The optimization runs in the background, so you can keep working or leave the page. It usually takes about 1 hour, sometimes 2 hours or more, depending on your data.

While it runs, you can keep training other drafts. You can also optimize several drafts at the same time, one run per draft. To stop a run, click Cancel, then confirm with Cancel optimization. A canceled run doesn't create a new version, and you can optimize the same draft again whenever you like.

Guiding the Optimizer

The Optimizer learns a lot from your data, but some things aren't visible in it. When you start a run, click Guide the optimizer (optional) and write instructions to share what only you know. The Optimizer treats your instructions as facts and follows them throughout the run.

Good things to share:

  • A column that gets updated later. "plan_tier is overwritten every night with the current plan, and customers often downgrade before they cancel. Don't use it." The Optimizer won't add a column you rule out.

  • A column that was wrongly removed as leakage. If a previous run removed a column you know is safe, say why. "customer_segment isn't leakage. It's set when the account is created and never changes. Keep it." Always give the reason, not just the column name. The Optimizer uses it to decide.

  • How tables connect. "user_id in app_events is a single seat, not an account. Connect it to accounts through account_id in the seats table."

  • A table that matters. "Use support_tickets. A rise in tickets is often an early sign of churn." The Optimizer tries the tables you name before other new tables.

What instructions can't change:

  • What the model predicts, who is included, or the prediction horizon. Change these in the notebook before you optimize.

  • The score it optimizes. It always improves the model's overall score, so it can't aim for a different metric or a specific group of customers.

  • Which period of data it trains on. It removes older data only when it detects that your data has changed over time.

You don't need to ask it to improve accuracy. It always does.

Leakage still comes first. When a leakage flag is unclear, for example on a column whose values can change over time, your explanation helps the Optimizer decide whether to keep it. If it finds evidence in the data that a column uses information from after the prediction date, it won't use the column, even if your instructions ask it to.

What it already knows. The Optimizer also uses what Pecan has learned about your data in your earlier conversations with the assistant. If your instructions say something different, it follows your instructions.

To see the instructions a run used, open its Optimization summary and go to the User instructions tab.

Following the Progress

A new section appears below your draft, showing the optimization as it happens:

  • A timer showing how long the run has been going.

  • One line per iteration with a short title of what was tried, for example "Add status history", and its result:

    • Improved: this change produced the best version so far.

    • Improved - Under Leakage Investigation: this change beat the best score so far, but a column was flagged as possible leakage. The Optimizer checks the flag before the version can count (see Health Checks During Optimization).

    • No improvement: the change was tried and didn't beat the best version so far.

    • Failed: this iteration couldn't complete. The run moves on to the next one.

  • See details under each iteration explains what was changed and why.

How "Better" Is Decided

Each new version is scored on your test set, a slice of your data held back from training. That way the model is judged on data it hasn't seen. One score decides whether a version is better:

  • Binary (yes/no) models: AUPRC. A score from 0 to 1 for how well the model catches the cases you're predicting without flagging too many that don't happen.

  • Regression models: wMAPE. Total absolute error as a percentage of the total actual values. Lower is better.

A version counts as improved only if it beats the best version found so far on this score. Other metrics you see, like precision and recall, often improve too, but not always. Because the Optimizer is working toward this one score, another metric can sometimes go down.

Why a lower score can be the better result

Sometimes the optimized model scores lower than your original draft and is still the right result. This happens when the original draft had leakage: it used information that wouldn't be available at the moment of prediction, for example a column that's only filled in after the outcome is known. Leakage makes a model look better in testing than it will perform in real use.

When the Optimizer confirms leakage in your original draft, it treats that draft's score as inflated and doesn't use it as the bar to beat. The optimized version's lower score is the honest one. It reflects how the model is likely to perform once it's making real predictions.

Health Checks During Optimization

Every new version goes through the same health checks as any draft model, and the Optimizer handles problems on its own:

  • Leakage. When a version that beats the best score so far has a column flagged as possible leakage, the Optimizer looks into it:

    • If the leak is real, it removes the column or fixes the query, and retrains.

    • If the flag turns out to be a false alarm, it keeps the column, dismisses the flag, and lists the column under Needs review so you can confirm it (see Seeing What Changed below).

    • If it can't tell for sure, it removes the column. A slightly weaker model you can trust is better than one that only looks good. Your instructions can help here: if you explain how or when a column is filled in, the Optimizer uses that to decide (see Guiding the Optimizer).

    A flagged version that doesn't beat the best score isn't investigated, because it wouldn't be picked anyway.

  • Label drift. If your target behaves very differently in older data than in recent data, the Optimizer may drop the older rows from your core set, as long as enough data remains. This is the one change it can make to the core set. It's also why an optimized model can train on fewer rows than your original draft.

A version with an unresolved leakage or drift issue is never picked as the best result.

Reviewing the Results

When the run ends, you'll see one of three outcomes:

  • Optimized. The Optimizer found a better version. It appears below your original draft as a new version: for example, optimizing V1 creates V1.1. The card shows its metrics, how long the run took, and how many iterations it ran.

  • No improvement. You'll see "Optimization complete. Your original draft remains the best performer." No new version is created. You can run the Optimizer on the same draft again, and it may try different changes.

  • Failed. You'll see "Optimization failed." No new version is created, and our team is notified. You can run the Optimizer on the same draft again.

You'll also hear about the result in chat: the next time you message the assistant in this flow, it tells you how the optimization went, and you can ask it questions about the result. If the Optimizer made leakage decisions, the message also lists the columns it kept, removed or filtered, and asks you to confirm them. If you disagree with a decision, tell the assistant and it can reverse it.

Seeing What Changed

Click What's improved? on the optimized version to open the Optimization summary. After you've started using the optimized version, you can still open it any time from the version's three-dot menu, under Optimization Report.

At the top of the summary:

  • The main score (AUPRC or wMAPE) of the new version, and how much it improved over your original draft.

  • Before → after for the main metrics and health checks, for example V1 → V1.1. For binary models that's AUPRC, precision, recall and the test set label distribution. For regression models it's wMAPE and error bias. The score the Optimizer worked toward is marked Target.

  • Work done: how many iterations ran, how long the run took, and how many attributes were engineered.

Below that are the tabs. Some appear only when they apply.

Report lists the changes that made it into the final version, in order. Each row shows the type of change (such as Attribute added, Attribute edited, Leakage treated or Fixing drift), what happened and why, and the score after that change. Expand a row to see a fuller explanation and the SQL changes. When there are columns to review, a line at the top of the Report links to the Needs review tab.

The Report shows only the path from your original draft to the final version. To see every iteration the Optimizer tried, including the ones that didn't help, open the Improvements summary tab.

Evaluation shows the optimized version's performance summary, which features drive it most, and how your core set changes over time.

Needs review appears when the Optimizer kept columns that were flagged as possible leakage. Sometimes the Optimizer flags a column, investigates it, and decides it's safe to keep. It can't be certain about this, because only you know exactly when your data becomes available. So every column it kept this way, and that's still in the final version, is listed here with the reason it was flagged. This includes columns from your original draft as well as ones the Optimizer added.

Expand a row to see the checks the Optimizer ran and its conclusion, which explains why the column was dismissed.

Before you rely on the optimized version, go through this list. For each column, ask: would this value be known at the moment the prediction is made? If yes, no action is needed. If you're not sure, or the answer is no, click Use this version, then remove the column in the notebook, either yourself or by asking the agent, and train a new draft. A model that relies on future information looks strong in testing but underperforms once it's making real predictions.

Notebook shows every query in the optimized version. Queries the Optimizer added or edited are marked, with the changes highlighted, so you can review the exact SQL before you use it.

User instructions appears when you added instructions to the run, and shows exactly what you wrote.

Improvements summary lists every iteration the Optimizer tried and its result, the same list you see on the draft card.

Using the Optimized Version

The optimized version isn't used until you choose it. When you're happy with what changed, and you've gone through anything under Needs review, click Use this version, either on the version's card or in the Optimization summary. It becomes your current version, and your original draft stays in the list, so you can always go back.

To go back, open the three-dot menu on your original draft and click Restore. Choose Restore & Replace Current to return your notebook to that draft, or Restore & Create New to open it in a new notebook.

Good to Know

  • Your original draft is never changed. Every improvement is saved as a new version.

  • One optimized version per draft. Once a run has created an optimized version of a draft, you can't optimize that draft again, and you can't optimize an optimized version (like V1.1). To keep improving, build on the result and train a new draft. You can then optimize that one. If a run was canceled, failed or found no improvement, you can optimize the same draft again.

  • Optimize needs data sharing. If your organization's data sharing setting is off, the Optimize button is disabled. Turn data sharing on in your organization settings. If Optimize is unavailable for another reason, hover over it to see why.

  • Use this version is unavailable while another draft is training.

  • Each iteration is a draft model, so the usual draft model size limits apply.

  • Results are a draft-level preview. Like any draft, the optimized version's score is a good guide to whether you're moving in the right direction, not an exact preview of your final production model.

Did this answer your question?