def test_sync(self): with ScratchDir('.'): df = pd.read_csv(os.path.join(CAMD_TEST_FILES, 'test_df.csv')) # Construct and start campaign new_campaign = Campaign(df, AgentStabilityML5(), ATFSampler(df), StabilityAnalyzer(), create_seed=10, s3_prefix="test") new_campaign.auto_loop(n_iterations=3, save_iterations=True, initialize=True) # Test iteration read s3 = boto3.resource('s3') obj = s3.Object(CAMD_S3_BUCKET, "test/iteration.json") loaded = json.loads(obj.get()['Body'].read()) self.assertEqual(loaded, 2) # Test save directories for iteration in [-1, 0, 1, 2]: obj = s3.Object(CAMD_S3_BUCKET, f"test/{iteration}/iteration.json") loaded = json.loads(obj.get()['Body'].read()) self.assertEqual(loaded, iteration)
def test_simple_dft(self): with ScratchDir('.'): campaign = ProtoDFTCampaign.from_chemsys("Si") # Nerf agent a bit agent = AgentStabilityML5(n_query=2) campaign.agent = agent campaign.autorun()
def test_sync(self): with ScratchDir('.'): df = pd.read_csv(os.path.join(CAMD_TEST_FILES, 'test_df.csv')) # Construct and start campaign new_campaign = Campaign(df, AgentStabilityML5(), ATFSampler(df), StabilityAnalyzer(), create_seed=10, s3_prefix="test") new_campaign.initialize() s3 = boto3.resource('s3') obj = s3.Object(CAMD_S3_BUCKET, "test/iteration.json") loaded = json.loads(obj.get()['Body'].read()) self.assertEqual(loaded, 0)
from sklearn.neural_network import MLPRegressor from camd.agent.stability import AgentStabilityML5 from camd.analysis import StabilityAnalyzer from camd.experiment.base import ATFSampler from camd.utils.data import load_default_atf_data ########################################################## # Load dataset and filter by N_species of 2 or less ########################################################## df = load_default_atf_data() ## Epsilon-Greedy n_seed = 5000 # Starting sample size - a seed of this size will be randomly chosen. n_query = 200 # This many new candidates are "calculated with DFT" (i.e. requested from Oracle -- DFT) agent = AgentStabilityML5(model=MLPRegressor(hidden_layer_sizes=(84, 50)), n_query=n_query, hull_distance=0.05, exploit_fraction=0.5) analyzer = StabilityAnalyzer(hull_distance=0.05) experiment = ATFSampler(dataframe=df) candidate_data = df ########################################################## new_loop = Campaign(candidate_data, agent, experiment, analyzer, create_seed=n_seed) new_loop.auto_loop(n_iterations=4, initialize=True)
def test_ml_agent(self): agent = AgentStabilityML5() hypotheses = agent.get_hypotheses(candidate_data=self.candidate_data, seed_data=self.seed_data)