Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
analytics-tools-forcefield
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nomad-lab
analytics-tools-forcefield
Commits
07011571
Commit
07011571
authored
Jan 24, 2017
by
Adam Fekete
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding datamodel class and future version of GP
parent
a7360329
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
245 additions
and
0 deletions
+245
-0
python-module/ML_of_Forces/DataModel/ForceConfs.py
python-module/ML_of_Forces/DataModel/ForceConfs.py
+90
-0
python-module/ML_of_Forces/DataModel/__init__.py
python-module/ML_of_Forces/DataModel/__init__.py
+3
-0
python-module/ML_of_Forces/DataModel/baseclasses.py
python-module/ML_of_Forces/DataModel/baseclasses.py
+5
-0
python-module/ML_of_Forces/GP/Extensions/BeakerSupport.py
python-module/ML_of_Forces/GP/Extensions/BeakerSupport.py
+1
-0
python-module/ML_of_Forces/GP/Extensions/PlotlySupport.py
python-module/ML_of_Forces/GP/Extensions/PlotlySupport.py
+36
-0
python-module/ML_of_Forces/GP/Extensions/__init__.py
python-module/ML_of_Forces/GP/Extensions/__init__.py
+0
-0
python-module/ML_of_Forces/GP/GPVec.py
python-module/ML_of_Forces/GP/GPVec.py
+42
-0
python-module/ML_of_Forces/GP/Optimizer/__init__.py
python-module/ML_of_Forces/GP/Optimizer/__init__.py
+0
-0
python-module/ML_of_Forces/GP/__init__.py
python-module/ML_of_Forces/GP/__init__.py
+4
-0
python-module/ML_of_Forces/GP/baseclass.py
python-module/ML_of_Forces/GP/baseclass.py
+22
-0
python-module/ML_of_Forces/GP/feature/__init__.py
python-module/ML_of_Forces/GP/feature/__init__.py
+2
-0
python-module/ML_of_Forces/GP/feature/cov_mat.py
python-module/ML_of_Forces/GP/feature/cov_mat.py
+13
-0
python-module/ML_of_Forces/GP/kernels/__init__.py
python-module/ML_of_Forces/GP/kernels/__init__.py
+11
-0
python-module/ML_of_Forces/GP/kernels/id.py
python-module/ML_of_Forces/GP/kernels/id.py
+7
-0
python-module/ML_of_Forces/GP/tools/__init__.py
python-module/ML_of_Forces/GP/tools/__init__.py
+9
-0
No files found.
python-module/ML_of_Forces/DataModel/ForceConfs.py
0 → 100644
View file @
07011571
from
DataModel.baseclasses
import
DataModel
from
collections
import
namedtuple
import
numpy
as
np
### Subsampling from big database ###
### Spliting database in training/testing sets ###
class
ForceConfs
(
DataModel
):
def
__init__
(
self
,
confs
=
[],
force
=
[]):
"""
:param force: array of forces
:type force: np.array
:param confs: array of configurations
"""
assert
len
(
confs
)
==
len
(
force
)
self
.
confs
=
confs
self
.
force
=
force
def
__str__
(
self
):
out
=
'ForceConfs model
\n
'
+
\
' # of configuration: {}
\n
'
.
format
(
len
(
self
.
confs
))
+
\
' range of configurations: mean={2}, min={0}, max={1}
\n
'
.
format
(
*
self
.
range
())
return
out
def
__len__
(
self
):
"""
:return: length of the forces/configurations
"""
return
len
(
self
.
confs
)
def
range
(
self
):
"""
Determine the minimum and maximum length for a given list of configurations
:return: namedtuple('LengthRange', ['min', 'max', 'mean'])
"""
lengths
=
[
len
(
conf
)
for
conf
in
self
.
confs
]
LengthRange
=
namedtuple
(
'LengthRange'
,
[
'min'
,
'max'
,
'mean'
])
return
LengthRange
(
min
=
np
.
min
(
lengths
),
max
=
np
.
max
(
lengths
),
mean
=
np
.
mean
(
lengths
))
# return np.min(lengths), np.max(lengths), np.mean(lengths)
def
read_json_data
(
self
,
filename
):
import
json
with
open
(
filename
,
'r'
)
as
jsonfile
:
data
=
json
.
load
(
jsonfile
)[
'data'
]
self
.
confs
=
[
timestep
[
'confs'
]
for
timestep
in
data
]
self
.
force
=
[
timestep
[
'force'
]
for
timestep
in
data
]
self
.
confs
=
np
.
asarray
(
self
.
confs
)
self
.
force
=
np
.
asarray
(
self
.
force
)
def
subsampling
(
self
,
train
:
int
=
0
,
test
:
int
=
0
,
random
:
bool
=
True
)
->
None
:
self
.
nsample
=
train
+
test
if
random
:
inds
=
range
(
len
(
self
))
inds
=
np
.
random
.
choice
(
inds
,
size
=
self
.
nsample
,
replace
=
False
)
self
.
train_confs
=
self
.
confs
[
inds
[
0
:
train
]]
self
.
train_force
=
self
.
force
[
inds
[
train
:]]
if
__name__
==
'__main__'
:
filename
=
'../Data/Si_TB_300K.json'
data
=
ForceConfs
()
data
.
read_json_data
(
filename
)
print
(
data
)
data
.
subsampling
(
40
,
10
)
print
(
len
(
data
.
train_confs
))
print
(
len
(
data
.
train_force
))
print
(
'END'
)
python-module/ML_of_Forces/DataModel/__init__.py
0 → 100644
View file @
07011571
from
.ForceConfs
import
ForceConfs
__all__
=
[
"ForceConfs"
]
\ No newline at end of file
python-module/ML_of_Forces/DataModel/baseclasses.py
0 → 100644
View file @
07011571
from
abc
import
ABCMeta
class
DataModel
(
metaclass
=
ABCMeta
):
pass
python-module/ML_of_Forces/GP/Extensions/BeakerSupport.py
0 → 100644
View file @
07011571
python-module/ML_of_Forces/GP/Extensions/PlotlySupport.py
0 → 100644
View file @
07011571
# from bokeh.plotting import figure, output_file, show
# output_file("test.html")
# p = figure()
# p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2)
# show(p)
# from plotly import __version__
#
# from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
#
# print(__version__) # requires version >= 1.9.0
#
# from plotly.graph_objs import Scatter, Figure, Layout
#
# plot([Scatter(x=[1, 2, 3], y=[3, 1, 6])])
#
#
# import plotly
# from plotly.graph_objs import Scatter, Layout
#
# plotly.offline.plot({
# "data": [Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
# "layout": Layout(title="hello world")
# })
import
plotly
from
plotly.graph_objs
import
Scatter
,
Layout
plotly
.
offline
.
init_notebook_mode
()
plotly
.
offline
.
iplot
({
"data"
:
[
Scatter
(
x
=
[
1
,
2
,
3
,
4
],
y
=
[
4
,
3
,
2
,
1
])],
"layout"
:
Layout
(
title
=
"hello world"
)
})
\ No newline at end of file
python-module/ML_of_Forces/GP/Extensions/__init__.py
0 → 100644
View file @
07011571
python-module/ML_of_Forces/GP/GPVec.py
0 → 100644
View file @
07011571
from
.baseclass
import
GaussianProcess
from
typing
import
Optional
from
typing
import
Union
,
List
,
Dict
class
GPVec
(
GaussianProcess
):
def
__init__
(
self
,
kernel
:
Optional
[
str
]
=
None
,
datamodel
=
None
):
"""
sdfdsfdf
:param kernel: Hello
:type kernel: Optional[str]
:param datamodel:
"""
super
().
__init__
()
self
.
datamodel
=
datamodel
# type: Optional[str]
self
.
kernel
=
kernel
# kernel functions
pass
def
fit
(
self
,
X
,
Y
):
pass
def
predict
(
self
):
pass
# def __repr__(self):
# return "%s(%r)" % (self.__class__, self.__dict__)
def
__str__
(
self
):
out
=
'GaussianProcess:
\n
'
+
\
' datamodel: {}
\n
'
.
format
(
self
.
datamodel
)
+
\
' kernel: {}
\n
'
.
format
(
self
.
kernel
)
return
out
python-module/ML_of_Forces/GP/Optimizer/__init__.py
0 → 100644
View file @
07011571
python-module/ML_of_Forces/GP/__init__.py
0 → 100644
View file @
07011571
from
.GPVec
import
GPVec
__all__
=
[
'GPVec'
]
\ No newline at end of file
python-module/ML_of_Forces/GP/baseclass.py
0 → 100644
View file @
07011571
from
abc
import
ABCMeta
,
abstractmethod
,
abstractproperty
class
GaussianProcess
(
metaclass
=
ABCMeta
):
# @abstractproperty
# def kernel(self): pass
@
abstractmethod
def
fit
(
self
):
pass
@
abstractmethod
def
predict
(
self
):
pass
class
Kernel
(
metaclass
=
ABCMeta
):
pass
class
FeatureSpace
(
metaclass
=
ABCMeta
):
pass
python-module/ML_of_Forces/GP/feature/__init__.py
0 → 100644
View file @
07011571
python-module/ML_of_Forces/GP/feature/cov_mat.py
0 → 100644
View file @
07011571
from
GP.baseclass
import
FeatureSpace
class
cov_mat
(
FeatureSpace
):
pass
if
__name__
==
'__main__'
:
m
=
cov_mat
()
print
(
m
)
\ No newline at end of file
python-module/ML_of_Forces/GP/kernels/__init__.py
0 → 100644
View file @
07011571
from
.id
import
id
__all__
=
[
'id'
]
if
__name__
==
'__main__'
:
pass
python-module/ML_of_Forces/GP/kernels/id.py
0 → 100644
View file @
07011571
from
GP.baseclass
import
Kernel
class
id
(
Kernel
):
def
__call__
(
self
,
*
args
,
**
kwargs
):
return
1.0
python-module/ML_of_Forces/GP/tools/__init__.py
0 → 100644
View file @
07011571
import
json
def
read_json_data
(
filename
):
with
open
(
filename
,
'r'
)
as
jsonfile
:
data
=
json
.
load
(
jsonfile
)
return
data
[
'data'
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment