README Last Updated by Hamed on 2/13/19
- Consistent results and outputs, both in terms of format and in terms of ensuring results are valid and without bugs
- Collaboration and awareness of peer analytics through leaderboard summaries and access to model code
- Automated calculation of various model performance metrics
- Automated selection of future experiments to run (coming soon for protein design and perovskites)
You can use the Test Harness locally or with TACC resources such as Maverick2.
Python 3 should be used when using the Test Harness.
- Clone this repository into the environment of your choice (directory, conda env, virtualenv, etc)
- Using command-line, navigate to the directory in which you cloned this repo (not inside the repo itself).
- Run
pip3 install test-harness
orpip3 install -e test-harness
. This will install thetest-harness
package and make it visible to all other repositories/projects you have in the current environment. The-e
option stands for "editable". This will install the package in a way where any local changes to the package will automatically be reflected in your environment. See this link for more details.
Note: for some reason I cannot install the package on Maverick2 unless I use the -e
option and also --user
: pip3 install -e test-harness --user
First create a script file in your environment
(see the example_scripts
folder for examples), then:
- In your script, import modules from the
test-harness
package you installed earlier. For example,from harness.test_harness_class import TestHarness
- Create a TestHarness object with
output_location
path - Use the
run_custom
orrun_leave_one_out
methods - Results will be output in a
test_harness_results
folder whose location depends on the path you give tooutput_location
when initializing your TestHarness object.
There are 2 types of runs currently supported in the Test Harness: Custom Runs and Leave-One-Out Runs More details coming soon (probably in pydoc format)
Feature Extraction is controlled with the feature_extraction
option. Valid values are:
- False --> Feature Extraction is not carried out
- True --> The
eli5_permutation
method is used - "eli5_permutation" --> Uses the eli5 package's implementation of permutation importance for SkLearn Models. A more general version that isn't specific to sklearn models will be added in the future.
- "rfpimp_permutation" --> Uses the rfpimp package's implementation of permutation importance for Random Forest Models only.
- "shap_audit" --> SHapley Additive exPlanations
- "bba_audit" --> Black Box Auditing by Haverford Team
Feature Extraction results are saved in the file feature_importances.csv
in the appropriate subfolder within the results
folder.
Note: In a test that I ran, I got significantly different results from the two different implementations of permutation importance: this needs to be investigated.
ssh [email protected]
- Enter user/pass/auth-code
module load tacc-singularity/2.6.0
- Not necessary if you make singularity part of your default set of modules using "module save"
- Only do these ONCE: first get on a compute node by using the
idev
command. Then runsingularity pull docker://eram5/test-harness:3.2
- This is only needed the first time you're pulling the image, or if you want to pull an updated version of the image.
- This will build a singularity image from the docker container and store it in a ".simg" file under singularity_cache
- The path to the ".simg" file will be printed out, make sure to save the path for everytime you need to kick off a singularity shell!
cd [wherever you're working]
. e.g.cd $WORK
(cdw
is equivalent) followed bycd protein-design
idev -m 100
[or however many minutes you want the session to last]- Note: if you want to keep a session going after you exit terminal (or get disconnected), you could use the
screen
command beforeidev
- Note: if you want to keep a session going after you exit terminal (or get disconnected), you could use the
singularity shell --nv /work/05260/hamed/singularity_cache/test-harness-3.2.simg
--> path is different for each user!- The path is the one that was printed when you first pulled the docker container
- This starts an interactive singularity shell and places you within it
Note: if you try to install things within the singularity container,
you probably will have to add the "--user" parameter at the end,
e.g. pip3 install pandas --user
. Ideally you would install all requirements within your dockerfile though
View the sbatch_example.slurm
file in the example_scripts
folder. As you can see the sbatch_example.slurm
file is pretty self-explanatory.
In the last line you can see the command that runs example_script.py
. In this case there is just one command being run, but you can add more if you would like.
Just keep in mind that the commands will be run in serial on a single node. To access multiple nodes and parallelization, you can either manually kick off more
jobs in the same way, or you can use launcher (see below for the guide to that).
- The command to run a
slurm
file issbatch sbatch_example.slurm
. - You can view the progress of your job in realtime by using
tail -f [name_of_my_job_id_file]
Running non-interactively using Sbatch/Slurm, combined with parallelization using Launcher and Argparse:
Looking at the example_scripts
folder, there are 3 files that are used for this:
example_script_argparse.py
--> the script I am runningjobfile_example
--> just a list of the jobs I want to run. Make sure you have an empty line at the end of this file or your last line won't be read!launcher_example.slurm
--> slurm file that uses Launcher to organize and split up tasks in thejobfile
over multiple nodes so they can run in parallel
Once again you would use the sbatch
and tail
commands to kick off your jobs and view their progress.
** Please note that if you installed the test-harness
package without the -e
option,
then if you make any major changes to the test-harness
package, you will have to
reinstall the package to update it.
The Test Harness consists of several parts that work together.
- Test Harness Model Classes and Instances: Basically just wrappers for your ML model so that the Test Harness can know how to run your model.
- All TH-Model Classes must subclass from the abstract base classes in
test_harness_models_abstract_classes.py
. A Model Class defines how to fit and predict. - Once a TH-Model Class is created (e.g. SklearnClassification), TH-Model Instances can be created with specific models passed in.
- All TH-Model Classes must subclass from the abstract base classes in
test_harness_class.py
contains theTestHarness
class, which allows the user to add and execute different types of runs (custom, leave-one-out).run_classes.py
defines the_BaseRun
class that is used by theTestHarness
class to carry out runs.- Script files that run the Test Harness. This is where you implement the Test Harness and use its methods to run your models.
As a user, you will mainly be concerned with the Test Harness model classes/instances
(bullet 1 above), and the script files (bullet 4 above).
By choosing an output_location
when instantiating your TestHarness
object,
you can dictate where the results of your runs go. For example if you want the results of
a certain set of runs to be isolated from other runs, you can set a previously unused
path to be your output_location
.
For submitting to the SD2-wide leaderboard, set your output_location
to the following path
in sd2e-community depending on your challenge problem:
- Protein Design:
/sd2e-community/protein-design/test-harness-outputs
- Perovskites: tbd