{"cells":[{"cell_type":"markdown","id":"38759022-e1b2-4912-b879-13f4f42b27d9","metadata":{},"outputs":[],"source":["<img src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DS0103EN-SkillsNetwork/labs/Module%202/images/IDSNlogo.png\" width=\"400\">\n","\n","# From Requirements to Collection\n","\n","\n","Estimated time needed: **15** minutes\n","    \n","\n","## Objectives\n","\n","After completing this lab you will be able to:\n","\n","* Understand Data Requirements\n","* Explore the stages in Data Collection\n"]},{"cell_type":"markdown","id":"281336e4-579a-4d45-84d8-463ff88c408d","metadata":{},"outputs":[],"source":["## Table of Contents\n","\n","<div class=\"alert alert-block alert-info\" style=\"margin-top: 20px\">\n","    \n","1. [Data Requirements](#0)<br>\n","2. [Data Collection](#2)<br>\n","</div>\n","<hr>\n"]},{"cell_type":"markdown","id":"145fe783-50d7-40e7-9b91-819f99d25ba4","metadata":{},"outputs":[],"source":["# Data Requirements <a id=\"0\"></a>\n"]},{"cell_type":"markdown","id":"0d2322fe-21b1-49db-aac0-34c325fc72dc","metadata":{},"outputs":[],"source":["<img src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DS0103EN-SkillsNetwork/labs/Module%202/images/lab2_fig1_flowchart_data_requirements.png\" width=\"500\">\n"]},{"cell_type":"markdown","id":"acfb15d5-949c-4314-a2a8-3c8cff7f65aa","metadata":{},"outputs":[],"source":["In the videos, we learned that the chosen analytic approach determines the data requirements. Specifically, the analytic methods to be used require certain data content, formats and representations, guided by domain knowledge.\n"]},{"cell_type":"markdown","id":"c1a16637-91f0-470e-96dc-f889b2f7fe6f","metadata":{},"outputs":[],"source":["Identifying the required data fulfills the data requirements stage of the data science methodology.\n","\n","-----------\n"]},{"cell_type":"markdown","id":"a76ffe4f-8685-40e2-a03e-ca10ed80fabe","metadata":{},"outputs":[],"source":["# Data Collection <a id=\"2\"></a>\n"]},{"cell_type":"markdown","id":"49efb703-4be1-45f7-b780-48276e4144cf","metadata":{},"outputs":[],"source":["<img src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DS0103EN-SkillsNetwork/labs/Module%202/images/lab2_fig2_flowchart_data_collection.png\" width=\"500\">\n"]},{"cell_type":"markdown","id":"2229d195-e89b-4198-a71d-cee015f7737f","metadata":{},"outputs":[],"source":["In the initial data collection stage, data scientists identify and gather the available data resources. These can be in the form of structured, unstructured, and even semi-structured data relevant to the problem domain.\n"]},{"cell_type":"markdown","id":"712286c2-dcdd-4be8-9c84-ac30d087d6b2","metadata":{},"outputs":[],"source":["#### Web Scraping of Online Food Recipes \n","\n","A researcher named Yong-Yeol Ahn scraped tens of thousands of food recipes (cuisines and ingredients) from three different websites, namely:\n"]},{"cell_type":"markdown","id":"49f29df4-b246-4942-aded-a534f60e9900","metadata":{},"outputs":[],"source":["<img src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DS0103EN-SkillsNetwork/labs/Module%202/images/lab2_fig3_allrecipes.png\" width=\"500\">\n","<div align=\"center\">\n","www.allrecipes.com\n","</div>\n","<br/><br/>\n","<img src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DS0103EN-SkillsNetwork/labs/Module%202/images/lab2_fig4_epicurious.png\" width=\"500\">\n","<div align=\"center\">\n","www.epicurious.com\n","</div>\n","<br/><br/>\n","<img src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DS0103EN-SkillsNetwork/labs/Module%202/images/lab2_fig5_menupan.png\" width=\"500\">\n","<div align=\"center\">\n","www.menupan.com\n","</div>\n","<br/><br/>\n"]},{"cell_type":"markdown","id":"db3d09e5-c190-4776-9cd8-1572861e4e21","metadata":{},"outputs":[],"source":["For more information on Yong-Yeol Ahn and his research, you can read his paper on [Flavor Network and the Principles of Food Pairing](http://yongyeol.com/papers/ahn-flavornet-2011.pdf?utm_medium=Exinfluencer&utm_source=Exinfluencer&utm_content=000026UJ&utm_term=10006555&utm_id=NA-SkillsNetwork-Channel-SkillsNetworkCoursesIBMDeveloperSkillsNetworkDS0103ENSkillsNetwork983-2023-01-01).\n"]},{"cell_type":"markdown","id":"e9398ca7-b1f8-498f-8132-e6ec84f860c3","metadata":{},"outputs":[],"source":["Luckily, we will not need to carry out any data collection as the data that we need to meet the goal defined in the business understanding stage is readily available.\n"]},{"cell_type":"markdown","id":"1163256e-8609-4781-af6b-ba5d8a2d753a","metadata":{},"outputs":[],"source":["#### We have already acquired the data and placed it on an IBM server. Let's download the data and take a look at it.\n"]},{"cell_type":"markdown","id":"a6e101a9-1fb0-437d-acc8-ffac8b152569","metadata":{},"outputs":[],"source":["<strong>Important note:</strong> Please note that you are not expected to know how to program in python. The following code is meant to illustrate the stage of data collection, so it is totally fine if you do not understand the individual lines of code. There will be a full course in this certificate on programming in python, <a href=\"http://cocl.us/PY0101EN_DS0103EN_LAB2_PYTHON_edX\">Python for Data Science</a>, which will teach you how to program in Python if you decide to complete this certificate.\n"]},{"cell_type":"markdown","id":"adadaab4-cbf0-4c0e-83df-ceb7cf35b1ae","metadata":{},"outputs":[],"source":["### Using this notebook:\n","\n","To run any of the following cells of code, you can type **Shift + Enter** to excute the code in a cell.\n"]},{"cell_type":"markdown","id":"955c840d-cfd1-4b9c-8f96-72b418a2adbd","metadata":{},"outputs":[],"source":["Get the version of Python installed.\n"]},{"cell_type":"code","id":"9543e413-1c71-4ad1-be77-56dfddf0ecd6","metadata":{},"outputs":[],"source":["# check Python version\n!python -V"]},{"cell_type":"markdown","id":"3594bdfd-012c-47a4-8f21-ff8290ec6415","metadata":{},"outputs":[],"source":["Read the data from the IBM server into a *pandas* dataframe.\n"]},{"cell_type":"code","id":"a853e141-a32e-4b41-8a04-0927b4bbe5c7","metadata":{},"outputs":[],"source":["import pandas as pd # download library to read data into dataframe\npd.set_option('display.max_columns', None)\n\nrecipes = pd.read_csv(\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DS0103EN-SkillsNetwork/labs/Module%202/recipes.csv\")\n\nprint(\"Data read into dataframe!\") # takes about 30 seconds"]},{"cell_type":"markdown","id":"c3df73ac-f6cc-46c8-aef2-da9d18dbfc6d","metadata":{},"outputs":[],"source":["Show the first few rows.\n"]},{"cell_type":"code","id":"a16281b0-a199-4d59-8323-0406a8bc82d3","metadata":{},"outputs":[],"source":["recipes.head()"]},{"cell_type":"markdown","id":"2d29aa3e-90ff-4d5c-b2e9-15086652657f","metadata":{},"outputs":[],"source":["Get the dimensions of the dataframe.\n"]},{"cell_type":"code","id":"fe8d9ce4-046d-4867-bae5-1e4b7e29be12","metadata":{},"outputs":[],"source":["recipes.shape"]},{"cell_type":"markdown","id":"1d7db50a-8189-4525-b480-3503abf10d34","metadata":{},"outputs":[],"source":["So our dataset consists of 57,691 recipes. Each row represents a recipe, and for each recipe, the corresponding cuisine is documented as well as whether 384 ingredients exist in the recipe or not beginning with almond and ending with zucchini.\n","\n","-----------\n"]},{"cell_type":"markdown","id":"c38ad3f4-ed2c-422f-a182-c6fb63d743a1","metadata":{},"outputs":[],"source":["Now that the data collection stage is complete, data scientists typically use descriptive statistics and visualization techniques to better understand the data and get acquainted with it. Data scientists, essentially, explore the data to:\n","\n","* understand its content,\n","* assess its quality,\n","* discover any interesting preliminary insights, and,\n","* determine whether additional data is necessary to fill any gaps in the data.\n"]},{"cell_type":"markdown","id":"b4723dd5-55cb-4fe6-aaf8-52a39ebc5edf","metadata":{},"outputs":[],"source":["### Thank you for completing this lab!\n","\n","## Author\n","\n","<a href=\"https://www.linkedin.com/in/aklson/?utm_medium=Exinfluencer&utm_source=Exinfluencer&utm_content=000026UJ&utm_term=10006555&utm_id=NA-SkillsNetwork-Channel-SkillsNetworkCoursesIBMDeveloperSkillsNetworkDS0103ENSkillsNetwork983-2023-01-01\">Alex Aklson</a>\n","\n","\n","\n","## Change Log\n","\n","\n","|  Date (YYYY-MM-DD) |  Version | Changed By  |  Change Description |\n","|---|---|---|---|\n","| 2021-04-06 | 2.1 | Malika | Updated lab link |\n","| 2020-09-25  | 2.0  | Lakshmi |  Fixed Typo errors |\n","| 2020-08-27  | 2.0  | Lavanya  |  Moved lab to course repo in GitLab |\n","\n","\n","\n","<hr>\n","\n","## <h3 align=\"center\"> © IBM Corporation 2020. All rights reserved. <h3/>\n"]}],"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.12.8"},"prev_pub_hash":"301702ee51de7cc71eca9c3a89a3b933349a27c45cf8470380007270e4d269f6"},"nbformat":4,"nbformat_minor":4}