From a2ce49c9f6e8be82d36f1eb2857dc9ca67b326cb Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 3 Mar 2021 10:28:56 -0800 Subject: [PATCH] Statistics Function for annotation lengths Added in a new function annotation_duration_statistics() which outputs the number of annotations, mode, mean, standard deviation, min, Q1, Median, Q3, and max values with respect to the lengths of the annotations --- Microfaune_Local_Score_Package_Tutorial.ipynb | 456 ++++++++++++++++-- microfaune_local_score.py | 21 + 2 files changed, 426 insertions(+), 51 deletions(-) diff --git a/Microfaune_Local_Score_Package_Tutorial.ipynb b/Microfaune_Local_Score_Package_Tutorial.ipynb index 78fe500..95074b0 100644 --- a/Microfaune_Local_Score_Package_Tutorial.ipynb +++ b/Microfaune_Local_Score_Package_Tutorial.ipynb @@ -505,13 +505,91 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Human Manual Labels for Comparison " + "### Function that gathers statistics about the duration of labels " ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
COUNTMODEMEANSTANDARD DEVIATIONMINQ1MEDIANQ3MAX
0312.05.3534725.7251781.3711562.6031294.1573475.28241534.056122
\n", + "
" + ], + "text/plain": [ + " COUNT MODE MEAN STANDARD DEVIATION MIN Q1 MEDIAN \\\n", + "0 31 2.0 5.353472 5.725178 1.371156 2.603129 4.157347 \n", + "\n", + " Q3 MAX \n", + "0 5.282415 34.056122 " + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "annotation_duration_statistics(automated_df)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Human Manual Labels for Comparison " + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, "outputs": [ { "data": { @@ -854,7 +932,7 @@ "24 0 60.000000 25.000 34.900 1 " ] }, - "execution_count": 5, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -864,6 +942,74 @@ "manual_df" ] }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
COUNTMODEMEANSTANDARD DEVIATIONMINQ1MEDIANQ3MAX
0251.06.495327.6043670.30.94.59.734.9
\n", + "
" + ], + "text/plain": [ + " COUNT MODE MEAN STANDARD DEVIATION MIN Q1 MEDIAN Q3 MAX\n", + "0 25 1.0 6.49532 7.604367 0.3 0.9 4.5 9.7 34.9" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "annotation_duration_statistics(manual_df)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -880,7 +1026,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -917,14 +1063,14 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "WARNING:tensorflow:5 out of the last 8 calls to .predict_function at 0x7fb3ac2f3310> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" + "WARNING:tensorflow:5 out of the last 8 calls to .predict_function at 0x7f4ce23ceee0> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" ] }, { @@ -960,14 +1106,14 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "WARNING:tensorflow:6 out of the last 9 calls to .predict_function at 0x7fb3de6c4550> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" + "WARNING:tensorflow:6 out of the last 9 calls to .predict_function at 0x7f4d340565e0> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" ] }, { @@ -996,14 +1142,14 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "WARNING:tensorflow:7 out of the last 10 calls to .predict_function at 0x7fb382fa49d0> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" + "WARNING:tensorflow:7 out of the last 10 calls to .predict_function at 0x7f4ce1049430> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" ] }, { @@ -1036,7 +1182,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 12, "metadata": { "scrolled": true }, @@ -1045,7 +1191,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "WARNING:tensorflow:8 out of the last 11 calls to .predict_function at 0x7fb38235c040> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" + "WARNING:tensorflow:8 out of the last 11 calls to .predict_function at 0x7f4ce06aaa60> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" ] }, { @@ -1074,7 +1220,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -1098,7 +1244,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -1162,7 +1308,7 @@ "0 5.639002 28.294059 0.691507 0.873818 0.772046 0.628725 " ] }, - "execution_count": 12, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -1180,7 +1326,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -1332,7 +1478,7 @@ "5 0.628725 " ] }, - "execution_count": 13, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -1351,7 +1497,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -1398,7 +1544,7 @@ "0 0.727076 0.743082 0.734992 0.581018" ] }, - "execution_count": 14, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -1416,7 +1562,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -1445,7 +1591,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -1503,7 +1649,7 @@ "0 1 4 4 0.2 0.2 0.2 " ] }, - "execution_count": 16, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -1521,7 +1667,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 19, "metadata": { "scrolled": true }, @@ -1663,7 +1809,7 @@ "5 0 5 5 0.0000 0.0 0.00 " ] }, - "execution_count": 17, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -1682,7 +1828,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -1733,7 +1879,7 @@ "0 1 24 30 0.0323 0.04 0.0357" ] }, - "execution_count": 18, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -1752,14 +1898,14 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "WARNING:tensorflow:9 out of the last 12 calls to .predict_function at 0x7fb3ac1d3940> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" + "WARNING:tensorflow:9 out of the last 12 calls to .predict_function at 0x7f4d255c5040> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" ] }, { @@ -1783,14 +1929,14 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "WARNING:tensorflow:9 out of the last 11 calls to .predict_function at 0x7fb3add3baf0> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" + "WARNING:tensorflow:9 out of the last 11 calls to .predict_function at 0x7f4d249b9040> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" ] }, { @@ -1812,14 +1958,14 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "WARNING:tensorflow:10 out of the last 12 calls to .predict_function at 0x7fb3adee6f70> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" + "WARNING:tensorflow:10 out of the last 12 calls to .predict_function at 0x7f4ce127ba60> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" ] }, { @@ -1848,7 +1994,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 24, "metadata": { "scrolled": true }, @@ -1864,7 +2010,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "/home/jacob/Desktop/EngineersForExploration/Bioacoustics/Automated_Audio_Labelling_System_AID/microfaune_local_score.py:738: SettingWithCopyWarning: \n", + "/home/jacob/Desktop/EngineersForExploration/Bioacoustics/Automated_Audio_Labelling_System_AID/microfaune_local_score.py:759: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", @@ -1890,7 +2036,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -2260,7 +2406,7 @@ "24 0 33.933061 29.000 4.500 1 0.4809 " ] }, - "execution_count": 23, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -2278,7 +2424,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -2303,7 +2449,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -2320,7 +2466,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "/home/jacob/Desktop/EngineersForExploration/Bioacoustics/Automated_Audio_Labelling_System_AID/microfaune_local_score.py:814: SettingWithCopyWarning: \n", + "/home/jacob/Desktop/EngineersForExploration/Bioacoustics/Automated_Audio_Labelling_System_AID/microfaune_local_score.py:835: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", @@ -2343,7 +2489,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -2713,7 +2859,7 @@ "24 0 33.933061 29.000 4.500 1 0.7588 " ] }, - "execution_count": 26, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -2724,16 +2870,16 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "WARNING:tensorflow:11 out of the last 13 calls to .predict_function at 0x7fb3ac6afc10> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n", - "WARNING:tensorflow:10 out of the last 11 calls to .predict_function at 0x7fb3ac6afc10> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n", - "WARNING:tensorflow:8 out of the last 11 calls to .predict_function at 0x7fb3ac6afc10> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" + "WARNING:tensorflow:11 out of the last 13 calls to .predict_function at 0x7f4d25493940> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n", + "WARNING:tensorflow:10 out of the last 11 calls to .predict_function at 0x7f4d25493940> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n", + "WARNING:tensorflow:8 out of the last 11 calls to .predict_function at 0x7f4d25493940> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" ] } ], @@ -2743,7 +2889,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -2934,7 +3080,7 @@ "[168 rows x 8 columns]" ] }, - "execution_count": 28, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -2945,14 +3091,14 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "WARNING:tensorflow:8 out of the last 11 calls to .predict_function at 0x7fb3822cfaf0> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" + "WARNING:tensorflow:8 out of the last 11 calls to .predict_function at 0x7f4ce042f310> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.\n" ] }, { @@ -2974,10 +3120,218 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20190622_210000.WAV\n", + "20190623_222000.WAV\n", + "Division by zero setting precision, recall, and f1 to zero\n", + "BlackFacedAntbird1.wav\n", + "Division by zero setting precision, recall, and f1 to zero\n", + "HowlerMonkey1.WAV\n", + "Division by zero setting precision, recall, and f1 to zero\n", + "20190624_152000.WAV\n", + "Division by zero setting precision, recall, and f1 to zero\n", + "ScreamingPiha2.wav\n", + "Division by zero setting precision, recall, and f1 to zero\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
FOLDERIN FILETRUE POSITIVEFALSE NEGATIVEFALSE POSITIVEPRECISIONRECALLF1
0/home/jacob/Acoustic-Species-Identification/pa...20190622_210000.WAV14480.02040.20.037
1/home/jacob/Acoustic-Species-Identification/pa...20190623_222000.WAV01210.00000.00.000
2/home/jacob/Acoustic-Species-Identification/pa...BlackFacedAntbird1.wav04200.00000.00.000
3/home/jacob/Acoustic-Species-Identification/pa...HowlerMonkey1.WAV03460.00000.00.000
4/home/jacob/Acoustic-Species-Identification/pa...20190624_152000.WAV0780.00000.00.000
5/home/jacob/Acoustic-Species-Identification/pa...ScreamingPiha2.wav05240.00000.00.000
\n", + "
" + ], + "text/plain": [ + " FOLDER IN FILE \\\n", + "0 /home/jacob/Acoustic-Species-Identification/pa... 20190622_210000.WAV \n", + "1 /home/jacob/Acoustic-Species-Identification/pa... 20190623_222000.WAV \n", + "2 /home/jacob/Acoustic-Species-Identification/pa... BlackFacedAntbird1.wav \n", + "3 /home/jacob/Acoustic-Species-Identification/pa... HowlerMonkey1.WAV \n", + "4 /home/jacob/Acoustic-Species-Identification/pa... 20190624_152000.WAV \n", + "5 /home/jacob/Acoustic-Species-Identification/pa... ScreamingPiha2.wav \n", + "\n", + " TRUE POSITIVE FALSE NEGATIVE FALSE POSITIVE PRECISION RECALL F1 \n", + "0 1 4 48 0.0204 0.2 0.037 \n", + "1 0 1 21 0.0000 0.0 0.000 \n", + "2 0 4 20 0.0000 0.0 0.000 \n", + "3 0 3 46 0.0000 0.0 0.000 \n", + "4 0 7 8 0.0000 0.0 0.000 \n", + "5 0 5 24 0.0000 0.0 0.000 " + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stats_df2 = dataset_IoU_Statistics(new_automated_df,manual_df,threshold = 0.5)\n", + "stats_df2" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
TRUE POSITIVEFALSE NEGATIVEFALSE POSITIVEPRECISIONRECALLF1
01241670.0060.040.0104
\n", + "
" + ], + "text/plain": [ + " TRUE POSITIVE FALSE NEGATIVE FALSE POSITIVE PRECISION RECALL F1\n", + "0 1 24 167 0.006 0.04 0.0104" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "global_stats_df = global_IoU_Statistics(stats_df2)\n", + "global_stats_df" + ] } ], "metadata": { diff --git a/microfaune_local_score.py b/microfaune_local_score.py index 9310e23..7769dd8 100644 --- a/microfaune_local_score.py +++ b/microfaune_local_score.py @@ -12,6 +12,7 @@ import csv import argparse from scipy.io import wavfile +from scipy import stats import scipy.signal as scipy_signal import pandas as pd import math @@ -217,6 +218,26 @@ def calc_local_scores(bird_dir,weight_path=None, Normalized_Sample_Rate = 44100) annotations.reset_index(inplace = True, drop = True) return annotations +# Function that takes in a pandas dataframe of annotations and outputs a dataframe of the +# mean, median, mode, quartiles, and standard deviation of the annotation durations. +def annotation_duration_statistics(df): + # Reading in the Duration column of the passed in dataframe as a Python list + annotation_lengths = df["DURATION"].to_list() + # Converting the Python list to a numpy array + annotation_lengths = np.asarray(annotation_lengths) + entry = {'COUNT' : np.shape(annotation_lengths)[0], + 'MODE' : stats.mode(np.round(annotation_lengths,2))[0][0], + 'MEAN' : np.mean(annotation_lengths), + 'STANDARD DEVIATION' : np.std(annotation_lengths), + 'MIN': np.amin(annotation_lengths), + 'Q1': np.percentile(annotation_lengths,25), + 'MEDIAN' : np.median(annotation_lengths), + 'Q3' : np.percentile(annotation_lengths,75), + 'MAX' : np.amax(annotation_lengths)} + # returning the dictionary as a pandas dataframe + return pd.DataFrame.from_dict([entry]) + + def calc_local_scores_simpler(bird_dir,weight_path=None, Normalized_Sample_Rate = 44100): # init detector # Use Default Microfaune Detector