-
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.
- Loading branch information
Showing
10 changed files
with
140 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
sets=( | ||
"diffusion" | ||
) | ||
|
||
grid=(0.001 0.01 0.1 1.0 10.0 100.0 1000.0) | ||
|
||
for i in "${sets[@]}" | ||
do | ||
|
||
for j in "${grid[@]}" | ||
do | ||
|
||
echo "runs/${i}/${j}" | ||
|
||
mkdir -p "runs/${i}" | ||
cp -r template "runs/${i}/${j}" | ||
|
||
cd "runs/${i}/${j}" | ||
sed -i "s/replace_data/'${i}'/g" fit.py | ||
sed -i "s/replace_bw/bandwidth=${j}/g" fit.py | ||
|
||
cd - > /dev/null | ||
|
||
done | ||
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}) | ||
qsub ${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,78 @@ | ||
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 | ||
|
||
|
||
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', replace_bw) | ||
|
||
# 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 = [('calibration', RepeatedKFold(n_repeats=n_repeats))] | ||
|
||
# Boostrap, cluster data, and generate splits | ||
for i in [2, 3]: | ||
|
||
# Cluster Splits | ||
top_split = BootstrappedLeaveClusterOut( | ||
AgglomerativeClustering, | ||
n_repeats=n_repeats, | ||
n_clusters=i | ||
) | ||
|
||
splits.append(('agglo_{}'.format(i), top_split)) | ||
|
||
# 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:{}'.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 @@ | ||
#PBS -S /bin/bash | ||
#PBS -m be | ||
#PBS -q morgan | ||
#PBS -l select=1:ncpus=12:mpiprocs=12 | ||
#PBS -l walltime=72:00:00 | ||
#PBS -N job | ||
|
||
cd $PBS_O_WORKDIR | ||
|
||
./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
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
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