Let’s create an experimental_data(temp, conc) function that simulates the yield of a chemical reaction based on temperature, concentration A, concentration B and concentration C.
import numpy as npimport pandas as pdimport plotly.graph_objects as goimport plotly.io as piopio.renderers.default ="notebook"def experimental_data(temp, cA, cB, cC):""" This function simulates experimental data based on temperature and concentrations. The function is not based on any real experimental data and is purely for demonstration purposes. """ out =.2*temp +.5*temp*cA + (cA)/3+ (1- cB)**2/2+ (3- cC)/1.5+ np.random.normal(0, 0.2, len(temp))return outdef generate_data(N=100): temp = np.random.uniform(0, 100, N) cA = np.random.uniform(0, 1, N) cB = np.random.uniform(0, 1, N) cC = np.random.uniform(0, 1, N) exp_response = experimental_data(temp, cA, cB, cC)# Create a DataFrame with the generated data df = pd.DataFrame({'temp': temp, 'cA': cA, 'cB': cB, 'cC': cC, 'response': exp_response})return dfdf = generate_data(50)df.to_csv('dataML.csv', index=False)df.head()
temp
cA
cB
cC
response
0
11.251967
0.274572
0.510769
0.320083
5.665817
1
52.767722
0.149580
0.000185
0.751806
16.517494
2
70.363543
0.251513
0.184655
0.169892
25.203428
3
52.331971
0.467241
0.287215
0.154678
25.058860
4
67.584432
0.132317
0.879010
0.868066
19.396625
Now, we will use the OPTIMEO package to analyse the data.