Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed plot_bird_label_scores() from statistics.py #53

Merged
merged 1 commit into from
Apr 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 0 additions & 82 deletions IsoAutio/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,88 +109,6 @@ def bird_label_scores(automated_df,human_df):

return pd.DataFrame(entry,index=[0])

def plot_bird_Label_scores(automated_df,human_df,save_fig = False):
"""
Function to visualize automated and human annotation scores across an audio clip.

Args:
automated_df (Dataframe) - Dataframe of automated labels for one clip
human_df (Dataframe) - Dataframe of human labels for one clip.
plot_fig (boolean) - Whether or not the efficiency statistics should be displayed.
save_fig (boolean) - Whether or not the plot should be saved within a file.

Returns:
Dataframe with statistics comparing the automated and human labeling.
"""
duration = automated_df["CLIP LENGTH"].to_list()[0]
SAMPLE_RATE = automated_df["SAMPLE RATE"].to_list()[0]
# Initializing two arrays that will represent the human labels and automated labels with respect to
# the audio clip
#print(SIGNAL.shape)
human_arr = np.zeros((int(SAMPLE_RATE*duration),))
bot_arr = np.zeros((int(SAMPLE_RATE*duration),))

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:
minval = int(round(automated_df["OFFSET"][row]*SAMPLE_RATE,0))
maxval = int(round((automated_df["OFFSET"][row] + automated_df["DURATION"][row]) *SAMPLE_RATE,0))
bot_arr[minval:maxval] = 1
for row in human_df.index:
minval = int(round(human_df["OFFSET"][row]*SAMPLE_RATE,0))
maxval = int(round((human_df["OFFSET"][row] + human_df["DURATION"][row])*SAMPLE_RATE,0))
human_arr[minval:maxval] = 1

human_arr_flipped = 1 - human_arr
bot_arr_flipped = 1 - bot_arr

true_positive_arr = human_arr*bot_arr
false_negative_arr = human_arr * bot_arr_flipped
false_positive_arr = human_arr_flipped * bot_arr
true_negative_arr = human_arr_flipped * bot_arr_flipped
IoU_arr = human_arr + bot_arr
IoU_arr[IoU_arr == 2] = 1

plt.figure(figsize=(22,10))
plt.subplot(7,1,1)
plt.plot(human_arr)
plt.title("Ground Truth for " + clip_name)
plt.subplot(7,1,2)
plt.plot(bot_arr)
plt.title("Automated Label for " + clip_name)

#Visualizing True Positives for the Automated Labeling
plt.subplot(7,1,3)
plt.plot(true_positive_arr)
plt.title("True Positive for " + clip_name)

#Visualizing False Negatives for the Automated Labeling
plt.subplot(7,1,4)
plt.plot(false_negative_arr)
plt.title("False Negative for " + clip_name)

plt.subplot(7,1,5)
plt.plot(false_positive_arr)
plt.title("False Positive for " + clip_name)

plt.subplot(7,1,6)
plt.plot(true_negative_arr)
plt.title("True Negative for " + clip_name)

plt.subplot(7,1,7)
plt.plot(IoU_arr)
plt.title("Union for " + clip_name)

plt.tight_layout()
if save_fig == True:
x = clip_name.split(".")
clip_name = x[0]
plt.save_fig(clip_name + "_label_plot.png")





# Will have to adjust the isolate function so that it adds a sampling rate onto the dataframes.
def automated_labeling_statistics(automated_df,manual_df):
Expand Down