Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F118949839
HPELM_RC.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jun 23, 06:16
Size
2 KB
Mime Type
text/x-python
Expires
Wed, Jun 25, 06:16 (2 d)
Engine
blob
Format
Raw Data
Handle
26948470
Attached To
R8800 solar_potential
HPELM_RC.py
View Options
import
sys
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
matplotlib.colors
import
LinearSegmentedColormap
import
pandas
as
pd
import
xarray
as
xr
import
os
import
time
import
hpelm
import
util
from
ds
import
Dataset
from
tables
import
open_file
,
Atom
,
Filters
print
(
"Executing"
,
sys
.
argv
[
0
])
# ### Initialise reader
# In[3]:
# data_path = os.path.abspath("D:/Meteo_data/Meteoswiss_satellite")
#data_path = os.path.abspath("/home/castello/work/energy-potential/Solar/data/meteo")
#modelname = "2012-2012_grid100_SIS"
#queryname = 'grid1600'
data_path
=
os
.
path
.
abspath
(
sys
.
argv
[
1
])
modelname
=
sys
.
argv
[
2
]
queryname
=
sys
.
argv
[
3
]
nodes
=
int
(
sys
.
argv
[
4
])
# In[4]:
my_ds
=
Dataset
(
data_path
,
modelname
,
queryname
)
# In[5]:
print
(
my_ds
.
train_X
)
print
(
my_ds
.
val_X
)
print
(
my_ds
.
test_X
)
print
(
my_ds
.
query_X
)
# In[6]:
nf
=
my_ds
.
feature_norm
.
m
nt
=
my_ds
.
target_norm
.
m
# In[7]:
my_ds
.
get_matrices
([
'train'
,
'test'
,
'val'
,
'query'
])
# In[8]:
modelfile
=
os
.
path
.
join
(
my_ds
.
model_path
,
'model.hdf5'
)
# ## HPELM
# In[9]:
model
=
hpelm
.
HPELM
(
nf
,
nt
)
print
(
model
)
# In[13]:
model
.
add_neurons
(
nodes
,
'sigm'
)
print
(
"number of nodes ="
,
nodes
)
#model.add_neurons(10, 'lin')
# In[14]:
timer
=
time
.
process_time
()
model
.
train
(
my_ds
.
train_X
,
my_ds
.
train_T
,
'V'
,
Xv
=
my_ds
.
val_X
,
Tv
=
my_ds
.
val_T
)
print
(
"TRAINING:Executed in
%.2f
seconds"
%
(
time
.
process_time
()
-
timer
))
# In[15]:
model
.
nnet
.
get_neurons
()
# In[17]:
# TRAINING ERROR:
timer
=
time
.
clock
()
model
.
predict
(
my_ds
.
train_X
,
my_ds
.
train_Y
)
print
(
model
.
error
(
my_ds
.
train_Y
,
my_ds
.
train_T
))
print
(
"TRAINING ERROR: Executed in
%.2f
seconds"
%
(
time
.
clock
()
-
timer
))
# In[18]:
# VALIDATION ERROR:
timer
=
time
.
clock
()
model
.
predict
(
my_ds
.
val_X
,
my_ds
.
val_Y
)
print
(
model
.
error
(
my_ds
.
val_Y
,
my_ds
.
val_T
))
print
(
"VALIDATION ERROR: Executed in
%.2f
seconds"
%
(
time
.
clock
()
-
timer
))
# In[19]:
# TESTING ERROR:
timer
=
time
.
clock
()
model
.
predict
(
my_ds
.
val_X
,
my_ds
.
test_Y
)
print
(
model
.
error
(
my_ds
.
test_Y
,
my_ds
.
test_T
))
print
(
"TESTING ERROR: Executed in
%.2f
seconds"
%
(
time
.
clock
()
-
timer
))
# In[24]:
timer
=
time
.
clock
()
query_Y
=
model
.
predict
(
my_ds
.
query_X
)
print
(
"QUERY PREDICTIONS: Executed in
%.2f
seconds"
%
(
time
.
clock
()
-
timer
))
# In[37]:
h5
=
open_file
(
my_ds
.
query_X
,
"r"
)
for
node
in
h5
.
walk_nodes
():
pass
# find a node with whatever name
X
=
node
[:]
h5
.
close
()
print
(
"==== Query features === "
)
print
(
X
)
print
(
"==== Query targets === "
)
print
(
query_Y
)
Event Timeline
Log In to Comment