Skip to content

Commit 042401c

Browse files
committed
GPR models saved and pickled
1 parent 0389fcc commit 042401c

8 files changed

Lines changed: 49 additions & 24 deletions

2_Paper_Reproduction.ipynb

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
},
9393
{
9494
"cell_type": "code",
95-
"execution_count": 213,
95+
"execution_count": 3,
9696
"metadata": {},
9797
"outputs": [],
9898
"source": [
@@ -103,7 +103,7 @@
103103
},
104104
{
105105
"cell_type": "code",
106-
"execution_count": 214,
106+
"execution_count": 4,
107107
"metadata": {},
108108
"outputs": [
109109
{
@@ -206,7 +206,7 @@
206206
"4 CS-NRCan-014_A6 1.5 6.0 1.0 66 0.655983 0.344017 EXP"
207207
]
208208
},
209-
"execution_count": 214,
209+
"execution_count": 4,
210210
"metadata": {},
211211
"output_type": "execute_result"
212212
}
@@ -218,7 +218,7 @@
218218
},
219219
{
220220
"cell_type": "code",
221-
"execution_count": 90,
221+
"execution_count": 5,
222222
"metadata": {},
223223
"outputs": [
224224
{
@@ -328,7 +328,7 @@
328328
"4 HY "
329329
]
330330
},
331-
"execution_count": 90,
331+
"execution_count": 5,
332332
"metadata": {},
333333
"output_type": "execute_result"
334334
}
@@ -339,7 +339,7 @@
339339
},
340340
{
341341
"cell_type": "code",
342-
"execution_count": 109,
342+
"execution_count": 6,
343343
"metadata": {},
344344
"outputs": [
345345
{
@@ -683,7 +683,7 @@
683683
"22 1.666667e-01 0.000000 RND "
684684
]
685685
},
686-
"execution_count": 109,
686+
"execution_count": 6,
687687
"metadata": {},
688688
"output_type": "execute_result"
689689
}
@@ -701,7 +701,7 @@
701701
},
702702
{
703703
"cell_type": "code",
704-
"execution_count": 215,
704+
"execution_count": 7,
705705
"metadata": {},
706706
"outputs": [],
707707
"source": [
@@ -711,7 +711,7 @@
711711
},
712712
{
713713
"cell_type": "code",
714-
"execution_count": 216,
714+
"execution_count": 8,
715715
"metadata": {},
716716
"outputs": [
717717
{
@@ -1289,7 +1289,7 @@
12891289
"23 RND "
12901290
]
12911291
},
1292-
"execution_count": 216,
1292+
"execution_count": 8,
12931293
"metadata": {},
12941294
"output_type": "execute_result"
12951295
}
@@ -1300,7 +1300,7 @@
13001300
},
13011301
{
13021302
"cell_type": "code",
1303-
"execution_count": 217,
1303+
"execution_count": 9,
13041304
"metadata": {},
13051305
"outputs": [
13061306
{
@@ -1491,7 +1491,7 @@
14911491
"[64 rows x 8 columns]"
14921492
]
14931493
},
1494-
"execution_count": 217,
1494+
"execution_count": 9,
14951495
"metadata": {},
14961496
"output_type": "execute_result"
14971497
}
@@ -1502,7 +1502,7 @@
15021502
},
15031503
{
15041504
"cell_type": "code",
1505-
"execution_count": 95,
1505+
"execution_count": 10,
15061506
"metadata": {},
15071507
"outputs": [
15081508
{
@@ -1583,7 +1583,7 @@
15831583
},
15841584
{
15851585
"cell_type": "code",
1586-
"execution_count": 218,
1586+
"execution_count": 11,
15871587
"metadata": {},
15881588
"outputs": [],
15891589
"source": [
@@ -1651,7 +1651,7 @@
16511651
},
16521652
{
16531653
"cell_type": "code",
1654-
"execution_count": 219,
1654+
"execution_count": 12,
16551655
"metadata": {},
16561656
"outputs": [],
16571657
"source": [
@@ -1672,22 +1672,22 @@
16721672
},
16731673
{
16741674
"cell_type": "code",
1675-
"execution_count": 220,
1675+
"execution_count": 30,
16761676
"metadata": {},
16771677
"outputs": [],
16781678
"source": [
16791679
"# define 3 models with with kernels with 3 different lengthscales\n",
1680-
"gpr_model_0 = GaussianProcessRegressor(kernel=Matern(length_scale= [1,1,1], nu=1.5), alpha = 1e-5, n_restarts_optimizer=5)\n",
1681-
"gpr_model_1 = GaussianProcessRegressor(kernel=Matern(length_scale= [1,1,1], nu=1.5), alpha = 1e-5, n_restarts_optimizer=5)\n",
1682-
"gpr_model_2 = GaussianProcessRegressor(kernel=Matern(length_scale= [1, 1,1], nu=1.5), alpha = 1e-10, n_restarts_optimizer=5)\n",
1680+
"gpr_model_0 = GaussianProcessRegressor(kernel=Matern(length_scale= [1,1,1], nu=1.5), alpha = 1e-5, n_restarts_optimizer=10)\n",
1681+
"gpr_model_1 = GaussianProcessRegressor(kernel=Matern(length_scale= [1,1,1], nu=1.5), alpha = 1e-5, n_restarts_optimizer=10)\n",
1682+
"gpr_model_2 = GaussianProcessRegressor(kernel=Matern(length_scale= [1,1,1], nu=1.5), alpha = 1e-10, n_restarts_optimizer=10)\n",
16831683
"\n",
1684-
"gpr_model_0_1 = GaussianProcessRegressor(kernel=Matern(length_scale= [1,1,1], nu=1.5), alpha = 1e-5, n_restarts_optimizer=5)\n",
1685-
"gpr_model_0_2 = GaussianProcessRegressor(kernel=Matern(length_scale= [1,1,1], nu=1.5), alpha = 1e-5, n_restarts_optimizer=5)"
1684+
"gpr_model_0_1 = GaussianProcessRegressor(kernel=Matern(length_scale= [1,1,1], nu=1.5), alpha = 1e-5, n_restarts_optimizer=10)\n",
1685+
"gpr_model_0_2 = GaussianProcessRegressor(kernel=Matern(length_scale= [1,1,1], nu=1.5), alpha = 1e-5, n_restarts_optimizer=10)"
16861686
]
16871687
},
16881688
{
16891689
"cell_type": "code",
1690-
"execution_count": 221,
1690+
"execution_count": 31,
16911691
"metadata": {},
16921692
"outputs": [
16931693
{
@@ -1716,12 +1716,37 @@
17161716
"print(gpr_model_0_2.kernel_) "
17171717
]
17181718
},
1719+
{
1720+
"cell_type": "markdown",
1721+
"metadata": {},
1722+
"source": [
1723+
"### Saving GPR models for each iteration of the active learning"
1724+
]
1725+
},
17191726
{
17201727
"cell_type": "code",
1721-
"execution_count": null,
1728+
"execution_count": 37,
17221729
"metadata": {},
17231730
"outputs": [],
1724-
"source": []
1731+
"source": [
1732+
"import pickle\n",
1733+
"\n",
1734+
"# Pickle scalers\n",
1735+
"with open('models/feature_standard_scaler_AL_iteration_0.pkl', 'wb') as f:\n",
1736+
" pickle.dump(scale_0, f)\n",
1737+
"with open('models/feature_standard_scaler_AL_iteration_1.pkl', 'wb') as f:\n",
1738+
" pickle.dump(scale_0_1, f)\n",
1739+
"with open('models/feature_standard_scaler_AL_iteration_2.pkl', 'wb') as f:\n",
1740+
" pickle.dump(scale_0_2, f)\n",
1741+
"\n",
1742+
"# Pickle models\n",
1743+
"with open('models/GPR_model_AL_iteration_0.pkl', 'wb') as f:\n",
1744+
" pickle.dump(gpr_model_0, f)\n",
1745+
"with open('models/GPR_model_AL_iteration_1.pkl', 'wb') as f:\n",
1746+
" pickle.dump(gpr_model_0_1, f)\n",
1747+
"with open('models/GPR_model_AL_iteration_2.pkl', 'wb') as f:\n",
1748+
" pickle.dump(gpr_model_0_2, f)"
1749+
]
17251750
},
17261751
{
17271752
"cell_type": "markdown",
21.6 KB
Binary file not shown.
6.52 KB
Binary file not shown.
18.3 KB
Binary file not shown.
38.1 KB
Binary file not shown.
636 Bytes
Binary file not shown.
636 Bytes
Binary file not shown.
636 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)