Beispiel #1
0
    'Normal', 'Temper1', 'AGS No.', 'CT_MCR'])
df['log_CT_CS'] = np.log(df['CT_CS'])
df['log_CT_MCR'] = np.log(df['CT_MCR'])

df['LMP_Model'] = df.apply(lambda x:
        1e-3 * x['CT_Temp'] * (np.log(x['CT_RT']) + 25), axis=1)

features = [i for i in df.columns if i not in ['CT_RT', 'CT_Temp', 
    'ID', 'CT_CS', 'LMP_Model', 'CT_MCR']]
df = df[df['CT_RT'] < 200000]
X = df[features].to_numpy(np.float32)
y = df['LMP_Model'].to_numpy(np.float32)
y2 = df[['ID', 'CT_RT', 'CT_Temp', 'CT_CS']].values.tolist()

pdata = ProcessData(X=X, y=y, y2=y2, features=features)
pdata.clean_data()
data = pdata.get_data()
scale = pdata.scale
del pdata

CT_RT = np.array([i[1] for i in data['y2']])
CT_Temp = np.array([i[2] for i in data['y2']])
CT_CS = np.array([i[3] for i in data['y2']])
ID = [i[0] for i in data['y2']]
C = np.array([25 for i in ID])

skreg = SKREG(X=data['X'],
              y=data['y'],
              estimator="LR",
              validation="3-Fold",
              CT_Temp=CT_Temp,
Beispiel #2
0
df = df.dropna(subset=[
    'CT_RT', 'CT_CS', 'CT_EL', 'CT_RA', 'CT_Temp', 'Normal', 'Temper1',
    'AGS No.', 'CT_MCR'
])
df['log_CT_CS'] = np.log(df['CT_CS'])
df['log_CT_MCR'] = np.log(df['CT_MCR'])

features = [i for i in df.columns if i not in ['CT_CS', 'CT_MCR', 'ID']]
X = df[features].to_numpy(np.float32)
#print(X.shape)
y = df['CT_RT'].to_numpy(np.float32)

pdata = ProcessData(X=X, y=y, features=features)
#pdata.clean_data(scale_strategy={'strategy': 'power_transform',
#    'method': 'yeo-johnson'})
pdata.clean_data(scale_strategy={'strategy': 'MinMaxScaler'})
data = pdata.get_data()
scale = pdata.scale
#X = scale.inverse_transform(data['X'])
X = data['X']
features = data['features']
del data, pdata, df, y, ID, ele, model

ae = AutoEncoder(arch=[33, 22, 11], X=X, loss='mse', epochs=250)

ae.build_model()
X_pred = ae.predict(X)
print(scale.inverse_transform(X)[0], scale.inverse_transform(X_pred)[0])

X_gen = ae.get_random_alloy()
print(scale.inverse_transform(X_gen)[0])
Beispiel #3
0
    'Ti', 'Ta', 'Hf', 'Re', 'V', 'B', 'N', 'O', 'S', 'Zr'
]
df[ele] = df[ele].fillna(0)
df = df.dropna(subset=[
    'CT_RT', 'CT_CS', 'CT_EL', 'CT_RA', 'CT_Temp', 'Normal', 'Temper1',
    'AGS No.', 'CT_MCR'
])
df['log_CT_CS'] = np.log(df['CT_CS'])
df['log_CT_MCR'] = np.log(df['CT_MCR'])

features = [
    i for i in df.columns if i not in ['CT_RT', 'CT_CS', 'CT_MCR', 'ID']
]
X = df[features].to_numpy(np.float32)
y = df['CT_RT'].to_numpy(np.float32)

pdata = ProcessData(X=X, y=y, features=features)
#pdata.clean_data(scale_strategy={'strategy': 'power_transform',
#    'method': 'yeo-johnson'})
pdata.clean_data(scale_strategy={'strategy': 'RobustScaler'})
data = pdata.get_data()
scale = pdata.scale
del pdata

X = data['X'][data['y'] < 200000]
y = data['y'][data['y'] < 200000]

skreg = SKREG(X=X, y=y, estimator='LR', validation='5-Fold')
skreg.run_reg()
print(skreg.__dict__)
Beispiel #4
0
    "Fe", "C", "Cr", "Mn", "Si", "Ni", "Co", "Mo", "W", "Nb", "Al", "P", "Cu",
    "Ti", "V", "B", "N", "S"
]
df[ele] = df[ele].fillna(0)
df = df.dropna(
    subset=['CT_RT', 'CT_CS', 'CT_EL', 'CT_RA', 'CT_Temp', 'AGS No.'])
df['log_CT_CS'] = np.log(df['CT_CS'])
df['log_CT_MCR'] = np.log(df['CT_MCR'])
features = [
    i for i in df.columns if i not in ['CT_RT', 'CT_CS', 'ID', 'CT_MCR']
]
features = [i for i in features if 'Weighted' not in i]
X = df[features].to_numpy(np.float32)
y = df['CT_RT'].to_numpy(np.float32)
pdata = ProcessData(X=X, y=y, features=features)
pdata.clean_data(scale_strategy={'strategy': 'StandardScaler'})
data = pdata.get_data()
scale = pdata.scale
del pdata

parameters = {
    'iterations': None,
    'learning_rate': None,
    'depth': None,
    'l2_leaf_reg': None,
    'model_size_reg': None,
    'rsm': None,
    'loss_function': 'RMSE',
    'border_count': None,
    'feature_border_type': None,
    'per_float_feature_quantization': None,
Beispiel #5
0
ID = [1, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
      43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 58, 59, 60,
      61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
      77, 78, 79, 82]
ID = ['9Cr-{}'.format(str(i).zfill(3)) for i in ID]
df = df[df.ID.isin(ID)]
df['log_CT_CS'] = np.log(df['CT_CS'])
X = df[[i for i in df.columns if i not in ['ID', 'CT_RT', 
    'CT_Temp', 'CT_CS']]].to_numpy(dtype=np.float)
df['LMP'] = df.apply(lambda x: 1e-3*(x['CT_Temp'])*(np.log(x['CT_RT']) 
    +data[x['ID']]['C']), axis=1)
y = df['LMP'].to_numpy()

dprocess = ProcessData(X=X, y=y, metadata=[i for i in df.columns 
    if i not in ['ID', 'CT_RT', 'CT_Temp', 'CT_CS']])
dprocess.clean_data()
X, y, metadata = dprocess.get_data()
del dprocess

df = pd.DataFrame(X, columns=metadata)
df['LMP'] = y

#Initialize the model
bframe = BayesFrame(df=df, target="LMP", val_scheme='5-Fold',
                    bic_scheme="per_n", model_scheme=["selection"])

#Print the best model
print(bframe.zoo)

np.save('best_model.npy', bframe.zoo)