Forge Fate
Quant & Data Research

Designing a Logistic Regression Comparison: Timing, Evaluation, and Failure Handling

6 min read

Before comparing logistic regression with baseline strategies, define which information may enter training, which period everyone will evaluate, and what happens when training fails. Dropping failed months or replacing them with cash changes the result, even with the same model. Failure handling is part of the comparison, not an exception to invent during execution.

The blog has published an actual SPY/IEF/GLD comparison of buy-and-hold and 12-month momentum. It has not yet published logistic regression trained on actual ETF data under the same conditions. This article designs that comparison. Its probabilities are illustrative numbers, not model predictions.

Conditions the strategies should share

For the first comparison, I propose these common conditions for buy-and-hold, momentum, and logistic regression:

ItemComparison condition
InputSame ETFs, price definition, and data snapshot
Evaluation calendarSame start and end after the warm-up period
Feature observationInformation available by month-end
Signal calculationAfter the required month-end data become available
Execution assumptionClose of the next observed trading day
ML selectionEqual weights among assets with estimated class-1 probability at least 0.50
Normal cash holdingValid predictions exist, but no asset is selected
CostsOne-way 0, 5, 10, and 20 bp, using the same accounting code
EndingLiquidate on the same end date, including costs
FailureA required check failing during evaluation makes the run unsuccessful

The 0.50 threshold aligns this design with the logistic/tree comparison; it is not an optimized value. A different threshold must be a recorded candidate, with the selection procedure decided before viewing test results.

Do not compare full-period baseline results directly with a shorter ML evaluation. Recalculate the baselines over the common period from the same initial state. Reusing a period whose results have already been inspected does not create new independent validation.

Decide which outcomes are eligible for training

The prediction target is:

Is the price return positive from the entry reference point after the signal to the next exit reference point?

A positive return gives label 1; zero or a negative return gives 0. Until the interval ends, the label remains unknown. This is a direction label before trading costs, distinct from the strategy's net performance.

StageTreatment
FeaturesUse only historical information available at the signal
Entry referenceNext observed trading day's close
Exit referenceExecution-day close corresponding to the next monthly signal
Label finalizationAfter the exit price becomes available
Training inclusionOnly labels finalized before that retraining time

At a March 31 signal, a historical sample whose holding interval ends April 1 cannot enter training. An old signal date alone does not make its outcome available.

With date-only data, label_end_date < signal_date is a conservative rule. Using labels that finish on the same day requires price-arrival and training-cutoff timestamps. The logistic regression baseline design shows how to preserve unknown labels and exclude them during training. Here that becomes a common experiment rule.

Separate insufficient preparation from evaluation failure

The minimum training sample requirement is still undecided, so this is not yet a complete executable specification.

Unresolved itemDecision needed
FeaturesColumns, windows, price definitions, availability times
Minimum training historyHistorical span, finalized sample count, class-specific requirements
PeriodsDevelopment/validation/evaluation boundaries and overlapping labels
Model settingsCandidate configurations and selection criteria
Training warningsConditions under which convergence or other warnings invalidate a run
Common startEvaluation start at which all strategies meet preparation requirements

Sample size is not just a number of rows. Three ETFs observed in one month are not equivalent to three independent months. Inspect the historical span and class distribution as well.

  • Before evaluation: verify preparation requirements and fix a shared evaluation calendar.
  • During evaluation: stop on a required-check failure and retain the reason.
  • After changing conditions: record a new configuration and run ID, preserving the earlier failure.

Do not reclassify unfavorable months as warm-up after seeing performance, or present a result excluding failed months as a completed original comparison.

Choosing cash is different from failing to predict

When valid predictions all fall below the threshold, cash is the normal selection result. When insufficient training data or invalid inputs prevent prediction, no investment decision has been produced.

SituationTreatmentRecord
Valid predictions and selected assetsAllocate equallyProbabilities and target weights
Valid predictions, all below thresholdTarget all cashValid signal with no selected assets
Current prediction row has an unknown future labelPermit prediction; defer subsequent classification evaluationUnknown-label state
Minimum training requirement not metFailed runRequired and actual training quantities
Only one class in the training windowFailed runClass counts
Missing/infinite required features or missing asset rowsFailed runDate, asset, and affected column
Fit or prediction errorFailed runError and environment

An unavailable future label is different from an unavailable required feature.

A failed research run is not accepted as a valid completed calculation. This does not define orders for a live account. Do not fill the remaining returns with zeros or insert an imaginary liquidation to manufacture a complete performance series.

Studying a cash fallback separately

A policy that moves to cash when training fails can be studied, but as a separate strategy, not a hidden exception. First specify eligible failures, execution timing, selling costs for existing holdings, when training and investing resume, and how cash-fallback frequency and duration are reported. Its results combine model behavior with a failure-response policy.

A small example of cash versus failure

These are synthetic inputs, not real ETF observations or trained-model outputs.

CaseSYN_ASYN_BSYN_CAction
Assets selected0.600.450.7050% each in A and C
None selected0.400.450.30100% cash
Missing predictionNone0.450.70Error; do not produce weights

The probability-to-target-weight calculation is:

python
from math import isfinitedef target_weights(probabilities, threshold=0.50):    if not isfinite(threshold) or not 0 <= threshold <= 1:        raise ValueError("임계값은 0~1의 유한한 값이어야 합니다")    if not probabilities:        raise ValueError("예측 결과가 없습니다")    if any(        p is None or not isfinite(p) or not 0 <= p <= 1        for p in probabilities.values()    ):        raise ValueError("유효하지 않은 예측 확률입니다")    selected = [        asset        for asset, p in probabilities.items()        if p >= threshold    ]    weights = {asset: 0.0 for asset in probabilities}    if not selected:        return weights, 1.0    for asset in selected:        weights[asset] = 1.0 / len(selected)    return weights, 0.0

The return values are asset target weights and cash target weight. The three cases produce:

text
({'SYN_A': 0.5, 'SYN_B': 0.0, 'SYN_C': 0.5}, 0.0)({'SYN_A': 0.0, 'SYN_B': 0.0, 'SYN_C': 0.0}, 1.0)ValueError: 유효하지 않은 예측 확률입니다

The Korean error message means “Invalid predicted probability.” These cases were executed with synthetic inputs while preparing the revision on October 22, 2026. They do not validate model training or a backtest.

Outside this function, verify that predictions cover every expected asset, refer to the same signal time, and come from successful training. Returned weights are targets before costs and execution. With actual predict_proba output, inspect classes_ to select the class-1 column; columns follow class order. scikit-learn LogisticRegression documentation

Separate retraining from model reselection

Fit preprocessing statistics only on each training window, then transform the current prediction row. Computing means and standard deviations on the entire period before splitting can introduce future information. A Pipeline does not remove the need to select training rows correctly. scikit-learn leakage guidance

ActionTreatment
Retrain on finalized historical data at a predefined scheduleAllowed
Reselect features, thresholds, or model candidates after viewing evaluation resultsSeparate experiment

Adding labels finalized during evaluation to later training is a predefined sequential evaluation procedure. Do not report it as if the model was fitted once and then frozen. Neither approach permits training on outcomes unavailable when a prediction was made.

Record evidence before building the results table

RecordQuestion it answers
Run ID and configuration versionWhich conditions were used?
Input hash, price definition, periodAre inputs comparable?
Evaluation dates and prediction-row countWere any months missing or excluded?
Training span and class countsDid each fit meet requirements?
Label finalization timesWere only available outcomes used?
Probabilities, weights, transaction ledgerHow did predictions become trades?
Costs, cash, terminal treatmentWas accounting consistent?
Warnings, failure reasons, environmentWas the run complete and reproducible?

First align the dates and inputs of completed runs; then separate classification results from net strategy results. High accuracy can coexist with poor net performance if errors occur on large losses or trading is frequent. A smaller drawdown may also reflect more cash exposure.

This article proposes comparison conditions and failure handling. Determining superiority still requires finalizing the unresolved training requirements and period, then producing completed runs with identical input, calendar, and accounting rules. The logistic regression versus tree-model design explains what should remain fixed when adding models.

Report an error or share feedback

Open a draft with this article’s title and URL. Review the message and recipient before sending.

To: [email protected]

Open email draft

If no email app opens, copy these details into your usual email service.

Contact information