This is a .NET-based web API for predicting movie ratings using a machine learning model built with ML.NET.
- Predict Movie Ratings: Given a
userIdandmovieId, the API predicts the rating. - ML.NET Integration: Utilizes a trained ML.NET model for recommendations.
- RESTful API: Easily integrate with frontend applications or other services.
- .NET 6 or later
- ML.NET 1.8.0
- Postman or any API testing tool (optional)
git clone <repository-url>
cd WebApplicationdotnet add package Microsoft.ML
dotnet add package Microsoft.ML.Recommender
dotnet add package Microsoft.Extensions.MLdotnet build
dotnet runThe API will start and listen on http://localhost:5014.
Use Postman or curl to send a GET request:
curl -X GET "http://localhost:5014/api/recommendation" \
-H "Content-Type: application/json" \
-d '{"userId": 1, "movieId": 101}'- GET /api/recommendation
- Request Body:
{ "userId": 1, "movieId": 101 } - Response:
{ "rating": 4.5 }
- Request Body:
- 400 Bad Request: Missing or invalid input data.
- 500 Internal Server Error: Model loading issues or internal exceptions.
- Ensure all required NuGet packages are installed.
- If encountering
FileNotFoundExceptionforMicrosoft.ML.Recommender, ensure it's properly referenced in the.csprojfile. - If the API throws a
BadHttpRequestException, ensure that you're providing a proper JSON body in POST requests.
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes.
- Push to your fork and submit a pull request.