{"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_minor":4,"nbformat":4,"cells":[{"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 os\nimport json\nimport librosa","metadata":{"execution":{"iopub.status.busy":"2022-03-27T02:08:55.863441Z","iopub.execute_input":"2022-03-27T02:08:55.864083Z","iopub.status.idle":"2022-03-27T02:08:55.868624Z","shell.execute_reply.started":"2022-03-27T02:08:55.864045Z","shell.execute_reply":"2022-03-27T02:08:55.867657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Completely random for now.","metadata":{}},{"cell_type":"code","source":"with open('/kaggle/input/birdclef-2022/scored_birds.json') as bird_file:\n    birds = json.load(bird_file)","metadata":{"execution":{"iopub.status.busy":"2022-03-27T02:08:55.938692Z","iopub.execute_input":"2022-03-27T02:08:55.939765Z","iopub.status.idle":"2022-03-27T02:08:55.946524Z","shell.execute_reply.started":"2022-03-27T02:08:55.939715Z","shell.execute_reply":"2022-03-27T02:08:55.945640Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_directory = '/kaggle/input/birdclef-2022/test_soundscapes/'","metadata":{"execution":{"iopub.status.busy":"2022-03-27T02:08:56.008533Z","iopub.execute_input":"2022-03-27T02:08:56.008903Z","iopub.status.idle":"2022-03-27T02:08:56.012570Z","shell.execute_reply.started":"2022-03-27T02:08:56.008836Z","shell.execute_reply":"2022-03-27T02:08:56.011959Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_files = os.listdir(test_directory)","metadata":{"execution":{"iopub.status.busy":"2022-03-27T02:08:56.113424Z","iopub.execute_input":"2022-03-27T02:08:56.114500Z","iopub.status.idle":"2022-03-27T02:08:56.119822Z","shell.execute_reply.started":"2022-03-27T02:08:56.114441Z","shell.execute_reply":"2022-03-27T02:08:56.118727Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = []\nfor test_file_name in test_files:\n    ts, rate = librosa.load(test_directory + test_file_name)\n    for segment in range(0, len(ts), rate*5):\n        for bird in birds:\n            row_id = test_file_name[:-4] + '_' + bird + '_' + str(int((segment + (rate * 5)) / (rate)))\n            target = bool(np.random.randint(2))\n            predictions.append([row_id, target])","metadata":{"execution":{"iopub.status.busy":"2022-03-27T02:08:56.233151Z","iopub.execute_input":"2022-03-27T02:08:56.233549Z","iopub.status.idle":"2022-03-27T02:08:57.707544Z","shell.execute_reply.started":"2022-03-27T02:08:56.233517Z","shell.execute_reply":"2022-03-27T02:08:57.706729Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.DataFrame(predictions, columns=['row_id', 'target'])","metadata":{"execution":{"iopub.status.busy":"2022-03-27T02:08:57.709205Z","iopub.execute_input":"2022-03-27T02:08:57.709445Z","iopub.status.idle":"2022-03-27T02:08:57.715110Z","shell.execute_reply.started":"2022-03-27T02:08:57.709415Z","shell.execute_reply":"2022-03-27T02:08:57.714455Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-03-27T02:08:57.716183Z","iopub.execute_input":"2022-03-27T02:08:57.717735Z","iopub.status.idle":"2022-03-27T02:08:57.729486Z","shell.execute_reply.started":"2022-03-27T02:08:57.717695Z","shell.execute_reply":"2022-03-27T02:08:57.728335Z"},"trusted":true},"execution_count":null,"outputs":[]}]}