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

[fix]: bug DateUtil + optimization #85

Merged
merged 2 commits into from
Nov 12, 2021
Merged

[fix]: bug DateUtil + optimization #85

merged 2 commits into from
Nov 12, 2021

Conversation

dat-lequoc
Copy link
Contributor

Can you review my pull request? @danymat @beng-git

@danymat
Copy link
Owner

danymat commented Nov 9, 2021

Hello, can you describe me those changes ?

Comment on lines 6 to 7
df = df_anon.copy()
df_original_reduced = df_original.copy()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to keep this line because by not doing a copy, the data frames will be modified (even outside function)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to keep this line because by not doing a copy, the data frames will be modified (even outside function)

Ok. I didn't know that. Thanks.

Hello, can you describe me those changes ?

Yeah, sure!
First, I keep the code which verifies weeks are all the same. Then because of that, we can retrieve the day_of_week using pandas.Series.dt.dayofweek .

abs(df_anon.date.dt.dayofweek - df_original.date.dt.dayofweek)

I calculate the difference between 2 series. The result is a pandas.Series whose values are from 0 to 6.

Now, I store 3 - result to df_score. 3 means 3 points (I'll divide later).

df_score = 3 - abs(df_anon.date.dt.dayofweek - df_original.date.dt.dayofweek)

Values of df_score is in [ -3 : 3]

return df_score.loc[df_score > 0].sum() / 3 / nb_orig_line

Finally, we choose only values that bigger than 0 and do the addition, we divide the result by 3 and number_of_lines.

@danymat
Copy link
Owner

danymat commented Nov 12, 2021

@beng-git I'm merging this PR into the INSAnonym-utils metrics, but we need to be careful: new merged changes (since #81) are still not taken into account in INSAnonym website

@danymat danymat merged commit 4139ef6 into danymat:main Nov 12, 2021
@dat-lequoc
Copy link
Contributor Author

@beng-git I'm merging this PR into the INSAnonym-utils metrics, but we need to be careful: new merged changes (since #81) are still not taken into account in INSAnonym website

I'd like to you if it'll be changed before the competition?

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.

2 participants