Created
September 2, 2022 18:46
-
-
Save Kazanskyi/9c7ee70838de067f950be687163cd6fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for j, i in enumerate(targets_all): | |
remove_redundant_list = list(targets_all) | |
remove_redundant_list.remove(i) | |
new_column_classification = i + "_classification" | |
# first let's create a new column with the 150days prediction classifier: 0 when price dropped and 1 when it's increased. | |
df_compact_reserve.loc[df_compact_reserve[i]<0.01, new_column_classification] = 0 | |
df_compact_reserve.loc[df_compact_reserve[i]>=0.01, new_column_classification] = 1 | |
#let's join prediction result to the test dataframe and get indexes | |
df_prediction = list_of_test_df[j].copy() | |
df_prediction["prediction"] = list_of_ypred[j] | |
df_prediction = df_prediction["prediction"] | |
#let's connect prediction result by indexes to the main dataframe | |
df_compare = df_compact_reserve[[i,new_column_classification]] | |
df_compare = df_compare.join(df_prediction, how = 'left') | |
df_compare = df_compare[df_compare["prediction"].notnull()] | |
# Now let's see how many negative values were really predicted as positive | |
df_compare = df_compare[[new_column_classification,"prediction"]].groupby(new_column_classification).sum() | |
df_compare["Value, %"] = (df_compare['prediction'] / df_compare['prediction'].sum()) * 100 | |
print(f"{i} precision is ") | |
print(str(round(df_compare["Value, %"][1],2)) + "%\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment