Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

myrmarachne
Copy link
Member

No description provided.

@codecov-commenter
Copy link

Codecov Report

Merging #136 (ee96a43) into master (5fc5ed9) will increase coverage by 0.09%.
The diff coverage is n/a.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Impacted file tree graph

@@            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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5fc5ed9...ee96a43. Read the comment docs.

@@ -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 """
Copy link
Collaborator

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

Copy link
Collaborator

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)
Copy link
Collaborator

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?

@myrmarachne myrmarachne closed this Jun 7, 2024
@myrmarachne myrmarachne deleted the z_score_refactor branch January 9, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants