This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def normal_distribution_ci(confidence, x_bar, sigma, n): | |
z_score = stats.norm.interval(confidence)[1] | |
sigma_over_root_n = sigma / np.sqrt(n) | |
ci = [x_bar - z_score * sigma_over_root_n, x_bar + z_score * sigma_over_root_n] | |
return ci | |
def binomial_distribution_ci(confidence, p_hat, n): | |
z_score = stats.norm.interval(confidence)[1] | |
rhs = z_score * np.sqrt(p_hat*(1-p_hat))/n | |
ci = [p_hat - rhs, p_hat + rhs] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ipywidgets import interact, interactive, fixed, interact_manual | |
import ipywidgets as widgets | |
import scipy.stats as stats | |
import numpy as np | |
import pandas as pd | |
pd.set_option("max_colwidth", 150) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_wine_balanced['label'].value_counts(normalize=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
red_wines = df_merged_wine[df_merged_wine['label'] == 1] | |
all_white_wines = df_merged_wine[df_merged_wine['label'] == 0] | |
white_wines = all_white_wines.sample(n=red_wines.shape[0], random_state=24) | |
df_wine_balanced = pd.concat([red_wines, white_wines]) | |
df_wine_balanced |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_merged_wine['label'].value_counts(normalize=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import graphviz | |
import pydotplus | |
import matplotlib.image as mpimg | |
import io | |
import random | |
from matplotlib import pyplot as plt | |
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import graphviz | |
import pydotplus | |
import matplotlib.image as mpimg | |
import io | |
import random | |
from matplotlib import pyplot as plt | |
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# %% Remove the outliers and re-display the box-and-whisker and the histogram | |
df_normal = remove_all_outliers(df_normal, 'Col0') | |
box_and_whisker(df_normal, 'Col0') | |
df_normal['Col0'].hist() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
box_and_whisker(df_normal, 'Col0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# %% Add some outliers and re-plot | |
s[600] = 6 | |
s[700] = 6.5 | |
s[800] = 6.57 | |
s[900] = 6.8 | |
df_normal = pd.DataFrame({'Col0': s}) | |
df_normal['Col0'].hist() |