[docs]def plot_results_altair(results, fidelity='epoch'):
"""
Parameters
----------
results: List[dict(fidelity=str, objective=float)]
Examples
--------
.. code-block: python
results = [
dict(epoch=1, objective=0.229),
dict(epoch=2, objective=0.30),
dict(epoch=3, objective=0.40),
dict(epoch=4, objective=0.50),
]
plot_results_altair(results, fidelity=epoch)
.. image:: ../../../docs/_static/plots/objective.png
"""
import altair as alt
alt.themes.enable('dark')
data = alt.Data(values=list(results))
# data = pd.DataFrame(results)
line = alt.Chart(data).mark_line().encode(
x=alt.X(f'{fidelity}:Q'),
y='mean(objective):Q'
)
band = alt.Chart(data).mark_errorband(extent='ci').encode(
x=alt.X(f'{fidelity}:Q'),
y=alt.Y('objective:Q', title='objective'),
)
graph = (band + line).configure_view(height=500, width=1000)
return graph
plots = {
'objective': {
'altair': plot_results_altair
}
}