{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import matplotlib.pyplot as plt\nfrom PIL import Image\nimport seaborn as sns\nimport pandas as pd\nimport numpy as np\nimport math\nimport sklearn\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import mean_squared_error,r2_score,mean_absolute_error\nimport matplotlib.pyplot as plt\nimport seaborn as sb\nfrom sklearn import preprocessing\nfrom sklearn.feature_extraction.text import CountVectorizer\nimport time\nimport warnings \nwarnings.filterwarnings('ignore')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# load metadata\nt1 = time.time()\ntopics = pd.read_csv('../input/trec-covid-information-retrieval/topics-rnd3.csv')\nqrels = pd.read_csv('../input/trec-covid-information-retrieval/qrels.csv')\ndocids = pd.read_csv('../input/trec-covid-information-retrieval/docids-rnd3.txt')\n\nt2 = time.time()\nprint('Elapsed time:', t2-t1)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"topics.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = plt.figure(figsize=(16,8))\nax = fig.add_subplot(111)\ntopics.groupby('query').mean().sort_values(by='topic-id', ascending=False)['topic-id'].plot(kind='bar', color='r',width=0.3,title='topic-id : query', fontsize=8)\nplt.xticks(rotation = 90)\nplt.ylabel('query')\nax.title.set_fontsize(30)\nax.xaxis.label.set_fontsize(10)\nax.yaxis.label.set_fontsize(10)\nprint(topics.groupby('query').mean().sort_values(by='topic-id', ascending=False)['topic-id'][[1,2]])\nprint(topics.groupby('query').mean().sort_values(by='topic-id', ascending=False)['topic-id'][[4,5,6]])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"topics.question.value_counts()[0:50].plot(kind='bar')\nplt.grid()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"topics.narrative.value_counts()[0:100].plot(kind='bar')\nplt.grid()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"qrels.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"docids.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import re\ntext=open(\"../input/trec-covid-information-retrieval/docids-rnd3.txt\", encoding='ISO-8859-1')\ntext=text.read()\nprint(text)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = plt.figure(figsize=(16,8))\nax = fig.add_subplot(111)\nqrels.groupby('cord-id').mean().sort_values(by='topic-id', ascending=False)['topic-id'].plot(kind='bar', color='r',width=0.3,title='topic-id : cord-id', fontsize=8)\nplt.xticks(rotation = 90)\nplt.ylabel('cord-id')\nax.title.set_fontsize(30)\nax.xaxis.label.set_fontsize(10)\nax.yaxis.label.set_fontsize(10)\nprint(qrels.groupby('cord-id').mean().sort_values(by='topic-id', ascending=False)['topic-id'][[1,2]])\nprint(qrels.groupby('cord-id').mean().sort_values(by='topic-id', ascending=False)['topic-id'][[4,5,6]])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"qrels_sub = qrels[['topic-id','cord-id']]\nqrels_sub.head(100)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#Create a  DataFrame\nsubmission = pd.DataFrame({'topic-id':qrels_sub['topic-id'],'cord-id':qrels_sub['cord-id']})\n                        \n\n#Visualize the first 10 rows\nsubmission.head(10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#Convert DataFrame to a csv file that can be uploaded\n#This is saved in the same directory as your notebook\nfilename = 'submission.csv'\n\nsubmission.to_csv(filename,index=False)\n\nprint('Saved file: ' + filename)","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}