CoolFace
Modelpublic

nhull/random-forest-model

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
Model Card

Random Forest Sentiment Analysis Model

This model is a Random Forest 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.

Model Details

  • Model Type: Random Forest
  • Task: Sentiment Analysis
  • Input: A hotel review (text)
  • Output: Sentiment rating (1-5 stars)
  • Dataset Used: TripAdvisor sentiment dataset (balanced labels)

Intended Use

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.

How to Use the Model

  1. 1.Install the required dependencies:
bash
    pip install joblib
  1. 1.Download and load the model: You can download the model from Hugging Face and use it to predict sentiment.

Example code to download and use the model:

python
    from huggingface_hub import hf_hub_download
    import joblib

    # Download model from Hugging Face
    model_path = hf_hub_download(repo_id="your-username/random-forest-model", filename="random_forest_model.joblib")

    # Load the model
    model = joblib.load(model_path)

    # Predict sentiment of a review
    def predict_sentiment(review):
        return model.predict([review])[0]

    review = "This hotel was fantastic. The service was great and the room was clean."
    print(f"Predicted sentiment: {predict_sentiment(review)}")
  1. 1.The model will return a sentiment rating between 1 and 5 stars, where:
  2. 2.1: Very bad
  3. 3.2: Bad
  4. 4.3: Neutral
  5. 5.4: Good
  6. 6.5: Very good

Model Evaluation

  • Test Accuracy: 55.28% on the test set.
  • Classification Report (Test Set):
LabelPrecisionRecallF1-scoreSupport
1.00.620.780.691600
2.00.480.380.421600
3.00.490.400.441600
4.00.490.460.481600
5.00.630.740.681600
Accuracy--0.558000
Macro avg0.540.550.548000
Weighted avg0.540.550.548000

Cross-validation Scores:

MetricValue
Random Forest Cross-validation scores[0.54983553, 0.55164474, 0.55805921, 0.55657895, 0.54424342]
Random Forest Mean Cross-validation score0.5521

Limitations

  • The model performs well on extreme ratings (1 and 5 stars) but struggles with intermediate ratings (2, 3, and 4 stars).
  • The model was trained on the TripAdvisor dataset and may not generalize well to reviews from other sources or domains.
  • The model does not handle aspects like sarcasm or humor well, and shorter reviews may lead to less accurate predictions.