Skip to content

Instantly share code, notes, and snippets.

View marcosfelt's full-sized avatar

Kobi Felton marcosfelt

View GitHub Profile
@marcosfelt
marcosfelt / chemios_tc_base.py
Created June 23, 2018 17:12
Chemios Temperature Controllers Base
# -*- coding: utf-8 -*-
"""Base Class for Temperature Controllers"""
from abc import ABC
class TemperatureControllers(ABC):
'''Base Class for Temperature Controllers
'''
def get_current_temperature(self):
@marcosfelt
marcosfelt / persistent_cache.py
Last active January 8, 2019 16:06
Simple Persistent Cache in python
class Cache:
def __init__(self, user_function):
self.user_function = user_function
def __call__(self, *args, **kwargs):
sentinel = object()
key = _make_key(args, kwargs, False)
try:
result = self.cache.get(key, sentinel)
except NameError:
@marcosfelt
marcosfelt / loo.py
Created May 1, 2019 00:52
Leave One Out Cross Validation GPy
import numpy as np
import GPy
import matplotlib.pyplot as plt
from plotting import plot_3d_model
#Teset data
seed = 947
rs = np.random.RandomState(seed)
X = rs.rand(1000, 2)*100
f = lambda x: np.atleast_2d(np.exp(-x[:, 0]) + 10*x[:, 1]**2).T
ord download --dataset=$DATASET_ID --out=$(pwd) --query="query.txt" --out="sample_dataset.csv"
@marcosfelt
marcosfelt / weighted_mse.py
Created May 27, 2021 12:58
ExperimentalEmulator MultiObjective
from summit import *
import torch
from torch import Tensor
# Replace this with however you import your data
data = get_data()
# Replace this with however you specify your domain
domain = get_domain()
@marcosfelt
marcosfelt / sensitivity_analysis.py
Created July 13, 2021 15:28
Bayesian Optimization Sensitivity Analysis
from summit import *
import numpy as np
import pandas as pd
import GPy
def main():
# Get the in-silico benchmark
exp, catalyst_list, base_list = setup_benchmark()
# Run optimization
from rdkit import Chem
from rdkit.Chem.Scaffolds import MurckoScaffold
from tqdm import tqdm
import numpy as np
from sklearn.model_selection import GroupShuffleSplit
import logging
def scaffold_split(df, column_to_split:str, test_size=0.1):
"""" Split a dataframe by scaffolds
@marcosfelt
marcosfelt / README.md
Last active November 6, 2021 20:43
Lably Testing

To setup:

python venv .venv
source .venv/
pip install -r requirements.txt

Then to run the app

streamlit run main.py
@marcosfelt
marcosfelt / fit_nrtl_ray.py
Created May 16, 2022 09:55
Fitting the NRTL model to data using Ray
import pandas as pd
import numpy as np
from lmfit import minimize, Parameters
import ray
from ray.exceptions import GetTimeoutError
from tqdm.auto import tqdm, trange
import typer
@marcosfelt
marcosfelt / distill.py
Last active May 24, 2022 08:29
Dynamic simulation of a distillation column in python
from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt
from typing import List, Union, Optional
class BinaryDistillationColumn:
"""
Notes
------