-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor refactor of z-score to use the correct standard deviation #136
Conversation
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. @@ Coverage Diff @@
## master #136 +/- ##
==========================================
+ Coverage 76.71% 76.81% +0.09%
==========================================
Files 227 227
Lines 9071 9071
==========================================
+ Hits 6959 6968 +9
+ Misses 2112 2103 -9 see 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
@@ -13,25 +13,17 @@ | |||
# limitations under the License. | |||
|
|||
from numpy import log | |||
from qf_lib.common.utils.numberutils.is_finite_number import is_finite_number | |||
from qf_lib.containers.series.qf_series import QFSeries | |||
|
|||
|
|||
def z_score_outliers_cut(series: QFSeries) -> QFSeries: | |||
""" Compute z-score for a series with logarithm the series and cutting std above 2 and -2 """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(old) grammatical error in the docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the std is not cut, it's the z-score
shift_value = 1 - clean_series.min() | ||
log_series = log(clean_series.values.astype(float) + shift_value) | ||
shift_value = 1 - series.min() | ||
log_series = log(series.astype(float) + shift_value) | ||
result = (log_series - log_series.mean()) / log_series.std() | ||
|
||
# constraint the limits at +-2 | ||
result = result.clip(-2, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be a parameter?
No description provided.