Skip to content

Commit

Permalink
Display number of points in the KS-Test graph
Browse files Browse the repository at this point in the history
  • Loading branch information
onyb committed Jun 21, 2021
1 parent 3864ffb commit d4c337d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def get_breakpoints_suggestions():
]
title_ks = wrap_title(title_tokens, chunk_size=4)

df_breakpoints = ks_test_engine(
df_breakpoints, df_size = ks_test_engine(
df=df,
predictor_name=predictor,
error_name=loader.error_type.name,
Expand All @@ -499,14 +499,20 @@ def get_breakpoints_suggestions():

plot = plot_ks_stats(
df=df_breakpoints,
node=title_ks,
node=title_ks + f"\n\nNo. of points: {df_size}",
predictor=predictor,
unit=loader.units["predictors"][predictor],
)
df_breakpoints = format_ks_stats(df_breakpoints)

return Response(
json.dumps({"records": df_breakpoints.to_dict("records"), "figure": plot}),
json.dumps(
{
"records": df_breakpoints.to_dict("records"),
"figure": plot,
"count": df_size,
}
),
mimetype="application/json",
)

Expand Down
2 changes: 1 addition & 1 deletion core/postprocessors/ks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def ks_test_engine(
df_result.at[idx, "pValue"] = -1 * np.log(pvalue)
df_result.at[idx, "dStatValue"] = statistic

return df_result
return df_result, len(df)


def format_ks_stats(df: pd.DataFrame) -> pd.DataFrame:
Expand Down

0 comments on commit d4c337d

Please sign in to comment.