from doepy import build
import plotly.express as px
import plotly
df = build.lhs(
{'Cooking time (mins)':[40,60],
'Oven temperature (C)':[150,200],
'Flour mass (g)':[300,400]},
num_samples=12
)
df
Cooking time (mins) | Oven temperature (C) | Flour mass (g) | |
---|---|---|---|
0 | 52.667561 | 162.468726 | 398.287146 |
1 | 49.296672 | 184.232729 | 377.040491 |
2 | 54.787274 | 188.360551 | 335.025955 |
3 | 58.403253 | 195.903942 | 346.525913 |
4 | 47.161711 | 152.463441 | 366.732327 |
5 | 55.343486 | 171.053152 | 361.458470 |
6 | 56.833208 | 182.930209 | 333.008200 |
7 | 40.799624 | 175.390838 | 313.430777 |
8 | 42.090438 | 170.796043 | 317.127645 |
9 | 45.492060 | 156.454264 | 350.722775 |
10 | 50.869119 | 192.169410 | 304.362577 |
11 | 44.304402 | 166.101580 | 385.743787 |
plotly.offline.init_notebook_mode(connected=True)
fig = px.scatter_3d(df,x='Cooking time (mins)', y='Oven temperature (C)', z='Flour mass (g)',
template="none",labels={
'Cooking time (mins)': 'Cooking time (mins)',
'Oven temperature (C)': 'Oven temperature (°C)',
'Flour mass (g)': 'Flour mass (g)'
})
fig.update_layout(font_family="Courier New",font_color="black",title_font_family="Courier New",title={
'text' : "Latin hypercube sampling",
'y':0.9,
'x':0.5,
'xanchor': 'center',
})
fig.update_traces(marker=dict(size=8,color='mediumpurple',line=dict(width=2,
color='DarkSlateGrey')), selector=dict(mode='markers'))
fig.update_layout(scene = dict(
xaxis = dict(
gridcolor="black",
showbackground=True,
zerolinecolor="black",
showgrid = True,
showline = True,
range = [35,65]),
yaxis = dict(
gridcolor="black",
showbackground=True,
zerolinecolor="black",
showgrid = True,
zeroline = True,
showline = True,
range = [145,205]),
zaxis = dict(
gridcolor="black",
showbackground=True,
zerolinecolor="black",
showgrid = True,
zeroline = True,
showline = True,
range = [295,405])),
width=700,
margin=dict(
r=20, l=10,
b=10, t=10)
)
fig.show()
df2 = build.space_filling_lhs(
{'Cooking time (mins)':[40,60],
'Oven temperature (C)':[150,200],
'Flour mass (g)':[300,400]},
num_samples=12
)
df2
Cooking time (mins) | Oven temperature (C) | Flour mass (g) | |
---|---|---|---|
0 | 41.818182 | 154.545455 | 400.000000 |
1 | 49.090909 | 177.272727 | 381.818182 |
2 | 47.272727 | 190.909091 | 327.272727 |
3 | 40.000000 | 168.181818 | 390.909091 |
4 | 50.909091 | 181.818182 | 345.454545 |
5 | 60.000000 | 172.727273 | 309.090909 |
6 | 52.727273 | 195.454545 | 372.727273 |
7 | 58.181818 | 163.636364 | 300.000000 |
8 | 56.363636 | 159.090909 | 354.545455 |
9 | 45.454545 | 186.363636 | 363.636364 |
10 | 43.636364 | 150.000000 | 336.363636 |
11 | 54.545455 | 200.000000 | 318.181818 |
plotly.offline.init_notebook_mode(connected=True)
fig2 = px.scatter_3d(df2,x='Cooking time (mins)', y='Oven temperature (C)', z='Flour mass (g)',
template="none",labels={
'Cooking time (mins)': 'Cooking time (mins)',
'Oven temperature (C)': 'Oven temperature (°C)',
'Flour mass (g)': 'Flour mass (g)'
})
fig2.update_layout(font_family="Courier New",font_color="black",title_font_family="Courier New",title={
'text' : "Space-filling Latin hypercube sampling",
'y':0.9,
'x':0.5,
'xanchor': 'center',
})
fig2.update_traces(marker=dict(size=8,color='mediumpurple',line=dict(width=2,
color='DarkSlateGrey')), selector=dict(mode='markers'))
fig2.update_layout(scene = dict(
xaxis = dict(
gridcolor="black",
showbackground=True,
zerolinecolor="black",
showgrid = True,
showline = True,
range = [35,65]),
yaxis = dict(
gridcolor="black",
showbackground=True,
zerolinecolor="black",
showgrid = True,
zeroline = True,
showline = True,
range = [145,205]),
zaxis = dict(
gridcolor="black",
showbackground=True,
zerolinecolor="black",
showgrid = True,
zeroline = True,
showline = True,
range = [295,405])),
width=700,
margin=dict(
r=20, l=10,
b=10, t=10)
)
fig2.show()