{"id":20009924,"url":"https://github.com/i008/nyyelp","last_synced_at":"2025-07-17T02:15:50.294Z","repository":{"id":138782179,"uuid":"82735573","full_name":"i008/nyyelp","owner":"i008","description":"predicting yelp review rating using recurrent neural networks","archived":false,"fork":false,"pushed_at":"2017-02-26T11:58:24.000Z","size":19819,"stargazers_count":22,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-10T14:49:51.923Z","etag":null,"topics":["deep-learning","nlp","python","recurrent-neural-networks","yelp-dataset"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/i008.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-21T22:54:55.000Z","updated_at":"2022-08-15T14:03:26.000Z","dependencies_parsed_at":"2024-04-04T02:15:08.465Z","dependency_job_id":null,"html_url":"https://github.com/i008/nyyelp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/i008/nyyelp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i008%2Fnyyelp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i008%2Fnyyelp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i008%2Fnyyelp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i008%2Fnyyelp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/i008","download_url":"https://codeload.github.com/i008/nyyelp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i008%2Fnyyelp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261088350,"owners_count":23107681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","nlp","python","recurrent-neural-networks","yelp-dataset"],"created_at":"2024-11-13T07:17:31.077Z","updated_at":"2025-06-21T08:05:42.872Z","avatar_url":"https://github.com/i008.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Project objective:\nPredict review rating (how many stars the reviewer gave to given POI) given the textual-content of the review using pretrained **GLOVE** word embeddings and a 2 layers deep **GRU(LSTM)** recurrent neural network. Visualize clusters on a 2D space using PCA and t-SNE.\n\n\n#### simple yelp-dataset exploration\nyelp data: https://www.yelp.de/dataset_challenge  \nnotebook used to load and explore basic properties of this dataset can be found here:  \nhttps://github.com/i008/nyyelp/blob/master/exploration.ipynb\n\n#### NLP project \nThe notebook for the NLP part of this project can be found here:  \nhttps://github.com/i008/nyyelp/blob/master/nlp.ipynb\n\n\n#### Steps(rough plan):\n\n1) Process .text data from yelp review-documents\n- filter to leave english-only reviews\n- balance the dataset (use similar amount of data for each star rating (1,2,3,4,5*)\n- balance the dataset by review length, so the length distribution of reviews for each rating-class is atleast similar (bucketing might be a good idea)\n\n2) Process text for deep-learning\n- bring  GLOVE embeddings to a reasonable form\n- Tokenize each review \n- transform reviews into tokenized sequences\n- Pad sequences to a fixed length\n- Prepare the embedding weight-matrix to be used in the Embedding layer (we will not train this layer)\n- split into test and train\n\n\n3) Deep learning\n- loss function, regression(rmse) and/or classification(logloss)\n- prepare architecture (2 LSTM/GRU layers -\u003e Dense)\n- train, wish for the best\n\n4) Post learning\n- extract features from last LSTM layer\n- casting to 2D space using t-SNE\n\n5) Remarks\n- we have to limit the amount of data, bc of memory issues possible solution is to save the sequences into HDF and flowing from disk during training\n\n# Summary\n\n### text Data:  \n- For performance and memory reasons the final model was trained on a balanced and downsampled (by a factor of 10) subset of the reviews leaving us around 150,000 reviews (in total)\n- Review data was tokenized (20,000 words)\n- Max sequence length was set to 1000.\n- Embedding dimensions were set to 100 (GLOVE-100d representation was used) wich means every words is a vector with shape (100,)\n\n\n### Deep Learning Model  \n\u003cimg src=\"ims/model.png\" width=\"800\"\u003e\n\n- The Embedding layer used GLOVE (http://nlp.stanford.edu/projects/glove/) weights. Training of this layer was disabled\n- The objective function was logloss wich means that it was a classification task , altough regression would also  be a valid option\n- After the 3rd-4th epoch we can observe that the model starts to overfit\n\n### Results \n \nfig1. confusion matrix :    \n\u003cimg src=\"ims/cat_confusion_matrix.png\" width=\"500\"\u003e\n\nfig2. classification report:   \n\u003cimg src=\"ims/classification_report.png\" width=\"500\"\u003e\n\nfig3. Learning process:  \n\u003cimg src=\"ims/cat_training.png\" width=\"500\"\u003e\n\nAs we can see on the images above the model managed to learn (something) and achieved decent accuracy(~0.62).\n   \nKey takeways: \n - Extreme(1,5) reviews are easier to classify and understand, people write them in a specific way.\n - As we can see on fig1. The model makes mistakes almost only \"by 1-star\" this is a very good sign and leads to the conclusion that the \"grduation\" of the data was learned to some degree\n \n\n### t-SNE and PCA on GRU features\n\nt-SNE and PCA are dimmensionality reduction techniques, used on the features from last GRU layer they can give us an \"2D\"\nidea of the problem we are tackling.\n\nfig4. t-SNE  \n\u003cimg src=\"ims/TSN-e-gru.png\" width=\"750\"\u003e\n\n\nfig5. PCA  \n\u003cimg src=\"ims/pca-gru.png\" width=\"750\"\u003e\n\n\n### Learning Performance\n- One epoch (~150,000 reviews) with a batch size of 128 reviews took around 15mins to train on a GTX1070.\n\n\n### Docker app (try it yourself)\n\n```bash\ndocker run i008/nyyelp:latest python predict.py --review \"this place really sucks, food is terrible\"\n```\n\n\u003enumber of stars: 1\n\n```bash\ndocker run i008/nyyelp:latest python predict.py --review \"i have mixed feeling about this place, on one hand its good on the other not really\"\n```\n\n\u003enumber of stars: 3\n\n\n\n### TODO, Ideas\n\n- Treat this problem as regression and see what happens\n- Cluster GRU features using DBSCAN or similar methods, might give interesting results.\n- Use more data to train the models.\n- Balance the dataset considering the length of the review. \n- Interactive plot for t-SNE (click on a data point should show the review plotly?) \n\n\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi008%2Fnyyelp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fi008%2Fnyyelp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi008%2Fnyyelp/lists"}