MCPcopy
hub / github.com/facebook/prophet / piecewise_linear

Method piecewise_linear

python/prophet/forecaster.py:1297–1315  ·  view source on GitHub ↗

Evaluate the piecewise linear function. Parameters ---------- t: np.array of times on which the function is evaluated. deltas: np.array of rate changes at each changepoint. k: Float initial rate. m: Float initial offset. changepoint_ts: np.arr

(t, deltas, k, m, changepoint_ts)

Source from the content-addressed store, hash-verified

1295
1296 @staticmethod
1297 def piecewise_linear(t, deltas, k, m, changepoint_ts):
1298 """Evaluate the piecewise linear function.
1299
1300 Parameters
1301 ----------
1302 t: np.array of times on which the function is evaluated.
1303 deltas: np.array of rate changes at each changepoint.
1304 k: Float initial rate.
1305 m: Float initial offset.
1306 changepoint_ts: np.array of changepoint times.
1307
1308 Returns
1309 -------
1310 Vector y(t).
1311 """
1312 deltas_t = (changepoint_ts[None, :] <= t[..., None]) * deltas
1313 k_t = deltas_t.sum(axis=1) + k
1314 m_t = (deltas_t * -changepoint_ts).sum(axis=1) + m
1315 return k_t * t + m_t
1316
1317 @staticmethod
1318 def piecewise_logistic(t, cap, deltas, k, m, changepoint_ts):

Callers 4

predict_trendMethod · 0.95
test_piecewise_linearMethod · 0.95

Calls

no outgoing calls

Tested by 1

test_piecewise_linearMethod · 0.76