2D Projection prediction#
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams['figure.dpi'] = 120
Loading the data#
doe = pd.read_csv('../data/doe.csv')
data = pd.read_csv('../data/projection.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 ProjectionPredictor
reg = ProjectionPredictor()
reg.load_data(
    doe = doe,
    data = data,
    index='doe_id',
    process_parameters = [
        'Blechdicke', 
        'Niederhalterkraft', 
        'Ziehspalt', 
        'Einlegeposition', 
        'Ziehtiefe',
        'Rp0',
    ],
    categorical = [
        'Ziehspalt', 
        'Ziehtiefe',
    ],
    position = ['xp', 'yp'],
    output = ['deviation', 'thickness'],
    validation_split=0.1,
    validation_method='leaveoneout'
)
reg.save_config("../models/projection.pkl")
reg.data_summary()
config = {
    'batch_size': 4096*16,
    'max_epochs': 5,
    'layers': [256, 256, 256, 256, 256],
    'dropout': 0.0,
    'learning_rate': 0.001
}
reg.custom_model(save_path='../models/best_projection_model', config=config, verbose=True)
reg.training_summary()
reg.load_network('../models/best_projection_model')
x, y = reg.predict({
        'Blechdicke': 1.01, 
        'Niederhalterkraft': 410.0, 
        'Ziehspalt': 2.4, 
        'Einlegeposition': -5, 
        'Ziehtiefe': 30,
        'Stempel_ID': 3,
    }, 
    shape=(1000, 1000))
plt.figure()
plt.imshow(y[0, :, :].T)
plt.colorbar()
plt.figure()
plt.imshow(y[1, :, :].T)
plt.colorbar()
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.imshow(y[0, :, :].T)
    plt.colorbar()
    plt.figure()
    plt.imshow(y[1, :, :].T)
    plt.colorbar()
reg.interactive(function=viz, positions=(1000, 1000))