Skip to content

Commit

Permalink
Merge pull request #554 from WeikeYe-TRI/atomate
Browse files Browse the repository at this point in the history
Atomate
  • Loading branch information
JosephMontoya-TRI committed Jul 5, 2022
2 parents 2931ff9 + e57f856 commit aa31cd0
Show file tree
Hide file tree
Showing 20 changed files with 1,140 additions and 326 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/camd-test-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .[tests,m3gnet]
pip install -e .[tests,m3gnet,atomate]
- name: pytest
env:
MPLBACKEND: "Agg"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ RUN source /opt/conda/bin/activate camd && \
pip install -r requirements.txt

COPY camd /home/camd/camd
RUN pip install -e .[proto_dft,m3gnet]
RUN pip install -e .[proto_dft,m3gnet,atomate]
6 changes: 3 additions & 3 deletions camd/agent/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_hypotheses(self, candidate_data, seed_data=None):

self.candidate_data = candidate_data.drop(columns=["target"], axis=1)
self.seed_data = seed_data
X_seed = seed_data.drop(columns=["target"], axis=1, errors='ignore')
X_seed = seed_data.drop(columns=["target"], axis=1, errors="ignore")
y_seed = seed_data["target"]
steps = [
("scaler", StandardScaler()),
Expand Down Expand Up @@ -203,8 +203,8 @@ def get_hypotheses(self, candidate_data, seed_data=None):
2
* np.log(
len(self.candidate_data)
* _t ** 2
* np.pi ** 2
* _t**2
* np.pi**2
/ 6
/ self.kwargs.get("delta", 0.1)
)
Expand Down
2 changes: 2 additions & 0 deletions camd/agent/m3gnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def reverse_calcs(retrain_data, data_screening=None):

class M3GNetStabilityAgent(StabilityAgent):
"""Stability agent that uses megnet for estimation of energy"""

def __init__(
self,
m3gnet=None,
Expand Down Expand Up @@ -147,6 +148,7 @@ def train(self, train_data, epochs=10, kwargs={}):

class M3GNetHypothesisAgent(HypothesisAgent):
"""Generic agent for AL using m3gnet"""

def __init__(self, m3gnet=None, candidate_data=None, seed_data=None, n_query=None):

"""
Expand Down
62 changes: 32 additions & 30 deletions camd/agent/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@


REGRESSOR_PARAMS = [
{
"@class": ["sklearn.linear_model.LinearRegression"],
"fit_intercept": [True, False],
"normalize": [True, False]
},
{
"@class": ["sklearn.ensemble.RandomForestRegressor"],
"n_estimators": [100],
"max_features": list(np.arange(0.05, 1.01, 0.05)),
"min_samples_split": list(range(2, 21)),
"min_samples_leaf": list(range(1, 21)),
"bootstrap": [True, False]
},
{
"@class": ["sklearn.neural_network.MLPRegressor"],
"hidden_layer_sizes": [
# I think there's a better way to support this, but need to think
(80, 50),
(84, 55),
(87, 60),
],
"activation": ["identity", "logistic", "tanh", "relu"],
"learning_rate": ["constant", "invscaling", "adaptive"]
},
]
{
"@class": ["sklearn.linear_model.LinearRegression"],
"fit_intercept": [True, False],
"normalize": [True, False],
},
{
"@class": ["sklearn.ensemble.RandomForestRegressor"],
"n_estimators": [100],
"max_features": list(np.arange(0.05, 1.01, 0.05)),
"min_samples_split": list(range(2, 21)),
"min_samples_leaf": list(range(1, 21)),
"bootstrap": [True, False],
},
{
"@class": ["sklearn.neural_network.MLPRegressor"],
"hidden_layer_sizes": [
# I think there's a better way to support this, but need to think
(80, 50),
(84, 55),
(87, 60),
],
"activation": ["identity", "logistic", "tanh", "relu"],
"learning_rate": ["constant", "invscaling", "adaptive"],
},
]


AGENT_PARAMS = [
Expand All @@ -45,14 +45,14 @@
"n_members": list(range(2, 5)),
"hull_distance": list(np.arange(0.05, 0.21, 0.05)),
"training_fraction": [0.4, 0.5, 0.6],
"model": REGRESSOR_PARAMS
"model": REGRESSOR_PARAMS,
},
{
"@class": ["camd.agent.agents.AgentStabilityML5"],
"n_query": [4, 6, 8],
"hull_distance": [0.05, 0.1, 0.15, 0.2],
"exploit_fraction": [0.4, 0.5, 0.6],
"model": REGRESSOR_PARAMS
"model": REGRESSOR_PARAMS,
},
]

Expand All @@ -73,9 +73,11 @@ def convert_parameter_table_to_dataframe(parameter_table, fillna=np.nan):
"""
df = pd.DataFrame(parameter_table, dtype="int64")
df.index = ['-'.join([str(i) for i in row]) for row in np.array(df)]
df['agent'] = [parameter_table.hydrate_index(i, construct_object=True)
for i in range(len(parameter_table))]
df.index = ["-".join([str(i) for i in row]) for row in np.array(df)]
df["agent"] = [
parameter_table.hydrate_index(i, construct_object=True)
for i in range(len(parameter_table))
]
df.fillna(fillna)
return df

Expand Down
Loading

0 comments on commit aa31cd0

Please sign in to comment.