Web cut#
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams['figure.dpi'] = 150
doe = pd.read_csv('../data/doe.csv')
data = pd.read_csv('../data/cut_web_all.csv')
data.drop(data[data.doe_id == 1000].index, inplace=True)
data.drop(data[data.doe_id == 247].index, inplace=True)
from mesh_predictor import CutPredictor
reg = CutPredictor()
reg.load_data(
    doe = doe,
    data = data,
    index='doe_id',
    process_parameters = [
        'Blechdicke', 
        'Niederhalterkraft', 
        'Ziehspalt', 
        'Einlegeposition', 
        'Ziehtiefe',
        'Rp0',
    ],
    categorical = [
        'Ziehspalt', 
        'Ziehtiefe',
    ],
    position = 'c_phi',
    output = 'c_rho',
    validation_split=0.1,
    validation_method='leaveoneout'
)
reg.save_config("../models/cut_web.pkl")
reg.data_summary()
best_config = reg.autotune(
    save_path='../models/best_web_model',
    trials=100,
    max_epochs=100, 
    layers=[2, 4],
    neurons=[64, 256, 64],
    dropout=[0.0, 0.5, 0.1],
    learning_rate=[1e-5, 1e-3]
)
print(best_config)
config = {
    'batch_size': 4096,
    'max_epochs': 100,
    'layers': [128, 128, 128, 128, 128],
    'dropout': 0.0,
    'learning_rate': 0.01
}
# or best_config from autotune if you already did it once
reg.custom_model(save_path='../models/best_web_model', config=config, verbose=True)
reg.training_summary()
idx = np.random.choice(1000) + 1
print("Doe_ID", idx)
reg.compare(idx)
%matplotlib inline
plt.rcParams['figure.dpi'] = 150
def viz(x, y):
    plt.figure()
    plt.plot(x, y[:, 0])
    plt.xlabel('c_phi')
    plt.ylabel('c_rho')
reg.interactive(function=viz, positions=100)