File size: 9,589 Bytes
baa2f1c
1
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyMjOP9eeSmr0ii5DDNSNECG"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","source":["## Set up"],"metadata":{"id":"03_zGVdmtiwd"}},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"_ntkWenjsmjo","outputId":"70de83e7-a546-4966-b0df-959c58ec4370"},"outputs":[{"output_type":"stream","name":"stdout","text":["Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n","/content/drive/MyDrive/STA663\n","Updated git hooks.\n","Git LFS initialized.\n","\n","    _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|\n","    _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|\n","    _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|\n","    _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|\n","    _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|\n","\n","    A token is already saved on your machine. Run `huggingface-cli whoami` to get more information or `huggingface-cli logout` if you want to log out.\n","    Setting a new token will erase the existing one.\n","    To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .\n","Token: "]}],"source":["# Install the huggingface datasets library\n","!pip install datasets -q\n","\n","# Change to your work directory\n","from google.colab import drive\n","drive.mount('/content/drive')\n","%cd /content/drive/MyDrive/STA663\n","\n","# These are git commands, we will cover git more extensively in another class\n","!git config --global user.name \"Johnnyeee\"\n","!git config --global user.email \"yy413@duke.edu\"\n","!git config --global credential.helper store\n","!git lfs install\n","\n","# Log into huggingface\n","!huggingface-cli login\n","!huggingface-cli repo create Yelpdata_663 --type dataset\n","!git clone https://huggingface.co/datasets/Johnnyeee/Yelpdata_663\n","%cd Yelpdata_663"]},{"cell_type":"code","source":["# @title Save changes\n","\n","# You'll learn what this does in the future if you are\n","# not familiar with git\n","!git add -A\n","!git commit -m \"My commit\"\n","!git push"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"qqqPfv96su_F","executionInfo":{"status":"ok","timestamp":1710374207512,"user_tz":420,"elapsed":9324,"user":{"displayName":"Johnny Ye","userId":"16268450102215689935"}},"outputId":"360e6849-dce7-4c97-a543-64920d1b23b1"},"execution_count":4,"outputs":[{"output_type":"stream","name":"stdout","text":["fatal: cannot exec '.git/hooks/post-commit': Permission denied\n","[main 1baf50d] My commit\n"," 2 files changed, 1 insertion(+), 1 deletion(-)\n"," rewrite 663_project1_check.ipynb (62%)\n"," rename Yelpdata_663/Yelpdata_663.py => Yelpdata_663.py (100%)\n","fatal: cannot exec '.git/hooks/pre-push': Permission denied\n","^C\n"]}]},{"cell_type":"markdown","source":["## Test if works"],"metadata":{"id":"WWnP1bZvtpJF"}},{"cell_type":"code","source":["# @title Test if your dataset works!\n","\n","!pip install datasets\n","\n","from datasets import load_dataset"],"metadata":{"id":"KohLXmZUtmcu"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["dataset = load_dataset(\"Johnnyeee/Yelpdata_663\", trust_remote_code=True)"],"metadata":{"id":"Fptgu8xwDIqW"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["next(iter((dataset['train'])))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"DVup69Ee7Sfo","executionInfo":{"status":"ok","timestamp":1708376478907,"user_tz":300,"elapsed":186,"user":{"displayName":"Johnny Ye","userId":"16268450102215689935"}},"outputId":"d90e0fab-84b1-4666-c401-8edc333c0727"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["{'business_id': 'YMOCOlONOae4zaiKImTnTQ',\n"," 'name': 'Reef Sushi & Sake',\n"," 'address': '50 N Sierra St, Ste 106',\n"," 'city': 'Reno',\n"," 'state': 'NV',\n"," 'postal_code': '89501',\n"," 'latitude': 39.52512741088867,\n"," 'longitude': -119.81383514404297,\n"," 'stars_x': 3.0,\n"," 'review_count': 743.0,\n"," 'is_open': 0.0,\n"," 'categories': 'Restaurants, Sushi Bars, Asian Fusion, Japanese',\n"," 'hours': \"{'Monday': '11:0-22:0', 'Tuesday': '11:0-22:0', 'Wednesday': '11:0-22:0', 'Thursday': '11:0-22:0', 'Friday': '11:0-22:0', 'Saturday': '11:0-22:0', 'Sunday': '11:0-22:0'}\",\n"," 'review_id': 'FmoRIwlNwx91QHLhplZOaA',\n"," 'user_id': 'rwu2uCpSf57BvNi3B42F4A',\n"," 'stars_y': 4.0,\n"," 'useful': 0.0,\n"," 'funny': 0.0,\n"," 'cool': 0.0,\n"," 'text': \"First time here.  Place looked clean and trendy. This place is very reasonbly price. Customers have the option to either order al la cart or all you can eat.  We (2 adults/4 kids)  came in on a Friday afternoon about 200pm,  we ordered the all you eat for the adults and kids meal for my kids.  Everything we ordered was very tasty.  The servers were very helpful.  My only complain is that the appetizers /sushi we ordered took quite some time to get to our table and some of the things we order didn't come at all.  I would also suggest that the wait staff tell you what it is that they are bringing since the menu does not have pictures of the sushi that is offered. \\n\\nOur lunch was about 2 hours long due to the long waits for our sushi.  I would definitely recommend this place to friends and fam.  Hopefully next time we come back service is a little faster.\",\n"," 'date': '2015-03-21 09:09:06',\n"," 'attributes': '{\\'Alcohol\\': \"u\\'full_bar\\'\", \\'RestaurantsDelivery\\': \\'False\\', \\'BusinessAcceptsCreditCards\\': \\'True\\', \\'HasTV\\': \\'True\\', \\'RestaurantsGoodForGroups\\': \\'True\\', \\'RestaurantsAttire\\': \"u\\'casual\\'\", \\'WiFi\\': \"\\'free\\'\", \\'OutdoorSeating\\': \\'True\\', \\'Caters\\': \\'True\\', \\'BusinessParking\\': \"{\\'garage\\': False, \\'street\\': True, \\'validated\\': False, \\'lot\\': False, \\'valet\\': False}\", \\'RestaurantsPriceRange2\\': \\'2\\', \\'BikeParking\\': \\'True\\', \\'GoodForKids\\': \\'True\\', \\'RestaurantsReservations\\': \\'True\\', \\'HappyHour\\': \\'True\\', \\'Ambience\\': \"{\\'touristy\\': False, \\'hipster\\': False, \\'romantic\\': False, \\'divey\\': False, \\'intimate\\': False, \\'trendy\\': True, \\'upscale\\': False, \\'classy\\': False, \\'casual\\': True}\", \\'GoodForMeal\\': \"{\\'dessert\\': False, \\'latenight\\': False, \\'lunch\\': True, \\'dinner\\': True, \\'brunch\\': False, \\'breakfast\\': False}\", \\'RestaurantsTakeOut\\': \\'True\\', \\'NoiseLevel\\': \"u\\'average\\'\"}'}"]},"metadata":{},"execution_count":28}]},{"cell_type":"code","source":["next(iter((dataset['test'])))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"Ups2RaiB76iL","executionInfo":{"status":"ok","timestamp":1708376481764,"user_tz":300,"elapsed":186,"user":{"displayName":"Johnny Ye","userId":"16268450102215689935"}},"outputId":"662faba2-f653-4b58-ca20-1c567c7e2188"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["{'business_id': 'mabS8Eq8CLjMZdLl3V7GWA',\n"," 'name': \"Guido's Original New York Style Pizza Downtown\",\n"," 'address': '235 N 5th St',\n"," 'city': 'Boise',\n"," 'state': 'ID',\n"," 'postal_code': '83702',\n"," 'latitude': 43.61501693725586,\n"," 'longitude': -116.19904327392578,\n"," 'stars_x': 4.5,\n"," 'review_count': 270.0,\n"," 'is_open': 1.0,\n"," 'categories': 'Italian, Salad, Pizza, Restaurants',\n"," 'hours': \"{'Monday': '0:0-0:0', 'Tuesday': '11:0-21:0', 'Wednesday': '11:0-21:0', 'Thursday': '11:0-21:0', 'Friday': '11:0-22:0', 'Saturday': '11:0-22:0', 'Sunday': '11:0-21:0'}\",\n"," 'review_id': 'xCG3Mgp_stuKQqgcdoWtFw',\n"," 'user_id': 'ekDxCpf9ZYTqtbr2XHyDEQ',\n"," 'stars_y': 5.0,\n"," 'useful': 0.0,\n"," 'funny': 0.0,\n"," 'cool': 0.0,\n"," 'text': 'Pretty darn good pizzas, definitely recommend over the chain stores. The white pizza is especially tasty.',\n"," 'date': '2015-01-15 18:15:22',\n"," 'attributes': '{\\'BikeParking\\': \\'True\\', \\'GoodForKids\\': \\'True\\', \\'Alcohol\\': \"u\\'beer_and_wine\\'\", \\'BusinessParking\\': \"{\\'garage\\': False, \\'street\\': True, \\'validated\\': False, \\'lot\\': False, \\'valet\\': False}\", \\'RestaurantsPriceRange2\\': \\'1\\', \\'RestaurantsReservations\\': \\'False\\', \\'HasTV\\': \\'False\\', \\'NoiseLevel\\': \"u\\'average\\'\", \\'RestaurantsGoodForGroups\\': \\'True\\', \\'WiFi\\': \"u\\'no\\'\", \\'BusinessAcceptsCreditCards\\': \\'True\\', \\'RestaurantsAttire\\': \"\\'casual\\'\", \\'OutdoorSeating\\': \\'True\\', \\'RestaurantsDelivery\\': \\'True\\', \\'Caters\\': \\'False\\', \\'RestaurantsTakeOut\\': \\'True\\', \\'RestaurantsTableService\\': \\'False\\', \\'GoodForMeal\\': \"{\\'dessert\\': False, \\'latenight\\': False, \\'lunch\\': True, \\'dinner\\': True, \\'brunch\\': False, \\'breakfast\\': False}\", \\'Ambience\\': \"{\\'touristy\\': False, \\'hipster\\': None, \\'romantic\\': False, \\'divey\\': None, \\'intimate\\': False, \\'trendy\\': False, \\'upscale\\': False, \\'classy\\': False, \\'casual\\': True}\", \\'WheelchairAccessible\\': \\'True\\'}'}"]},"metadata":{},"execution_count":29}]}]}