Coder Social home page Coder Social logo

machine-learning's Introduction

Machine Learning - README.md

This repository contains a Machine Learning FastAPI project that implements sentiment analysis and rating prediction based on user input. The project provides an API with two endpoints: /predict_review for sentiment analysis and /new_ratings for predicting new ratings based on sentiment analysis results.

Model Documentation ๐Ÿ“„

Tensorflow model with NNLM-ID-128 is a tensorflow model that has been built by leveraging pre-trained word embeddings from the NNLM-ID-128 model. This approach allows the model to benefit from the knowledge and representations learned from a large corpus of text data. The additional layers and pruning techniques have been applied to further refine and optimize the model's performance. The output layer uses softmax activation to produce probability distributions over the target classes. The model has been trained using the Adam optimizer.

Training Validation Accuracy and Loss ๐ŸŽฏ

The training and validation accuracy and loss metrics provide insights into the performance of the model during the training process.

Test Accuracy ๐ŸŽฏ

The test accuracy reflects the performance of the model on an independent test dataset. This dataset is kept separate from both the training and validation datasets and serves as a final evaluation of the model's performance. The test accuracy provides an unbiased estimate of how well the model can perform on new, unseen data.

Confusion Matrix ๐Ÿค”

The confusion matrix is a visualization that shows the performance of a classification model across different classes or categories. It provides insights into the model's ability to correctly predict each class and identify potential areas of confusion. The matrix displays the true positive (TP), true negative (TN), false positive (FP), and false negative (FN) values for each class.

Prerequisites๐Ÿ“

Before running the project, make sure you have the following:

  • Python 3.x installed ๐Ÿ
  • Required dependencies installed. You can install them by running the following command:
    pip install -r requirements.txt
    
  • nlp_model.h5 file or download via this link

Usage โš™๏ธ

To start the server and use the API, follow these steps:

  1. Ensure all the prerequisites are met.โœ…
  2. Open a terminal or command prompt in the project directory.
  3. Run the following command to start the server:
    python main.py
    
    The server will start running at http://localhost:8080.

API Endpoints ๐Ÿ”—

Health Check Endpoint ๐Ÿš‘

  • Endpoint: /
  • Method: GET
  • Description: A test endpoint to check if the server is running.
  • Response: Returns a simple "Hello world from ML endpoint!" message.

Sentiment Analysis Endpoint ๐Ÿ”ฎ

  • Endpoint: /predict_review
  • Method: POST
  • Description: Predicts sentiment analysis based on the given text.
  • Request Body:
    • text (str): The text to analyze.
  • Response: Returns the predicted sentiment as a string. Possible values are "Positive", "Neutral", or "Negative". If an error occurs during prediction, it returns an "Internal Server Error" message.

Rating Prediction Endpoint โœจ

  • Endpoint: /new_ratings
  • Method: POST
  • Description: Predicts new ratings for a user based on a list of user ratings and a sentiment analysis result.
  • Request Body:
    • predicted (str): The sentiment analysis result (e.g., "Positive", "Neutral", "Negative").
    • user_rating (list): A list of user ratings.
  • Response:
    • total_rating (float): The updated overall rating.
    • new_ratings (list): The list of user ratings with the new rating appended.
  • Response Model: ResponseRating
  • Response Model Fields:
    • total_rating (float): The updated overall rating.
    • new_ratings (list): The list of user ratings with the new rating appended.

Additional Notes ๐Ÿ“œ

  • If this is your first time running the project, make sure to install the required dependencies by running pip install -r requirements.txt.
  • You can access the API documentation easily by visiting http://localhost:8080/docs in your browser after starting the server.
  • The model used for sentiment analysis can be either an h5 model (nlp_model.h5) or a saved model (my_model_folder). Make sure to uncomment the appropriate line in main.py based on the model type you are using.

Contributing โœ๏ธ

Contributions are welcome! If you find any issues or want to add new features, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Author ๐Ÿ‘ค

machine-learning's People

Contributors

dapthehuman avatar muhammadalifalfarizi avatar siburianbasrunki avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.