rheon.ReadinessWarning¶
- class rheon.ReadinessWarning[source]¶
Bases:
RheonWarning,UserWarningA warning that a model is not ready, or may never become ready.
It points once at a state every row already carries in
withheld_reason,settled_fracandsupport_coef, so you can act before reading the output. Where the finding is intended, filter it out withwarnings.simplefilter("ignore", rheon.ReadinessWarning). Is it ready? sets each finding beside the gates that withhold a prediction.The learning calls issue it:
ModelBank.fit(),ModelBank.fit_predict(),ModelBank.fit_predict_batches()andlf.rheon.fit_predict.predictnever does. Apart from the two findings about a horizon, it is issued once per spec and group. Its message begins with the spec, and the group where the spec has one, asspec "m" group "g":. Undergroup_close="session"each session span is a stream of its own, so the warning is issued once per span, which the message names by its session value, asspec "m" group "g" session "a":(session nullfor a null value). Two spans with the same finding then give two texts, and Python’s default filter, which shows a text once per line of code, shows both.It reports five findings:
A coefficient the ridge determined more than the data did (
support_coefbelow 0.5), named, on a row the gates let through. The features do not determine such a coefficient: a duplicated or constant column, or a ridge as large as the feature’s variance does this. While the columns stay collinear, the predictions do not depend on the split. The split among such columns is arbitrary, and it moves the moment the collinearity breaks.The ``max_error_inflation`` gate has not been met. The gate has withheld every row for a further half-life, and at the row rate so far
error_inflationstays abovemax_error_inflation, so predictions stay withheld unless the rows come faster. The message says how far, and gives a half-life above which the gate is met, or a looser ratio. Where the model has not fit at all, itsweight_sumshort of a row per coefficient, the message gives whereweight_sumtops out instead. Akalmannever issues it, since its gate reads each row’s own value, which a row nearer the design’s center reads lower.A
min_weighthas not been met. The floor has withheld every row for a further half-life, and the weight a target reads tops out below itsmin_weight. The message names that ceiling (weight_sum_settledinModelBank.summary()), and themin_weightorhalf_lifethat meets it. A target that no row with a positive weight has given a value has no rate to project from, so its message says that instead. A target whose own weight is belowweight_sumhas not been learned from every row, and its weight falls on each row without it. Its message says so, with the ceiling the floor would have if every row carried the target, where that ceiling is below the floor.A diagnostic has no horizon. A spec with a
clockand anembargobut nohorizon_rowshas a diagnostic that reads the target’s horizon (emit_calibration,emit_breaks,emit_specificationoremit_robust_se). Thereembargois in clock units, so the horizon is 0, and a target that looks ahead flags the test on most rows. The message nameshorizon_rows, once per diagnostic, on the bank’s first learning call.The Newey-West lags were capped at 64. Without a clock,
embargois in rows and gives the horizon. A diagnostic that reads the horizon takes twice the horizon in Newey-West lags, and at most 64 when they are read fromembargo. The message gives the lags asked for, and nameshorizon_rows(to take them all) androbust_se_lags. It begins with the spec alone, and comes on the bank’s first learning call.
Offline,
rheon.gram.lasso_path()issues it once per call for the penalties whose coordinate descent ran out of itsmax_itersweeps before it met its stopping rule, naming them. Each such penalty’s row of the path is where its descent stopped. Thelassomodel counts the same event inModelBank.solve_failures(), except on a Gram with too few rows for its features, its warm-up.Examples
This code reads
dffrom Example data:import warnings # 400 rows a step apart, with a half-life of 20 steps: the weight tops out near 29. spec = rp.spec.ewridge( "ridge", targets=["y"], features=["x0", "x1"], clock="t", half_life=20.0, gap_cap=5.0, min_weight=50.0, ) with warnings.catch_warnings(record=True) as caught: warnings.simplefilter("always") rp.ModelBank([spec]).fit_predict(df) for w in caught: print(type(w.message).__name__, str(w.message).split(" has not")[0])
ReadinessWarning spec "ridge": min_weight = 50
See also
Is it ready?, the gates and what each finding means for the output.
ModelBank.summary(), whoseweight_sum_settledis the ceiling themin_weightfinding names.RheonWarning, the base class every warning of this library shares.
Notes
The first three findings judge a model only once its
settled_fracreaches 0.95, the model within 5% of its steady state. Before then, its early rows still move what the warning would say, and a warning cannot be taken back: the first rows’ noisy feature variances, for example, can read a share of the data below 0.5 that later rows do not. Where nothing decays,settled_fracis null, so the model is never judged, and itssupport_coef,withheld_reasonandModelBank.summary()carry what it reads.The noise-gate and
min_weightfindings wait a half-life during which their gate withholds every row, on the clock the learned rows have covered. A row the gate lets through starts the wait again. The wait is in the state file: a bank saved and loaded inside it goes on waiting, and issues its warning on the row an unbroken stream would. Underembargoboth findings read thesettled_fracof the rows the model has learned from, on the clock its weight has covered. The row’s ownsettled_fraccounts the held rows’ clock too.Both findings project a ceiling from the rows so far, and rows that come faster can beat it, so neither says the gate is unmet for good. At the rows’ spacing
dand weight so far, themin_weightceiling is1 / (1 - 2 ** (-d / half_life))times that weight. With a clock,dis known only from the rows, so the ceiling cannot be read from the spec before the rows arrive. A warning on a row of weight 0, or on rows too uneven to project (one row far heavier than the rest, or a stream whose weight is still its first row’s), gives no figure. A target the rows stopped carrying gets no figure where rows that each carried it would meet the floor, since its weight falls toward 0 once the rows stop carrying it.