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 jb_test_statistic(column): | |
""" | |
Function for creating JB test statistic equation from pandas dataframe column | |
""" | |
# have all nulls removed, get the data length, and convert column values to an array | |
column = column.dropna() | |
n = column.shape[0] | |
column_values = column.values | |
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
# apply Jarque-Bera Test to baby_counts for each year | |
years = baby_names["Year of Birth"].sort_values().unique().tolist() | |
for year in years: | |
baby_year = baby_names[baby_names["Year of Birth"] == year] | |
jb_results = jarque_bera(baby_year["Count"]) | |
print(f"Jarque-Bera Count Results for {year}: {jb_results}") |
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
# compute jarque_bera for Counts column | |
jarque_bera(baby_names["Count"]) |
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 libraries | |
import pandas as pd | |
from scipy.stats import jarque_bera | |
# load data | |
baby_names = pd.read_csv("Popular_Baby_Names.csv") | |
# inspect data | |
baby_names.info() |
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
recall = cm[1,1]/(cm[1,1] + cm[1,0]) | |
precision = cm[1,1]/(cm[1,1] + cm[0, 1]) | |
fmi = sqrt(precision * recall) |
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
recall = cm[1,1]/(cm[1,1] + cm[1,0]) | |
specificity = cm[0,0]/(cm[0,0] + cm[0,1]) | |
numerator = sqrt(recall * (-specificity+1)) + specificity - 1 | |
denominator = recall + specificity - 1 | |
prevalence_threshold = numerator/denominator |
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
numerator = (cm[1,1] * cm[0,0]) - (cm[0,1] * cm[1,0]) | |
denominator = sqrt((cm[1,1] + cm[0,1]) * (cm[1,1] + cm[1,0]) * (cm[0,0] + cm[0,1]) * (cm[0,0] + cm[1,0])) | |
mcc = numerator/denominator |
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
precision = cm[1, 1]/(cm[1,1] + cm[0, 1]) | |
negative_predictive_value = cm[0, 0]/(cm[0,0] + cm[1,0]) | |
markedness = precision + negative_predictive_value - 1 |
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
recall = cm[1, 1]/(cm[1,1] + cm[1,0]) | |
specificity = cm[0, 0]/(cm[0,0] + cm[0,1]) | |
informedness = recall + specificity - 1 |
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
precision = cm[1,1]/(cm[1,1] + cm[0,1]) | |
recall = cm[1,1]/(cm[1,1] + cm[1,0]) | |
numerator = precision*recall | |
denominator = precision + recall | |
f1_score = 2* numerator/denominator |
NewerOlder