{"cells":[{"metadata":{"_uuid":"56192a4d54d41187738d399c1c6a8fc474c3f4ca"},"cell_type":"markdown","source":"Hi there,\n\nIs it ok that the same measurement have different target labels between signals?\nAccording to data description it should be the same (or not really?) . There are 38 cases of measurements with not consistent labels between signals.\n\nQuick and dirty code to show the problem below:"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n%matplotlib inline\nimport os\nprint(os.listdir(\"../input\"))\n","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"df = pd.read_csv('../input/metadata_train.csv')\ndf.info()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6ab018ed19ded1d01e7636aaf6d6ad6b48821f32"},"cell_type":"code","source":"df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4015e93e7bf52ba0be08a1cbbdb8c818a97c7cb6"},"cell_type":"code","source":"#let's check if targets are consistent within the same measurement id\ntargets = df.groupby('id_measurement')[['target','id_measurement']].agg('mean')\ntargets.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"626be03d822f0695328329d6059cfd8cbd1f11aa"},"cell_type":"code","source":"sns.countplot(x='target',data=targets)\n# it should be only \"1\" and \"0\" but we have cases where target is not consitent ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"ef49a1da860b4e6e19a4e28f9ed7f66387f72877"},"cell_type":"code","source":"mislabeled = targets.loc[(targets.target <1 ) & (targets.target > 0.3) ,'id_measurement']\nprint(str(mislabeled.shape[0]) + ' measurments most likely mislabeled' )\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a2a9be9bd5885709147c3b0b51093e77c7172d7b"},"cell_type":"code","source":"# qc it all","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"bb93a20d3bb7e8314807c6ee0b2f371088af5d7d"},"cell_type":"code","source":"\ndf.loc[df.id_measurement.isin(mislabeled) ,:]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1de31b2bf4d206d8c7dd3789ed034ba27dcf3b76"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}