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

MVP Surrogate Plugin ML/AI #1163

Merged
merged 32 commits into from
Dec 13, 2023

Conversation

franflame
Copy link
Contributor

@franflame franflame commented Sep 5, 2023

#1158

Summary/Motivation:

Added MVP surrogate plugin for creating ML/AI models

Instructions to run new plugins, applicable to all three: keras_nn, pytorch_nn, and scikit_nn:
(optional steps are marked with *)

  • Click on home button/"Session" and select "Open Session..."

  • Open the file FOQUS/examples/tutorial_files/Flowsheets/Tutorial_4/Simple_flow.foqus

  • Click on "Surrogate"

  • Under the "Tool:" dropdown, select either keras_nn, pytorch_nn, or scikit_nn
    *If you go to the "Data" tab, you should see that the "Flowsheet Results" have been populated

  • Go to the tab "Variables" to select your desired input and output variables
    *You can change various settings with "Method Settings"

  • Press the green play button to start the training process

  • Go to the "Execution" tab to see the output of the plugin

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the copyright and license terms described in the LICENSE.md file at the top level of this directory.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

Attention: 40 lines in your changes are missing coverage. Please review.

Comparison is base (cb938bf) 37.67% compared to head (39a1d6f) 38.52%.

Files Patch % Lines
foqus_lib/framework/surrogate/scikit_nn.py 83.06% 16 Missing and 5 partials ⚠️
foqus_lib/framework/surrogate/pytorch_nn.py 92.81% 8 Missing and 4 partials ⚠️
foqus_lib/framework/surrogate/keras_nn.py 94.81% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1163      +/-   ##
==========================================
+ Coverage   37.67%   38.52%   +0.85%     
==========================================
  Files         160      163       +3     
  Lines       36439    36880     +441     
  Branches     5961     5995      +34     
==========================================
+ Hits        13727    14208     +481     
+ Misses      21609    21562      -47     
- Partials     1103     1110       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@bpaul4 bpaul4 left a comment

Choose a reason for hiding this comment

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

@franflame this is very nice! I tested it locally and it ran smoothly. Just a few minor comments, overall the MVP looks good.

foqus_lib/framework/surrogate/keras_nn.py Show resolved Hide resolved
foqus_lib/framework/surrogate/keras_nn.py Outdated Show resolved Hide resolved
foqus_lib/framework/surrogate/keras_nn.py Outdated Show resolved Hide resolved
foqus_lib/framework/surrogate/keras_nn.py Outdated Show resolved Hide resolved
foqus_lib/framework/surrogate/keras_nn.py Outdated Show resolved Hide resolved
foqus_lib/framework/surrogate/keras_nn.py Outdated Show resolved Hide resolved
foqus_lib/framework/surrogate/keras_nn.py Outdated Show resolved Hide resolved
@ksbeattie ksbeattie added the Priority:High High Priority Issue or PR label Sep 12, 2023
@lbianchi-lbl lbianchi-lbl requested a review from bpaul4 November 22, 2023 21:20
@bpaul4
Copy link
Contributor

bpaul4 commented Nov 27, 2023

@franflame @lbianchi-lbl I just tested this by manually executing the "Simple_flow" test in the GUI, checking the save locations and loading behavior of the saved model files, and fixing a few typos to make the Spell Checker happy. It looks very nice, great work! The .keras extension is different than the .h5 extension we use in the ML AI Plugin but seems to work properly. The Plugin currently assumes file extensions directly correspond to model types and doesn't account for same-name models of different extensions, so we should probably update that in a separate PR.

I wasn't able to add samples after loading from a CSV file. Loading from a flowsheet node worked great. Would there be a way to use loaded data that does exist on the flowsheet to generate samples that the "Variables" tab can recognize? The UQ module may give some inspiration for how to do this.

Copy link
Contributor

@bpaul4 bpaul4 left a comment

Choose a reason for hiding this comment

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

Everything is good, GUI and data improvements planned for future updates.

@lbianchi-lbl lbianchi-lbl merged commit c11cc51 into CCSI-Toolset:master Dec 13, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ML/AI Machine Learning/Artificial Intelligence Priority:High High Priority Issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants