Skip to content

Commit

Permalink
Revert "Address Linting Warnings"
Browse files Browse the repository at this point in the history
- Local repo wasn't properly updated, leading to the undoing of important recent readme PR request

This reverts commit 684a03c.
  • Loading branch information
JacobGlennAyers committed Jul 30, 2021
1 parent 684a03c commit 3bb9c8a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
4 changes: 4 additions & 0 deletions PyHa/IsoAutio.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def simple_isolate(local_scores, SIGNAL, SAMPLE_RATE, audio_dir, filename, isola

annotation_start = 0
call_start = 0
call_stop = 0
# looping through all of the local scores
for ndx in range(len(local_scores)):
current_score = local_scores[ndx]
Expand Down Expand Up @@ -333,6 +334,7 @@ def stack_isolate(local_scores, SIGNAL, SAMPLE_RATE, audio_dir, filename, isolat
stack_counter = 0
annotation_start = 0
call_start = 0
call_stop = 0
# looping through every local score array value
for ndx in range(len(local_scores)):
# the case for the end of the local score array and the stack isn't empty.
Expand Down Expand Up @@ -515,6 +517,8 @@ def generate_automated_labels(audio_dir, isolation_parameters, manual_id = "bird
print("Error in detection, skipping", audio_file)
continue

# get duration of clip
duration = len(SIGNAL) / SAMPLE_RATE

try:
# Running moment to moment algorithm and appending to a master dataframe.
Expand Down
32 changes: 11 additions & 21 deletions PyHa/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,32 +171,22 @@ def automated_labeling_statistics(automated_df,manual_df,stats_type = "IoU", thr
statistics_df.reset_index(inplace = True, drop = True)
return statistics_df

# Function that will provide statistics across a whole dataset, inclusive of all classes
def dataset_statistics(statistics_df, stats_type):

return pd.DataFrame.from_dict([entry])

# Function that summarizes statistics across all classes
def global_dataset_statistics(statistics_df, stats_type):

return pd.DataFrame.from_dict([entry])

def class_general_statistics(statistics_df):
def global_dataset_statistics(statistics_df):
"""
Function that takes in a dataframe of statistics for multiple clips and outputs the same statistics, but across summed across the dataset.
Function that takes in a dataframe of efficiency statistics for multiple clips and outputs their global values.
Args:
statistics_df (Dataframe) - Dataframe of statistics value for multiple audio clips as returned by the function automated_labelling_statistics.
Returns:
Dataframe of global statistics for the efficacy of automated labels across multiple audio clips.
Dataframe of global statistics for the multiple audio clips' labelling.
"""
# Determining which class the clips are derived from
class_id = statistics_df["MANUAL ID"][0]
# summing all of the
tp_sum = statistics_df["TRUE POSITIVE"].sum()
fp_sum = statistics_df["FALSE POSITIVE"].sum()
fn_sum = statistics_df["FALSE NEGATIVE"].sum()
#tn_sum = statistics_df["TRUE NEGATIVE"].sum()
tn_sum = statistics_df["TRUE NEGATIVE"].sum()
union_sum = statistics_df["UNION"].sum()
precision = tp_sum/(tp_sum + fp_sum)
recall = tp_sum/(tp_sum + fn_sum)
Expand Down Expand Up @@ -351,7 +341,7 @@ def clip_catch(automated_df,manual_df):
manual_df.reset_index(inplace = True, drop = True)
# figuring out how many automated labels and human labels exist
manual_row_count = manual_df.shape[0]
#automated_row_count = automated_df.shape[0]
automated_row_count = automated_df.shape[0]
# finding the length of the clip as well as the sampling frequency.
duration = automated_df["CLIP LENGTH"].to_list()[0]
SAMPLE_RATE = automated_df["SAMPLE RATE"].to_list()[0]
Expand Down Expand Up @@ -463,7 +453,7 @@ def clip_catch(automated_df,manual_df):
# IoU_Statistics.reset_index(inplace = True, drop = True)
# return IoU_Statistics

def class_IoU_statistics(statistics_df):
def global_IoU_Statistics(statistics_df):
"""
Function that takes the output of dataset_IoU Statistics and outputs a global count of true positives and false positives,
as well as computing the precision, recall, and f1 metrics across the dataset.
Expand Down Expand Up @@ -541,7 +531,7 @@ def dataset_Catch(automated_df,manual_df):
# I am going to wait on showing off this function since we don't have any multi-class classifiers yet.
def dataset_IoU_Statistics(automated_df, manual_df, threshold = 0.5):

# Building a list of unique classes
# finding the number of unique classes.
class_list = manual_df["MANUAL ID"].to_list()
class_list = list(dict.fromkeys(class_list))

Expand All @@ -551,13 +541,13 @@ def dataset_IoU_Statistics(automated_df, manual_df, threshold = 0.5):

# Looping through each class
for class_id in class_list:
# Isolating the class from the passed in dataframe
# Isolating the class from the
class_automated_df = automated_df[automated_df["MANUAL_ID"] == class_id]
class_manual_df = manual_df[manual_df["MANUAL ID"] == class_id]
class_stats_df = class_IoU_Statistics(class_automated_df,class_manual_df, threshold = threshold)
class_global_stats_df = class_IoU_statistics(class_stats_df)
class_global_stats_df = global_IoU_Statistics(class_stats_df)
if master_clip_stats_df.empty:
master_clip_stats_df = class_stats_df
master_clips_stats_df = class_stats_df
if master_global_stats_df.empty:
master_global_stats_df = class_global_stats_df
else:
Expand Down
4 changes: 2 additions & 2 deletions PyHa/visualizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd
import scipy.signal as scipy_signal
import numpy as np
from .IsoAutio import isolate
from .IsoAutio import *



Expand Down Expand Up @@ -181,7 +181,7 @@ def plot_bird_label_scores(automated_df,human_df,save_fig = False):
human_arr = np.zeros((int(SAMPLE_RATE*duration),))
bot_arr = np.zeros((int(SAMPLE_RATE*duration),))

#folder_name = automated_df["FOLDER"].to_list()[0]
folder_name = automated_df["FOLDER"].to_list()[0]
clip_name = automated_df["IN FILE"].to_list()[0]
# Placing 1s wherever the au
for row in automated_df.index:
Expand Down

1 comment on commit 3bb9c8a

@JacobGlennAyers
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't properly update local staging branch, so we reverted these changes, and remerged the previous PR request from the readme branch

Please sign in to comment.