{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Show Us The Data"},{"metadata":{},"cell_type":"markdown","source":"This competition challenges data scientists to show how publicly funded data are used to serve science and society. Evidence through data and science are critical if government is to address the many threats facing society, including; pandemics, climate change, Alzheimer’s disease, child hunger, increasing food production, maintaining biodiversity, and addressing many other challenges. Yet much of the information about data necessary to inform evidence and science is locked inside publications.\n\nCan natural language processing find the hidden-in-plain-sight data citations? Can machine learning find the link between the words used in research articles and the data referenced in the article?"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import seaborn as sns\nimport matplotlib.pyplot as plt \n%matplotlib inline\n\nfrom collections import Counter\nimport re\nfrom wordcloud import WordCloud, STOPWORDS\nfrom nltk.corpus import stopwords","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"file_train = '../input/coleridgeinitiative-show-us-the-data/train.csv'\n\ndf = pd.read_csv(file_train)\ndf.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"file_sub = '../input/coleridgeinitiative-show-us-the-data/sample_submission.csv'\nfs = pd.read_csv(file_sub)\nfs.head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Start with EDA to understand the data more"},{"metadata":{},"cell_type":"markdown","source":"## Exploring Information in Titles of Datasets"},{"metadata":{"trusted":true,"collapsed":true},"cell_type":"code","source":"df.info()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Information about the train dataset"},{"metadata":{"trusted":true},"cell_type":"code","source":"print('===========Train Dataset has the following=========== ')\nprint(f\"Unique Publication Titles: {df['pub_title'].nunique()}\")\nprint(f\"Unique Dataset Titles: {df['dataset_title'].nunique()}\")\nprint(f\"Unique Dataset Labels: {df['dataset_label'].nunique()}\")\nprint(f\"Unique Cleaned Labels: {df['cleaned_label'].nunique()}\")\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true},"cell_type":"code","source":"# Get titles with corresponding frequency in literature\ndf['dataset_title'].value_counts()\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Bar Plot showing the title with corresponding value counts\n\ndf['dataset_title'].value_counts().plot(kind='bar',figsize=(22, 8))\nplt.title('Frequency of Dataset Usage in Literature', fontsize=24)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"def clean_text(txt):\n    return re.sub('[^A-Za-z0-9]+', ' ', str(txt).lower()).strip()\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"title_cleaned = df['dataset_title'].apply(lambda x: clean_text(x))\ntitle_cleaned","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"words = title_cleaned.str.split().values.tolist()\ntitle_corpus = [word for i in words for word in i]\n\ntitle_counter = Counter(title_corpus)\ntitle_most = title_counter.most_common()\n\nstop = set(stopwords.words('english'))\n\ntitle_top_words, title_top_words_count = [], []\nfor word, count in title_most[:100]:\n    if word not in stop:\n        title_top_words.append(word)\n        title_top_words_count.append(count)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"len (title_top_words)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.set(rc={'figure.figsize':(20,16)}, font_scale=2)\nsns.color_palette(\"tab10\")\nplt.title('TOP-20 title words', color = 'black', size = 25)\nsns.barplot(y = title_top_words[:25], x = title_top_words_count[:25])\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Can Create labels for the field the data is related to?\n\n## Example [Disease, Alzehimer, Covid,...]--> Medical field"},{"metadata":{"trusted":true},"cell_type":"code","source":"","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}