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

Hardness benchmark #440

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Hardness benchmark #440

wants to merge 10 commits into from

Conversation

ritalyu17
Copy link

@ritalyu17 ritalyu17 commented Dec 3, 2024

Work in progress Integrated Hardness benchmarking task.

To-do:

  • replace the dataset

@CLAassistant
Copy link

CLAassistant commented Dec 3, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ ritalyu17
❌ pre-commit-ci[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@ritalyu17 ritalyu17 marked this pull request as ready for review December 16, 2024 08:11
@ritalyu17
Copy link
Author

ritalyu17 commented Dec 16, 2024

The hardness benchmark is ready for review and some feedbacks.

Currently, the bayesian optimization component and multi-task component are set to two Benchmark. Main reason for seperating them is because the arguments in simulate_scenarios are different, specifically initial_data. Maybe there is a way to make the code look nicer?

Thank you!

dfComposition_temp = dfComposition_temp.sort_values(by="load")
# if there are any duplicate values for load, drop them
dfComposition_temp = dfComposition_temp.drop_duplicates(subset="load")
# if there are less than 5 values, continue to the next composition
Copy link
Contributor

Choose a reason for hiding this comment

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

Too verbose I think, comments like this can be removed which are very self-explanatory. Overall, just too many comments like this

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Collaborator

Choose a reason for hiding this comment

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

Quick comment from my side as I also have some stuff regarding comments in my review: I agree with @sgbaird that such individual line comments are not necessary. However, I would appreciate a bit more "high-level" comments like "Filtering composition for which less than 5 hardness values are available", descring what a full block of code is doing.

Note that I only unresolved this comment to make it easier for you to spot this comment here of mine, feel free to immediately un-resolve :)

@AVHopp
Copy link
Collaborator

AVHopp commented Dec 19, 2024

Just FYI: I will give my review here mid of January :)

Copy link
Collaborator

@AVHopp AVHopp left a comment

Choose a reason for hiding this comment

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

First of all, thanks for the benchmark :) This is a very first and quick review since I think that minor changes from your end will simplify the review process for me quite significantly. Also, note that the way that there was a PR involving the lookup mechanism (#441 ) This might (or might not) have an influence on your benchmark here.

Hence, I would appreciate if you could rebase your example onto main, verify that this benchmark is compatible with the new lookup and include the first batch of comments. Then I'll be more than happy to give it a full and proper review :)

@AVHopp
Copy link
Collaborator

AVHopp commented Jan 28, 2025

Hello @ritalyu17 just for your information: My work load has shifted quite a bit, and it might take some time for me to properly review here. Just wanted to inform you about this :)

@ritalyu17
Copy link
Author

Thanks for the information. No rush.

Copy link
Collaborator

@AdrianSosic AdrianSosic left a comment

Choose a reason for hiding this comment

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

Hi @ritalyu17, I can take care of further integration but would like to ask you for two things before I start with my review:

  • Can you please rebase the branch on top of the latest main? That is, we need to build the PR on the latest version of the benchmarking module + I'd like to get rid of all the unnecessary merge commits since your PR pretty much orthogonal to what happens else in the repo
  • Can you reformat your files to make them compatible with our code conventions? For that, please have look at any other module of the repo and you'll see what I mean. For example, we should consistently use snake_case for variable names and CamelCase for type definitions.

Please ping me once the changes are incorporated (also in the other PR) and I'll have a look 🙃

@AdrianSosic
Copy link
Collaborator

Hi @ritalyu17, any updates from your end?

@ritalyu17
Copy link
Author

ritalyu17 commented Feb 25, 2025 via email

@ritalyu17
Copy link
Author

ritalyu17 commented Mar 3, 2025

Hi @AdrianSosic, I have updated both benchmarks to match the coding convention with other scripts in the repository.

There is one thing that I couldn't quite figure out with, benchmark for transfer learning. In transfer learning, I want to work with different initial data sizes. But, initial_data argument is only used in simulate_scenarios, is there a way to do this elegantly? (Line 202-216 in Hardness benchmark)

@AdrianSosic
Copy link
Collaborator

Hi @AdrianSosic, I have updated both benchmarks to match the coding convention with other scripts in the repository.

There is one thing that I couldn't quite figure out with, benchmark for transfer learning. In transfer learning, I want to work with different initial data sizes. But, initial_data argument is only used in simulate_scenarios, is there a way to do this elegantly? (Line 202-216 in Hardness benchmark)

Hi @ritalyu17, thanks for pinging me. Yes, there is an easy way to handle the initial_data problem: instead of passing a fixed dataset, just pass an iterable of datasets and omit the n_mc_iterations argument. That way, one MC run will be performed for each dataset you pass.

Once you've included the change, ping me again and I'll have a look at the code 👍🏼

@AdrianSosic
Copy link
Collaborator

Hi @ritalyu17, let me know when changes are incorporated and the branch is rebased 👍🏼

@ritalyu17
Copy link
Author

Hi @AdrianSosic, thanks for the suggestions. This pull request is ready for review.

Copy link
Collaborator

@AdrianSosic AdrianSosic left a comment

Choose a reason for hiding this comment

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

Hi @ritalyu17, thx for the draft. Here my first comments

@@ -0,0 +1,266 @@
# Hardness benchmarking, a maximization task on experimental hardness dataset.
Copy link
Collaborator

Choose a reason for hiding this comment

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

You have a longer explanation in the __main__ section of the script. That should go here, and you can then print it from main via the __doc__ attribute of the file. Overall, it should become very clear from the text what is the goal of this benchmark. Details that are not relevant to understand the overall task, e.g. how exactly the data is loaded (for example, that you consider only contexts with more then 5 points etc) should not be mentioned here but in their respective code section. For example, for the data loading, you'd need to add some data loading function whose docstring/comments explain it.

)

# Set up directory and load datasets
home_dir = os.getcwd()
Copy link
Collaborator

Choose a reason for hiding this comment

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

The data should not live here but in a separate folder, probably under /benchmarks/data/hardness/

home_dir = os.getcwd()
# Materials Project (MP) bulk modulus dataset
df_mp = pd.read_csv(
os.path.join(home_dir, "benchmarks", "domains", "mp_bulkModulus_goodOverlap.csv"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

avoid os.path. Please use pathlib.Path instead for path manipulations

ConvergenceBenchmarkSettings,
)

# Set up directory and load datasets
Copy link
Collaborator

Choose a reason for hiding this comment

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

General comment: you execute all these commands in the main scope of the module, which is suboptimal. Please split the logic up into meaningful pieces and extract them into reasonable functions, e.g. one for data loading, one for data pre-processing (spline interpolation) etc

composition_subset = df_exp[df_exp["composition"] == composition_i]
# Sort the data by load
composition_subset = composition_subset.sort_values(by="load")
composition_subset = composition_subset.drop_duplicates(subset="load")
Copy link
Collaborator

Choose a reason for hiding this comment

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

what if there are multiple identical load values where the other column values differ?

hardness_benchmark = ConvergenceBenchmark(
function=hardness,
settings=benchmark_config,
optimal_target_values=None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

How come we don't know the optimal value? This should be clear from the dataset, no?

ax.set_xlabel("Hardness")
ax.set_ylabel("Frequency")
ax.set_title("Integrated Hardness Distribution")
ax.grid()
Copy link
Collaborator

Choose a reason for hiding this comment

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

plt.show() is missing

Copy link
Collaborator

Choose a reason for hiding this comment

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

file should be called hardness.py

Copy link
Collaborator

Choose a reason for hiding this comment

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

Changelog entry is missing

Copy link
Collaborator

Choose a reason for hiding this comment

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

Some general comment: the basic code requirements are not yet met, because it seems you haven't installed the pre-commit hooks while developing. Please:

  • Run the hooks (you can also trigger them manually via pre-commit run --all-files) and fix the problems
  • Run mypy and fix the typing issues.

You can also find more information here: https://emdgroup.github.io/baybe/stable/misc/contributing_link.html

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.

6 participants