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

optimize make_typos #211

Merged

Conversation

stevebachmeier
Copy link
Contributor

@stevebachmeier stevebachmeier commented Jul 7, 2023

Title: Optimize make_typos

Description

The make_typos noising function is notoriously slow. This PR
makes it run 3-4x faster. There is almost certainly more optimization
that can be done; I'm all ears if you've got any ideas!

Rajan and Imessed around for a bit with speeding up pd.Series.str::isin()
but couldn't find any appreciable gains. I poked around online a bit
on an alternative to isin but the stuff I found either didn't work
well or seemed too complicated.

I previously tried implementing numba with no luck (refer to the
Jira ticket for details). I might try and implement numba now that the
function is much simpler with a lot less loops. Open to ideas here as well.

Testing

Pytests pass.

characters = orig.copy()
characters[replace_mask] = typos
characters[keep_original_mask] = characters + orig
noised_column = noised_column + characters
Copy link
Contributor

Choose a reason for hiding this comment

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

Clever how you did all of this.

@stevebachmeier stevebachmeier merged commit 2e7213c into develop Jul 7, 2023
@stevebachmeier stevebachmeier deleted the feature/sbachmei/MIC-3938-optimize-make-typos branch July 7, 2023 19:47
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