Exemplo n.º 1
0
from skopt import BayesSearchCV
from catboost import CatBoostRegressor
from scipy.stats import norm,uniform
import numpy as np
import pickle

"""
Used to generate trained GB models with different train-test splits.
"""

np.random.seed(100)

df = pickle.load(open('../../data/pairs_pdos.pkl'))

if True:
    X,y = train_prep_pdos(df,include_WF=True,dE=0.1)
    model_type = 'pdos'
else:
    X,y = train_prep(df,include_WF=True)
    model_type = 'moments'

if False:
    X_train, X_dev, X_test, y_train, y_dev, y_test = split_by_cols(df,X,y,['comp','ads_a','ads_b'])
    split_type = 'comp_rxn'
elif True:
    X_train, X_dev, X_test, y_train, y_dev, y_test = split_by_cols(df,X,y,['comp'])
    split_type = 'comp'
elif False:
    X_train, X_dev, X_test, y_train, y_dev, y_test = split_by_cols(df,X,y,['ads_a','ads_b'])
    split_type = 'rxn'
else:
Exemplo n.º 2
0
    print('Model Performance')
    print('Average Error: {:0.4f} eV.'.format(mae))
    return mae


if __name__ == '__main__':
    df = pickle.load(open('data/pairs_pdos.pkl'))

    features = 'moments'  # #pdos,'moments'
    bayes = True

    #Feature Selection
    if features == 'moments':
        X, y = train_prep(df)
    elif features == 'pdos':
        X, y = train_prep_pdos(df, stack=False, include_WF=False, dE=0.1)

    X_train, X_dev, X_test, y_train, y_dev, y_test, groups = split_by_cols(
        df, X, y, ['comp', 'ads_a', 'ads_b'], ret_groups=True)

    rf = ensemble.RandomForestRegressor(n_estimators=100)

    group_kfold = GroupKFold(n_splits=3)

    #print(X_train.shape[1]),np.sqrt(X_train.shape[1])
    if bayes:
        random_grid = {  #'n_estimators': (5,100),
            'max_features': (int(np.sqrt(X_train.shape[1])), X_train.shape[1]),
            'max_depth': (5, 50),
            'min_samples_split': (2, 10),
            'min_samples_leaf': (2, 5),
Exemplo n.º 3
0
    key = [
        'comp', 'bulk', 'facet', 'coord', 'site_b', 'ads_a', 'ads_b', 'comp_g',
        'dE'
    ]
    df = pickle.load(open('data/pairs_pdos.pkl'))

    #models = ['rf','lr','krr']#,'NN']
    models = ['rf', 'boost']
    features = 'pdos'  # #pdos,'moments'
    split = 'pairs'

    #Feature Selection
    if features == 'moments':
        X, y = train_prep(df)
    elif features == 'pdos':
        X, y = train_prep_pdos(df, stack=False, include_WF=True)
        #X,y = train_prep_pdos(df,include_WF=True,stack=True)

    for m in models:
        #Train/test split
        if split == 'none':
            X_train = X
            X_test = X
            y_train = y
            y_test = y
        elif split == 'random':
            np.random.seed(100)
            X_train, X_test, y_train, y_test = train_test_split(
                X, y, test_size=0.3)  #need to add dev
            X_dev, X_test, y_dev, y_test = train_test_split(
                X_test, y_test, test_size=0.5)  #need to add dev