Skip to content

Commit

Permalink
Added README
Browse files Browse the repository at this point in the history
  • Loading branch information
monkin77 committed Jun 6, 2022
1 parent c36bd49 commit b6ff0cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Natural Language Processing with Amazon Reviews

## Setup & Installation

1. Install python3 and the necessary packages
2. To run `proProcessBagOfWords.ipynb`, you need to [download the spreadsheet files](https://www.kaggle.com/datasets/yacharki/amazon-reviews-for-sentianalysis-finegrained-csv) that exceed GitHub's limit.
3. There are some `test` and `train` spreadsheet files already generated if you want to skip step 2.
10 changes: 4 additions & 6 deletions amazonNLP.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,13 @@
" # Train with allWords\n",
" clf.fit(X_train, y_train, **arg)\n",
"\n",
" grid = HalvingGridSearchCV(clf, param_grid) # If we want Cross Validation: cv=pdfsplt\n",
" grid = HalvingGridSearchCV(clf, param_grid)\n",
"\n",
" grid.fit(X_paramTuning, y_paramTuning, **arg)\n",
"\n",
" print(\"Best grid params:\", grid.best_params_)\n",
"\n",
" return grid.predict(testAllWords)\n",
"\n",
"# MultinomialNB()"
" return grid.predict(testAllWords)\n"
]
},
{
Expand Down Expand Up @@ -351,7 +349,7 @@
" currData = data[index]\n",
" x, y, title = prepare_statistic(currData)\n",
" axis = axs[i, j]\n",
" axis.set_ylim(bottom=0.0, top=1.0) # Uncomment this to see yAxis from [0, 1]\n",
" axis.set_ylim(bottom=0.0, top=1.0)\n",
" axis.bar(x, y)\n",
" axis.set_title(title)\n",
" axis.grid(True)\n",
Expand Down Expand Up @@ -521,8 +519,8 @@
"begin = time.time()\n",
"prediction = predict(MultinomialNB(), sample_weight=1.0)\n",
"end = time.time()\n",
"# prediction = gridPredict(MultinomialNB(), {\"alpha\": [0.0001, 0.5, 1.0]}, sample_weight=1.0)\n",
"# prediction = fullPredict(MultinomialNB(), {\"alpha\": [0.0001, 0.5, 1.0]}, sample_weight=1.0)\n",
"\n",
"print(\"MultinomialNB Results:\")\n",
"accuracy = analyze(prediction, test, 'Multinomial Naive Bayes')\n",
"nb_metrics = (accuracy, end - begin)"
Expand Down

0 comments on commit b6ff0cd

Please sign in to comment.