nhull commited on
Commit
f4d75d0
·
verified ·
1 Parent(s): 1f34424

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +75 -1
README.md CHANGED
@@ -12,4 +12,78 @@ tags:
12
  - hotel-reviews
13
  - tripadvisor
14
  - nlp
15
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  - hotel-reviews
13
  - tripadvisor
14
  - nlp
15
+ ---
16
+
17
+ # Logistic Regression Sentiment Analysis Model
18
+
19
+ This model is a **Logistic Regression** classifier trained on the **TripAdvisor sentiment analysis dataset**. It predicts the sentiment of hotel reviews on a 1-5 star scale. The model takes text input (hotel reviews) and outputs a sentiment rating from 1 to 5 stars.
20
+
21
+ ## Model Details
22
+
23
+ - **Model Type**: Logistic Regression
24
+ - **Task**: Sentiment Analysis
25
+ - **Input**: A hotel review (text)
26
+ - **Output**: Sentiment rating (1-5 stars)
27
+ - **Dataset Used**: TripAdvisor sentiment dataset (balanced labels)
28
+
29
+ ## Intended Use
30
+
31
+ This model is designed to classify hotel reviews based on their sentiment. It assigns a star rating between 1 and 5 to a review, indicating the sentiment expressed in the review.
32
+
33
+ ## How to Use the Model
34
+
35
+ 1. **Install the required dependencies**:
36
+ ```bash
37
+ pip install joblib
38
+ ```
39
+
40
+ 2. **Download and load the model**:
41
+ You can download the model from Hugging Face and use it to predict sentiment.
42
+
43
+ Example code to download and use the model:
44
+ ```python
45
+ from huggingface_hub import hf_hub_download
46
+ import joblib
47
+
48
+ # Download model from Hugging Face
49
+ model_path = hf_hub_download(repo_id="your-username/logistic-regression-model", filename="logistic_regression_model.joblib")
50
+
51
+ # Load the model
52
+ model = joblib.load(model_path)
53
+
54
+ # Predict sentiment of a review
55
+ def predict_sentiment(review):
56
+ return model.predict([review])[0]
57
+
58
+ review = "This hotel was fantastic. The service was great and the room was clean."
59
+ print(f"Predicted sentiment: {predict_sentiment(review)}")
60
+ ```
61
+
62
+ 3. **The model will return a sentiment rating** between 1 and 5 stars, where:
63
+ - 1: Very bad
64
+ - 2: Bad
65
+ - 3: Neutral
66
+ - 4: Good
67
+ - 5: Very good
68
+
69
+ ## Model Evaluation
70
+
71
+ - **Test Accuracy**: 61.05% on the test set.
72
+
73
+ - **Classification Report** (Test Set):
74
+
75
+ | Label | Precision | Recall | F1-score | Support |
76
+ |-------|-----------|--------|----------|---------|
77
+ | 1.0 | 0.70 | 0.73 | 0.71 | 1600 |
78
+ | 2.0 | 0.52 | 0.50 | 0.51 | 1600 |
79
+ | 3.0 | 0.57 | 0.54 | 0.55 | 1600 |
80
+ | 4.0 | 0.55 | 0.54 | 0.55 | 1600 |
81
+ | 5.0 | 0.71 | 0.74 | 0.72 | 1600 |
82
+ | **Accuracy** | - | - | **0.61** | 8000 |
83
+ | **Macro avg** | 0.61 | 0.61 | 0.61 | 8000 |
84
+ | **Weighted avg** | 0.61 | 0.61 | 0.61 | 8000 |
85
+
86
+ - **Cross-validation Scores**:
87
+
88
+ * Logistic Regression Cross-validation scores: [0.61463816, 0.609375, 0.62072368, 0.59703947, 0.59835526]
89
+ * Logistic Regression Mean Cross-validation score: 0.6080