Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing conf band creation in prohpet predict function
Summary: **Current Logic Issue: Incorrect Anomaly Response Behavior** In the current implementation, we are simply populating the reference to predicted time series as the confidence band. This is not the expected behavior for `AnomalyResponse` constructor, as it expects time series to be independent. The issue arises from the fact that changing one anomaly response parameter affects another. Specifically, when we modify the upper bound of the confidence band, it also changes the `predicted_ts` parameter. This leads to incorrect results when calling the "extend" function on an `AnomalyResponse` object created by Prophet's predict method. As a result, we end up extending the `predicted_ts` three times when calling the "extend" function. **Example Use Case:** Suppose we have an `AnomalyResponse` object created by Prophet's predict method, and we want to extend its time series using the "extend" function. With the current logic, this would lead to incorrect results, as the `predicted_ts` parameter would be extended three times. ```python anomaly_response = prophet.predict(...) print(len(anomaly_response.predicted_ts.toList)) # e.g., 10 anomaly_response2 = prophet.predict(...) print(len(anomaly_response2.predicted_ts.toList)) # e.g., 100 anomaly_response.extend(anomaly_response2) # incorrect results print(len(anomaly_response.predicted_ts.toList)) # currently returns 310 ``` **Solution:** To fix this issue, we need to modify the logic to generate the time series independently and avoid affecting other parameters when changing one anomaly response parameter. We can achieve this by creating a copy of the time series instead of referencing the original one. ```python # Create a copy of the time series anomaly_response.confidence_band = anomaly_response.confidence_band.copy() # Now, modifying the upper bound of the confidence band will not affect the predicted_ts parameter anomaly_response.confidence_band.upper = ... ``` By making this change, we ensure that the time series are independent, and modifying one anomaly response parameter does not affect another. Differential Revision: D66768001 fbshipit-source-id: 07f2eff2fe991d1d3480c439966072e73ee5986a
- Loading branch information