Skip to content

Instantly share code, notes, and snippets.

View alcazar90's full-sized avatar
🎯
Focusing

Cristóbal Alcázar alcazar90

🎯
Focusing
View GitHub Profile
@alcazar90
alcazar90 / python_figure_chapter8_83.txt
Last active March 15, 2022 22:09
Python code for reproduce figure 8.3, chapter 8, book: Intro to Probability for Data Science
# python code for reproduce figure 8.3, chapter 8, book: Intro to Probability for Data Science
# https://probability4datascience.com/python08.html
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
from mpl_toolkits.axes_grid1 import make_axes_locatable
# Bernoulli log-likelihood sequence
N = 50
S = np.linspace(0, N)
library(ISLR)
# prepare data example
df <- ISLR::Hitters[, c("Salary", "Years")]
row.names(df) <- NULL
df$Salary <- log(df$Salary)
# remove the observation with missing values in the response variable
df <- df[!is.na(df$Salary), ]
x <- df$Years