3D Prediction#
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams['figure.dpi'] = 120
from mesh_predictor import MeshPredictor
doe = pd.read_csv('../data/doe.csv')
data = pd.read_csv('../data/zt_all_raw.csv')
data.drop(data[data.doe_id == 1000].index, inplace=True)
data.drop(data[data.doe_id == 247].index, inplace=True)
reg = MeshPredictor()
reg.load_data(
doe = doe,
data = data,
index='doe_id',
process_parameters = [
'Blechdicke',
'Niederhalterkraft',
'Ziehspalt',
'Einlegeposition',
'Ziehtiefe',
'Rp0',
],
categorical = [
'Ziehspalt',
'Ziehtiefe',
],
position = ['x', 'y', 'z'],
output = ['deviation', 'thickness'],
validation_split=0.1,
validation_method='leaveoneout'
)
reg.save_config("../models/3d_deviation.pkl")
reg.data_summary()
config = {
'batch_size': 2048*16,
'max_epochs': 20,
'layers': [256, 256, 256, 256, 256],
'dropout': 0.0,
'learning_rate': 0.001,
'activation': 'lrelu'
}
reg.custom_model(save_path='../models/current_3d_model', config=config, verbose=True)
reg.training_summary()
reg.load_network('../models/current_3d_model')
idx = np.random.choice(data['doe_id'].unique())
print("Doe_ID", idx)
p, t, y = reg.compare(idx)
geometry_50 = pd.read_csv('../data/geometry_zt50.csv')
parameters = {
'Blechdicke': 1.01,
'Niederhalterkraft': 410.0,
'Ziehspalt': 2.4,
'Einlegeposition': 0,
'Stempel_ID': 3,
'Ziehtiefe': 50,
'E': 191.37245,
'Rp0': 138.22696,
'Rp50': 449.528189,
}
positions = geometry_50[['x', 'y', 'z']].to_numpy()
df = reg.predict(parameters, positions, as_df=True)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
p = ax.scatter(positions[:, 0], positions[:, -2], positions[:, -1],
c=df['thickness'],
cmap='seismic')
fig.colorbar(p, ax=ax)
%matplotlib inline
plt.rcParams['figure.dpi'] = 120
positions_zt30 = pd.read_csv('../data/geometry_zt30.csv')[['x', 'y', 'z']].to_numpy()
positions_zt50 = pd.read_csv('../data/geometry_zt50.csv')[['x', 'y', 'z']].to_numpy()
positions_zt70 = pd.read_csv('../data/geometry_zt70.csv')[['x', 'y', 'z']].to_numpy()
reg.interactive(positions_zt30)