{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Take a first look on the training data tables"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# packages\nimport numpy as np\nimport pandas as pd\n\nfrom pylab import rcParams\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nfrom statsmodels.graphics.mosaicplot import mosaic\n\nimport os","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# file overview\n!ls \"/kaggle/input/rfcx-species-audio-detection\"","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"# import files\ndf_TP = pd.read_csv('../input/rfcx-species-audio-detection/train_tp.csv')\ndf_FP = pd.read_csv('../input/rfcx-species-audio-detection/train_fp.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_TP.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_FP.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"features_numeric = ['t_min','t_max','f_min','f_max']","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# True Positive Training File"},{"metadata":{"trusted":true},"cell_type":"code","source":"df_TP.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_TP.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_TP.species_id.value_counts().plot(kind='bar')\nplt.title('Species ID [TP]')\nplt.grid()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_TP.songtype_id.value_counts().plot(kind='bar')\nplt.title('Songtype ID [TP]')\nplt.grid()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.pairplot(df_TP[features_numeric])\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# False Positive Training File"},{"metadata":{"trusted":true},"cell_type":"code","source":"df_FP.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_FP.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_FP.species_id.value_counts().plot(kind='bar')\nplt.title('Species ID [FP]')\nplt.grid()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_FP.songtype_id.value_counts().plot(kind='bar')\nplt.title('Songtype ID [FP]')\nplt.grid()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.pairplot(df_FP[features_numeric])\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Combine to one table"},{"metadata":{"trusted":true},"cell_type":"code","source":"df_TP['label'] = 'TP'\ndf_FP['label'] = 'FP'\ndf = pd.concat([df_TP, df_FP], ignore_index=True)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Compare time"},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.violinplot(data=df, x='label', y='t_min')\nplt.title('Compare t_min')\nplt.grid()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.violinplot(data=df, x='label', y='t_max')\nplt.title('Compare t_max')\nplt.grid()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Compare frequency"},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.violinplot(data=df, x='label', y='f_min')\nplt.title('Compare f_min')\nplt.grid()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.violinplot(data=df, x='label', y='f_max')\nplt.title('Compare f_max')\nplt.grid()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## TP/FP by Species"},{"metadata":{"trusted":true},"cell_type":"code","source":"pd.crosstab(df.species_id, df.label)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# normalized\npd.crosstab(df.species_id, df.label, normalize=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# graphical view\nrcParams['figure.figsize'] = 10, 4\nmosaic(df, ['species_id', 'label'], title='TP/FP vs Species')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## TP/FP by Songtype"},{"metadata":{"trusted":true},"cell_type":"code","source":"pd.crosstab(df.songtype_id, df.label)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# normalized\npd.crosstab(df.songtype_id, df.label, normalize=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# graphical view\nrcParams['figure.figsize'] = 10, 4\nmosaic(df, ['songtype_id', 'label'], title='TP/FP vs Songtype')\nplt.show()","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}