-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed the examples so that they look like what I have in the paper.…
… I could add more, but wont
- Loading branch information
Showing
9 changed files
with
116 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
sets=( | ||
"friedman1" | ||
"fluence" | ||
"diffusion" | ||
"steel_yield_strength" | ||
"super_cond" | ||
) | ||
|
||
mkdir -p runs | ||
for i in "${sets[@]}" | ||
do | ||
|
||
echo ${i} | ||
cp -r template "runs/${i}" | ||
cd "runs/${i}" | ||
|
||
sed -i "s/replace_data/'${i}'/g" fit.py | ||
|
||
cd - > /dev/null | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
submit=submit.sh | ||
for i in $(find ${1} -type f -name ${submit}) | ||
do | ||
cd $(dirname ${i}) | ||
sbatch ${submit} | ||
cd - > /dev/null | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from sklearn.cluster import AgglomerativeClustering | ||
from sklearn.ensemble import RandomForestRegressor | ||
from sklearn.model_selection import RepeatedKFold | ||
from sklearn.model_selection import GridSearchCV | ||
from sklearn.preprocessing import StandardScaler | ||
from sklearn.pipeline import Pipeline | ||
|
||
from madml.ml.splitters import BootstrappedLeaveClusterOut | ||
from madml.models.space import distance_model | ||
from madml.models.combine import domain_model | ||
from madml.models.uq import calibration_model | ||
from madml.ml.assessment import nested_cv | ||
from madml import datasets | ||
|
||
import numpy as np | ||
|
||
|
||
def main(): | ||
|
||
run_name = 'run' | ||
data_name = replace_data | ||
|
||
# Load data | ||
data = datasets.load(data_name) | ||
X = data['data'] | ||
y = data['target'] | ||
g = data['class_name'] | ||
n_repeats = 5 | ||
|
||
# ML Distance model | ||
ds_model = distance_model(dist='kde') | ||
|
||
# ML UQ function | ||
uq_model = calibration_model(params=[0.0, 1.0]) | ||
|
||
# ML | ||
scale = StandardScaler() | ||
model = RandomForestRegressor() | ||
|
||
# The grid for grid search | ||
grid = {} | ||
grid['model__n_estimators'] = [100] | ||
|
||
# The machine learning pipeline | ||
pipe = Pipeline(steps=[ | ||
('scaler', scale), | ||
('model', model), | ||
]) | ||
|
||
# The gridsearch model | ||
gs_model = GridSearchCV( | ||
pipe, | ||
grid, | ||
cv=((slice(None), slice(None)),), # No splits | ||
) | ||
|
||
# Types of sampling to test | ||
splits = [('fit', RepeatedKFold(n_repeats=n_repeats))] | ||
|
||
# Fit models | ||
model = domain_model(gs_model, ds_model, uq_model, splits) | ||
cv = nested_cv(X, y, g, model, splits, save=run_name) | ||
cv.assess() | ||
cv.push('leschultz/cmg-rf-{}:latest'.format(data_name)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
export PYTHONPATH=$(pwd)/../../../../../src:$PYTHONPATH | ||
|
||
rm -rf run | ||
python3 fit.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
#SBATCH --partition=morgan | ||
#SBATCH --time=7-00:00:00 | ||
#SBATCH --nodes=1 | ||
#SBATCH --ntasks-per-node=40 | ||
#SBATCH --mem-per-cpu=4000 | ||
#SBATCH --error=job.e.%J | ||
#SBATCH --output=job.o.%J | ||
|
||
./run.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
#!/bin/bash | ||
|
||
sets=( | ||
"friedman1" | ||
"fluence" | ||
"diffusion" | ||
"steel_yield_strength" | ||
"super_cond" | ||
) | ||
|
||
gtgrid=( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters