Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
214 commits
Select commit Hold shift + click to select a range
7baea6e
add basemap
hgordo Dec 7, 2021
2888839
Merge branch 'gordon-dev' of https://github.com/c3aidti/training-spac…
hgordo Dec 7, 2021
decde04
typo
hgordo Dec 7, 2021
9d41a01
Merge pull request #493 from c3aidti/gordon-dev
babreu-ncsa Jan 20, 2022
00322e1
Merge pull request #507 from c3aidti/tc02d
dti-devops Jan 20, 2022
525d4d3
just moving files
babreu-ncsa Jan 20, 2022
a644269
moving more files
babreu-ncsa Jan 20, 2022
a2c772e
method to clean Observation data
babreu-ncsa Jan 20, 2022
5cccbd4
fix doStart for batch processing
babreu-ncsa Jan 20, 2022
2cc8456
add 99 bins for UHSAdNdlogd
babreu-ncsa Jan 20, 2022
1b2b189
Merge pull request #508 from c3aidti/gordon-dev
babreu-ncsa Jan 21, 2022
29c9288
Merge pull request #511 from c3aidti/tc02d
dti-devops Jan 21, 2022
a6ea431
adding temperature UOM
babreu-ncsa Jan 27, 2022
63bcc57
Merge pull request #512 from c3aidti/gordon-dev
babreu-ncsa Feb 21, 2022
3bc5b2b
first stab at custom ML pipe
babreu-ncsa Feb 21, 2022
5eccc65
Merge pull request #520 from c3aidti/tc02d
dti-devops Feb 21, 2022
92a878d
lil syntax fix
babreu-ncsa Feb 21, 2022
0f64fa3
shrink action runtime
babreu-ncsa Feb 21, 2022
a0818f9
change file names
babreu-ncsa Feb 21, 2022
5a55fb2
add train method variables
babreu-ncsa Feb 21, 2022
b7b5cf0
add pandas
babreu-ncsa Feb 21, 2022
0eb2338
add dill
babreu-ncsa Feb 21, 2022
2cf4a30
try new kernel
babreu-ncsa Feb 21, 2022
d41e2b4
scipy fix
babreu-ncsa Feb 21, 2022
91e06bc
another kernel try
babreu-ncsa Feb 21, 2022
c910b14
transform data after fit
babreu-ncsa Feb 21, 2022
2d6cbf0
add process step
babreu-ncsa Feb 21, 2022
8cc342a
adding field?
babreu-ncsa Feb 21, 2022
5b8ba26
now include process method
babreu-ncsa Feb 21, 2022
3a8057a
add isProcessable field
babreu-ncsa Feb 22, 2022
bd11447
first fields of GP Reg
babreu-ncsa Feb 22, 2022
3a4d099
filename fix
babreu-ncsa Feb 22, 2022
3fe80b3
add process method to GPR
babreu-ncsa Feb 22, 2022
5d0773f
forgot a collon !!!
babreu-ncsa Feb 22, 2022
f1d96d9
add spec?
babreu-ncsa Feb 22, 2022
e1b5eba
add isProcessable
babreu-ncsa Feb 22, 2022
ad3b366
organizing files
babreu-ncsa Feb 22, 2022
79fe6b6
trying ml annotation
babreu-ncsa Feb 22, 2022
1ec4aa6
trying again
babreu-ncsa Feb 22, 2022
ad5f083
first stab at kernels
babreu-ncsa Feb 22, 2022
ee08285
adding method to basis type
babreu-ncsa Feb 22, 2022
1fd5fcb
placeholder function
babreu-ncsa Feb 22, 2022
47ddac9
tiny tiny tiny syntax fix
babreu-ncsa Feb 22, 2022
e110a23
pickling returns string...
babreu-ncsa Feb 22, 2022
be38511
return this
babreu-ncsa Feb 22, 2022
310e565
member to inline
babreu-ncsa Feb 22, 2022
fb9342a
back to member
babreu-ncsa Feb 22, 2022
9b1ce96
trying to write to type
babreu-ncsa Feb 22, 2022
65f9254
merging object
babreu-ncsa Feb 22, 2022
79422da
back to what it was
babreu-ncsa Feb 22, 2022
db65dc3
trying merge again
babreu-ncsa Feb 22, 2022
dc916ec
making kernel persistable
babreu-ncsa Feb 22, 2022
21b7973
add schema name
babreu-ncsa Feb 22, 2022
7f905cd
entity type on the basis type too
babreu-ncsa Feb 22, 2022
8ebba16
okay... no entities then
babreu-ncsa Feb 22, 2022
31cca00
all entities again...
babreu-ncsa Feb 22, 2022
b67f996
add schema name to array field
babreu-ncsa Feb 22, 2022
06c5e0f
using schema suffix instead
babreu-ncsa Feb 22, 2022
8c086ca
adding after create...
babreu-ncsa Feb 22, 2022
456ee41
insert afterCreate again..
babreu-ncsa Feb 22, 2022
6156091
trying to fix syntax...
babreu-ncsa Feb 22, 2022
8f219ec
i don't want entity types
babreu-ncsa Feb 22, 2022
c221c03
minor fix?
babreu-ncsa Feb 22, 2022
59529f8
hiding push
babreu-ncsa Feb 22, 2022
5486e07
mixing obj
babreu-ncsa Feb 22, 2022
c7172f3
removing obj mixin......
babreu-ncsa Feb 22, 2022
9acaee9
trying inline + member
babreu-ncsa Feb 22, 2022
cd6c963
returning the object
babreu-ncsa Feb 23, 2022
4081af8
adding array field
babreu-ncsa Feb 23, 2022
0774caa
changing type definition a little bit
babreu-ncsa Feb 23, 2022
9480f61
don't override function
babreu-ncsa Feb 23, 2022
be645ec
add include annotation
babreu-ncsa Feb 23, 2022
6282368
creating object inside build function
babreu-ncsa Feb 23, 2022
12c460d
it's not a json...
babreu-ncsa Feb 23, 2022
6027286
remove dependency annotation
babreu-ncsa Feb 23, 2022
7fc20b9
just trying something else I guess...
babreu-ncsa Feb 23, 2022
e424b4d
...
babreu-ncsa Feb 23, 2022
34426fb
looks like this is FINALLY working
babreu-ncsa Feb 23, 2022
cbeaa25
imputing kernel to technique
babreu-ncsa Feb 23, 2022
e862438
add schema suffixes
babreu-ncsa Feb 23, 2022
b715b74
trying what I can...
babreu-ncsa Feb 23, 2022
bc6ee94
...
babreu-ncsa Feb 23, 2022
e10306b
....
babreu-ncsa Feb 23, 2022
a2c7659
............
babreu-ncsa Feb 23, 2022
3d931b6
... desperate commits
babreu-ncsa Feb 23, 2022
32f5a41
... mostly ...
babreu-ncsa Feb 23, 2022
f55d4a8
well, sometimes they work
babreu-ncsa Feb 23, 2022
1e92e94
add dot product kernel
babreu-ncsa Feb 23, 2022
44e5a71
add ExpSineSquared kernel
babreu-ncsa Feb 23, 2022
701409c
add matern kernel
babreu-ncsa Feb 23, 2022
a3bb3c4
add RBF kernel
babreu-ncsa Feb 23, 2022
e637d04
add rational quadratic kernel
babreu-ncsa Feb 23, 2022
3fa6635
add white kernel
babreu-ncsa Feb 23, 2022
cb0d5d3
of course the LAST one had a little typo
babreu-ncsa Feb 23, 2022
e413a9c
Merge pull request #521 from c3aidti/gordon-dev
babreu-ncsa Feb 23, 2022
2288d16
Merge pull request #523 from c3aidti/tc02d
dti-devops Feb 23, 2022
7878463
rmv inline of netcdf call
babreu-ncsa Feb 28, 2022
034d539
back to inline
babreu-ncsa Feb 28, 2022
3670ff8
add sklearn
babreu-ncsa Feb 28, 2022
1033821
adjust version
babreu-ncsa Feb 28, 2022
2047af0
Merge pull request #524 from c3aidti/gordon-dev
babreu-ncsa Feb 28, 2022
d25c823
Merge pull request #525 from c3aidti/tc02d
dti-devops Feb 28, 2022
ac7459f
add serialized netcdf util
babreu-ncsa Feb 28, 2022
6d424a3
name fix
babreu-ncsa Feb 28, 2022
1046cea
add simplified action runtime
babreu-ncsa Feb 28, 2022
5dea303
Merge pull request #526 from c3aidti/gordon-dev
babreu-ncsa Feb 28, 2022
898fcc2
Merge pull request #527 from c3aidti/tc02d
dti-devops Feb 28, 2022
f2547ee
Add dill library to kernel
JamesCarzon Mar 4, 2022
50337fe
comment on possible improvement
babreu-ncsa Mar 4, 2022
3cd05a3
Merge branch 'gordon-dev' of https://github.com/c3aidti/training-spac…
babreu-ncsa Mar 4, 2022
a3a6921
Merge pull request #528 from c3aidti/gordon-dev
babreu-ncsa Mar 4, 2022
fcddb82
Merge pull request #529 from c3aidti/tc02d
dti-devops Mar 4, 2022
a8abf90
rm inline call
babreu-ncsa Mar 8, 2022
6019649
got a lil different error now
babreu-ncsa Mar 8, 2022
1880437
another dependency
babreu-ncsa Mar 8, 2022
ef20053
fixing return type?
babreu-ncsa Mar 8, 2022
d03e938
include more stuff
babreu-ncsa Mar 8, 2022
e660070
try hiding deps one more time
babreu-ncsa Mar 8, 2022
d563789
add map to hyperPars
babreu-ncsa Mar 8, 2022
31c1559
add schema suffix
babreu-ncsa Mar 8, 2022
3c045b5
trying mapp
babreu-ncsa Mar 8, 2022
b833aae
back to map
babreu-ncsa Mar 8, 2022
60735a4
back to array.....
babreu-ncsa Mar 8, 2022
d19270f
schema name
babreu-ncsa Mar 8, 2022
55ae157
adding a space?
babreu-ncsa Mar 8, 2022
0198c00
change schema name
babreu-ncsa Mar 8, 2022
e4a8e9f
schema name on technique
babreu-ncsa Mar 8, 2022
02a8e82
db annotation
babreu-ncsa Mar 8, 2022
4c54f78
getting rid of schemas and type keys
babreu-ncsa Mar 8, 2022
172860a
it's working now
babreu-ncsa Mar 8, 2022
ed73dc3
clean up code
babreu-ncsa Mar 9, 2022
43ba2e1
tiny fix
babreu-ncsa Mar 9, 2022
c45fb4f
Merge pull request #530 from c3aidti/gordon-dev
babreu-ncsa Mar 9, 2022
08c3288
Merge pull request #531 from c3aidti/tc02d
dti-devops Mar 9, 2022
5fa2765
add container field and methods to upsert depending on that
babreu-ncsa Mar 15, 2022
c5b7cbf
just a bogus change
babreu-ncsa Mar 15, 2022
2c811a6
another bogus change
babreu-ncsa Mar 15, 2022
b7a7865
attempt to create entity type
babreu-ncsa Mar 15, 2022
fe22bf3
add js method to create SimulationOutputFile objects
babreu-ncsa Mar 15, 2022
2460c97
little fix and adding one fake SimSam to test
babreu-ncsa Mar 15, 2022
8184c72
fixed a bunch of bugs
babreu-ncsa Mar 15, 2022
d5088c1
this seems to be working now
babreu-ncsa Mar 16, 2022
92894cd
retrigger prov?
babreu-ncsa Mar 16, 2022
e820a4f
adding python method tor monthly mean upsert
babreu-ncsa Mar 16, 2022
8c90ad2
trying that again with loop over dict items
babreu-ncsa Mar 16, 2022
3934a63
the tiniest of fixes...
babreu-ncsa Mar 16, 2022
bb53573
add SimSam field
babreu-ncsa Mar 16, 2022
bd8eef4
add months to container search
babreu-ncsa Mar 17, 2022
dd1686d
fixing my js stupidity
babreu-ncsa Mar 17, 2022
dd9a3e5
another js bug
babreu-ncsa Mar 17, 2022
915a00c
it's complaining about a SEMICOLON........
babreu-ncsa Mar 17, 2022
c62e2f6
...... desperate commits again
babreu-ncsa Mar 17, 2022
f9199cf
c3 does not like interpreting loops...
babreu-ncsa Mar 17, 2022
adb3897
rename type, get rid of 0-ed columns
babreu-ncsa Mar 17, 2022
af0c94a
rm old type
babreu-ncsa Mar 17, 2022
9d6ef32
update methods names
babreu-ncsa Mar 17, 2022
ea43d3e
Merge pull request #533 from c3aidti/gordon-dev
babreu-ncsa Mar 17, 2022
8f72880
Merge pull request #536 from c3aidti/tc02d
dti-devops Mar 17, 2022
7fed97d
Merge pull request #537 from c3aidti/gordon-dev
babreu-ncsa Mar 17, 2022
217c9f7
Merge pull request #538 from c3aidti/tc02d
dti-devops Mar 17, 2022
0674b3b
starting to prototype coords
babreu-ncsa Mar 17, 2022
7ced1fa
double to float
babreu-ncsa Mar 17, 2022
9515e20
new upsert method
babreu-ncsa Mar 17, 2022
7e282f8
rm db ann
babreu-ncsa Mar 17, 2022
aec1261
lil fix as always
babreu-ncsa Mar 17, 2022
b13ce9d
the previous trial takes prohibitively long...
babreu-ncsa Mar 17, 2022
bb542e7
latitude as a reference field now
babreu-ncsa Mar 17, 2022
deabfd6
adding type to compare performance
babreu-ncsa Mar 18, 2022
ca48ff5
there's always a tiny fix that should be highlighted before provision…
babreu-ncsa Mar 18, 2022
c07954d
yeah... guess what... another tiny fix
babreu-ncsa Mar 18, 2022
3c23ad2
add lat lon time tuple type
babreu-ncsa Mar 18, 2022
7dc11d7
type to host data with references to geosurftime
babreu-ncsa Mar 18, 2022
8c0b318
adjust type name
babreu-ncsa Mar 18, 2022
428a281
add method to upsert all ref
babreu-ncsa Mar 18, 2022
bf42d0f
too long of a schema name
babreu-ncsa Mar 18, 2022
e00c439
fix name
babreu-ncsa Mar 18, 2022
73450d8
python stupidity fix
babreu-ncsa Mar 18, 2022
f674825
bending to c3's will
babreu-ncsa Mar 18, 2022
94bc8cd
making objs instead of fetching
babreu-ncsa Mar 18, 2022
2e8b987
eyt another approach
babreu-ncsa Mar 18, 2022
09c1759
@db on GeoSurfaceTime
babreu-ncsa Mar 21, 2022
f322660
Merge pull request #539 from c3aidti/gordon-dev
babreu-ncsa Mar 30, 2022
9ab0eef
Merge pull request #543 from c3aidti/tc02d
dti-devops Mar 30, 2022
8196ef5
excluding unique db ann
babreu-ncsa Mar 30, 2022
bb31036
python method for batch upsert
babreu-ncsa Apr 1, 2022
001159a
create batch job for AOD data
babreu-ncsa Apr 1, 2022
ea97e02
add limit to batch job
babreu-ncsa Apr 1, 2022
42c46da
lil fix
babreu-ncsa Apr 1, 2022
8840a99
fix on merging file type
babreu-ncsa Apr 1, 2022
14b5d45
stupid fix
babreu-ncsa Apr 1, 2022
74ffb1c
another syntax fix
babreu-ncsa Apr 1, 2022
1ed3eae
batch job to clean table
babreu-ncsa Apr 2, 2022
13743a2
change type key
babreu-ncsa Apr 2, 2022
26a63f9
other batch types for rm
babreu-ncsa Apr 2, 2022
a51b7f9
trying a little fix
babreu-ncsa Apr 2, 2022
bd35be4
change how batches are built
babreu-ncsa Apr 2, 2022
e8ced85
another trial
babreu-ncsa Apr 2, 2022
f95df3d
trying different script to scale up rm
babreu-ncsa Apr 3, 2022
ab8462e
lil fix
babreu-ncsa Apr 3, 2022
857917c
upsert -> create in AOD data
babreu-ncsa Apr 5, 2022
34a8da7
lil fix
babreu-ncsa Apr 5, 2022
06c0191
trying db annotations
babreu-ncsa Apr 5, 2022
9cbb6fd
lil fix...
babreu-ncsa Apr 5, 2022
0aa6569
bye remove files
babreu-ncsa Apr 5, 2022
0fedc43
rm another one
babreu-ncsa Apr 5, 2022
9b63cba
moving to cassandra
babreu-ncsa Apr 5, 2022
4ba0b38
rm shortId annotation
babreu-ncsa Apr 6, 2022
aae2dcb
add offset, fix db annotation
babreu-ncsa Apr 6, 2022
a232b47
comapctType does not work well
babreu-ncsa Apr 6, 2022
47beba4
adding point to the name
babreu-ncsa Apr 6, 2022
ea8cbac
add workaround to keep track of files that are failing
babreu-ncsa Apr 6, 2022
26ca042
add filters to the batch job
babreu-ncsa Apr 6, 2022
3ac265b
Merge pull request #544 from c3aidti/gordon-dev
babreu-ncsa Apr 6, 2022
5109965
Merge pull request #547 from c3aidti/tc02d
dti-devops Apr 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions training/gordon-group/seed/ActionRuntime/py-gordon-ML_1_0_0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"language": "Python",
"runtimeVersion": "3.6",
"modules": {
"conda.scikit-learn":"=0.23.1",
"conda.pandas":"=1.0.1",
"conda.numpy":"=1.18.1",
"conda.scipy":"=1.4.1",
"conda.dill":"=0.2.8.2"
},
"repositories": [
"https://repo.continuum.io/pkgs/main",
"conda-forge"
],
"runtime": "CPython",
"name": "py-gordon-ML_1_0_0",
"id": "py-gordon-ML_1_0_0"
}
15 changes: 15 additions & 0 deletions training/gordon-group/seed/ActionRuntime/py-gordon-nc4-_1_0_0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"language": "Python",
"runtimeVersion": "3.6",
"modules": {
"conda.netcdf4": "=1.5.7",
"conda.dill":"=0.2.8.2"
},
"repositories": [
"https://repo.continuum.io/pkgs/main",
"conda-forge"
],
"runtime": "CPython",
"name": "py-gordon-nc4_1_0_0",
"id": "py-gordon-nc4_1_0_0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"conda.netcdf4": "=1.5.7",
"conda.numpy": "=1.17.0",
"conda.pandas": "=1.1.5",
"conda.cartopy":"=0.18.0"
"conda.cartopy":"=0.18.0",
"conda.basemap":"=1.2.2",
"conda.iris":"=3.1.0"
},
"repositories": [
"https://repo.continuum.io/pkgs/main",
Expand Down
11 changes: 9 additions & 2 deletions training/gordon-group/seed/ActionRuntime/py-gordon_2_0_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
"language": "Python",
"runtimeVersion": "3.6",
"modules": {
"conda.cartopy":"=0.19.0",
"conda.pandas": "=1.0.1"
"conda.pip": "=21.2.2",
"conda.netcdf4": "=1.5.7",
"conda.numpy": "=1.17.0",
"conda.pandas": "=1.1.5",
"conda.cartopy":"=0.18.0",
"conda.basemap":"=1.2.2",
"conda.iris":"=3.1.0",
"conda.scikit-learn":"=0.23.1",
"conda.dill":"=0.2.8.2"
},
"repositories": [
"https://repo.continuum.io/pkgs/main",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* UpsertAODData.c3typ
* Batch job to upsert data from files in {@link SimulationOutputFile}with container=monthly-mean in parallel
*/
type UpsertAODData extends BatchJob<UpsertAODData, UpsertAODDataOptions, UpsertAODDataBatch> type key 'PSRT_MNTHMNDT' {

doStart: ~ js server
processBatch: ~ js server
// allComplete: ~ js server
}
41 changes: 41 additions & 0 deletions training/gordon-group/src/BatchJobs/UpsertAODData/UpsertAODData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* UpsertAODData.js
* Implementation of UpsertAODData.c3typ
* @param {UpsertAODData} job
* @param {UpsertAODDataOptions} options
*/
function doStart(job, options) {
var batch = [];

var finalFilter = options.filter.and().eq("container", "monthly-mean");

var dataset = SimulationOutputFile.fetchObjStream({
filter: finalFilter,
limit: options.limit,
offset: options.offset
});

while(dataset.hasNext()) {
batch.push(dataset.next());

if (batch.length >= options.batchSize || !dataset.hasNext()) {
var batchSpec = UpsertAODDataBatch.make({values: batch});
job.scheduleBatch(batchSpec);

batch = [];
}
}
}



/**
* @param {UpsertAODDataBatch} batch
* @param {UpsertAODData} job
* @param {UpsertAODDataOptions} options
*/
function processBatch(batch, job, options) {
batch.values.forEach(function(file) {
file.upsert3HourlyAODAllRefData();
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* UpsertAODDataBatch.c3typ
* Represents a unit of work (batch) in a {@link UpsertAODData} batch job.
*/
type UpsertAODDataBatch {
values: [SimulationOutputFile]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* UpsertAODDataOptions.c3typ
* Represents customization options for a {@link UpsertAODData} batch job
*/
type UpsertAODDataOptions {
// the number of files that will be processed in each batch
batchSize: int = 1
// a limit to the number of files that will be processed overall
limit: int = -1
// offset in the fetch to SimulationOutputFile
offset: int = 0
// any additional filters
filter: Filter
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function doStart(job, options) {
while(dataset.hasNext()) {
batch.push(dataset.next());

if (dataset.length >= options.batchSize || !dataset.hasNext()) {
if (batch.length >= options.batchSize || !dataset.hasNext()) {
var batchSpec = UpsertDataBatch.make({values: batch});
job.scheduleBatch(batchSpec);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* UpsertObsData.c3typ
* Batch job to upsert data from every {@link SimulationSample} in a {@link SimulationEnsemble} in parallel
* Batch job to upsert data from every {@link ObservationSet} in parallel
*/
type UpsertObsData extends BatchJob<UpsertObsData, UpsertDataOptions, UpsertObsDataBatch> type key 'UPSERTOBSDATA' {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
while(dataset.hasNext()) {
batch.push(dataset.next());

if (dataset.length >= options.batchSize || !dataset.hasNext()) {
if (batch.length >= options.batchSize || !dataset.hasNext()) {
var batchSpec = UpsertObsDataBatch.make({values: batch});
job.scheduleBatch(batchSpec);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* GaussianProcessRegressionPipe.c3typ
* Performs Scikit-Learn's GP Regression for a set of inputs-outputs.
*/
entity type GaussianProcessRegressionPipe extends MLLeafPipe<Dataset, Dataset> type key 'GPREG' {
// the technique for this regression
@db(persistAllFields=true)
technique: !GaussianProcessRegressionTechnique

// train the model
@py(env='gordon-ML_1_0_0')
train: ~
// process data, ie predictions
@py(env='gordon-ML_1_0_0')
process: ~
// guarantee that process() is only allowed after train()
@py(env='gordon-ML_1_0_0')
isProcessable: ~
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
def train(this, input, targetOutput, spec):
"""
Performs Scikit-Learn's GaussianProcessRegressor's fit().
https://scikit-learn.org/stable/modules/generated/sklearn.gaussian_process.GaussianProcessRegressor.html
"""
from sklearn.gaussian_process import GaussianProcessRegressor

# get data
X = c3.Dataset.toNumpy(dataset=input)
y = c3.Dataset.toNumpy(dataset=targetOutput).flatten()

# get kernel object from c3, make it python again
kernel = c3.PythonSerialization.deserialize(serialized=this.technique.kernel.pickledKernel)

# build and train GPR
gp = GaussianProcessRegressor(kernel=kernel)
gp.fit(X, y)

# pickle model
this.trainedModel = c3.MLTrainedModelArtifact(model=c3.PythonSerialization.serialize(obj=gp))

return this


def process(this, input, spec):
"""
Performs Scikit-Learn's GaussianProcessRegressor's predict().
https://scikit-learn.org/stable/modules/generated/sklearn.gaussian_process.GaussianProcessRegressor.html
"""
# unpickle the model
gp = c3.PythonSerialization.deserialize(serialized=this.trainedModel.model)

# format data
X = c3.Dataset.toNumpy(dataset=input)

return c3.Dataset.fromPython(pythonData=gp.predict(X))


def isProcessable(this):
""""
Guarantees that process() can only be called after train()
"""

return this.isTrained()
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* GaussianProcessRegressionTechnique.c3typ
* Defines hyper parameters for GP Regression.
*/
type GaussianProcessRegressionTechnique mixes MLTechnique {
// random seed
@ML(hyperParameter=true)
randomState: integer
// the kernel object
@ML(hyperParameter=true)
kernel: SklearnGPRKernel
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* SklearnGPRKernel.c3typ
* Stepping stone for Scikit-Learn Gaussian Process kernels.
* See: https://scikit-learn.org/stable/modules/classes.html#module-sklearn.gaussian_process
*/
type SklearnGPRKernel {
// the name of the kernel
name: string enum('Constant', 'DotProduct', 'ExpSineSquared', 'Matern', 'RBF', 'RationalQuadratic', 'White')
// the kernel hyper parameters
hyperParameters: map<string, double>
// the pickled kernel
pickledKernel: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* SklearnGPRKernelConstant.c3typ
* Scikit-Learn Gaussian Process Constant Kernel.
* See: https://scikit-learn.org/stable/modules/generated/sklearn.gaussian_process.kernels.ConstantKernel.html#sklearn.gaussian_process.kernels.ConstantKernel
*/
type SklearnGPRKernelConstant {
// Constant value that defines the kernel value
constantValue: !double
// the SklearnGPRKernel for this object
kernel: SklearnGPRKernel

// constructs the SklearnGPRKernel internal object
@py(env='gordon-ML_1_0_0')
build: member function(): SklearnGPRKernelConstant
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def build(this):
"""
This effectively constructs the type instance, by creating the object to be placed in the kernel field. Ideally this should be replaced by a callback function (beforeMake or afterMake).
"""
from sklearn.gaussian_process.kernels import ConstantKernel

sklKernel = ConstantKernel(this.constantValue)

kernel_pickled = c3.PythonSerialization.serialize(obj=sklKernel)
kernel_name = 'Constant'
kernel_hyperParameters = c3.c3Make(
"map<string, double>", {"constantValue": this.constantValue}
)

this.kernel = c3.SklearnGPRKernel(
name=kernel_name,
hyperParameters=kernel_hyperParameters,
pickledKernel=kernel_pickled
)

return this
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* SklearnGPRKernelDotProduct.c3typ
* Scikit-Learn Gaussian Process Dot Product Kernel.
* See: https://scikit-learn.org/stable/modules/generated/sklearn.gaussian_process.kernels.DotProduct.html#sklearn.gaussian_process.kernels.DotProduct
*/
type SklearnGPRKernelDotProduct {
// Constant that defines the kernel inhomogenity
sigmaZero: !double
// the SklearnGPRKernel for this object
kernel: SklearnGPRKernel

// constructs the SklearnGPRKernel internal object
@py(env='gordon-ML_1_0_0')
build: member function(): SklearnGPRKernelDotProduct
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def build(this):
"""
This effectively constructs the type instance, by creating the object to be placed in the kernel field. Ideally this should be replaced by a callback function (beforeMake or afterMake).
"""
from sklearn.gaussian_process.kernels import DotProduct

sklKernel = DotProduct(sigma_0=this.sigmaZero)

kernel_pickled = c3.PythonSerialization.serialize(obj=sklKernel)
kernel_name = 'DotProduct'
kernel_hyperParameters = c3.c3Make(
"map<string, double>", {"sigmaZero": this.sigmaZero}
)

this.kernel = c3.SklearnGPRKernel(
name=kernel_name,
hyperParameters=kernel_hyperParameters,
pickledKernel=kernel_pickled
)

return this
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* SklearnGPRKernelExpSineSquared.c3typ
* Scikit-Learn Gaussian Process Exponential Sine Squared Kernel.
* See: https://scikit-learn.org/stable/modules/generated/sklearn.gaussian_process.kernels.ExpSineSquared.html#sklearn.gaussian_process.kernels.ExpSineSquared
*/
type SklearnGPRKernelExpSineSquared {
// Constant that defines the kernel length scale
lengthScale: !double
// Constant that defines the kernel periodicity
periodicity: !double
// the SklearnGPRKernel for this object
kernel: SklearnGPRKernel

// constructs the SklearnGPRKernel internal object
@py(env='gordon-ML_1_0_0')
build: member function(): SklearnGPRKernelExpSineSquared
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def build(this):
"""
This effectively constructs the type instance, by creating the object to be placed in the kernel field. Ideally this should be replaced by a callback function (beforeMake or afterMake).
"""
from sklearn.gaussian_process.kernels import ExpSineSquared

sklKernel = ExpSineSquared(length_scale=this.lengthScale, periodicity=this.periodicity)

kernel_pickled = c3.PythonSerialization.serialize(obj=sklKernel)
kernel_name = 'ExpSineSquared'
kernel_hyperParameters = c3.c3Make(
"map<string, double>", {"lengthScale": this.lengthScale,
"periodicity": this.periodicity
}
)

this.kernel = c3.SklearnGPRKernel(
name=kernel_name,
hyperParameters=kernel_hyperParameters,
pickledKernel=kernel_pickled
)

return this
Loading