Search
Surface Plot

For visualizing climbing mount likelihood :)

import numpy as np
import pandas as pd
import os
from IPython.display import display, Image
import plotly.graph_objs as go

Example from Plotly

z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv')

fig = go.Figure(data=[go.Surface(z=z_data.values)])
fig.update_traces(contours_z=dict(show=True, usecolormap=True,
                                  highlightcolor="limegreen", project_z=True))
fig.update_layout(title='Mt Bruno Elevation', autosize=False,
                  scene_camera_eye=dict(x=1.87, y=0.88, z=-0.64),
                  width=500, height=500,
                  margin=dict(l=65, r=50, b=65, t=90)
)

fig.show()
Image(filename='../images/surface-figure-1.png')

Example of Climbing Mount Likelihood (NBD)

df = pd.read_csv('../data/barchart-1.csv').iloc[:, :2]
# Get values first
alpha_array = np.arange(0.01, 1.01, 0.01)
r_array = np.arange(0.01, 1.01, 0.01)
ll = []
for i in alpha_array:
    ll_i = []
    for j in r_array:
        some_ll = log_likelihood(i, j, 1, df['values'], df['actual'])
        ll_i.append(some_ll)
    ll.append(ll_i)
fig = go.Figure(
    go.Surface(
        contours = {
            "z": {"show": True, "start": -500, "end": -491, "size": 2}
        },
        x = alpha_array,
        y = r_array,
        z = ll)
)

fig.update_layout(
        scene = {
           "xaxis": {"title": "alpha", },
           "yaxis": {"title": "r", },
           "zaxis": {"title": "log-likelihood"}
        }
)

fig.show()
Image('../images/surface-figure-2.png')

Looks kinda meh actually..

Contour Plot

Maybe a contour plot looks better..

fig = go.Figure(data =
    go.Contour(
        z=ll,
        x=alpha_array, 
        y=r_array
    ))

fig.show()
Image('../images/surface-figure-3.png')

Easier to look at compared to the 3D surface tbh