Skip to main content

A Very Easy Recommendation Engine for Django

Project description

A Very Easy Recommendation Engine for Django

Installation

pip install very-easy-recommendation-engine-django

Configuration

Let's say you have a model for movies and ratings of movies like so:

"""
movies/models.py
"""

class Movie(models.Model):
    title = models.CharField()


class Rating(models.Model):
    created = models.DateTimeField(auto_now_add=True)
    value = models.IntegerField(min=1, max=5)
    movie = models.ForeignKey(Movie, on_delete=models.CASCADE)
    user = models.ForeignKey(User, on_delete=models.CASCADE)

We will build a recommendation engine to show movies a user might like based on their ratings.

"""
settings.py
"""

VERY_EASY_RECOMMENDATION_ENGINE = {
    "APPLICATION_ID": "{{ Your Application ID key here }}"
    "API_KEY": "{{ Your secret key here }}"
    "models": {
      "user_movie_recommendations": {
          "output_field": "books.Rating.value"
      }
    }
}
"""
urls.py
"""

urlpatterns = [
  ...,
  path("very-easy-ai", "very_easy_recommendation_engine.urls")
]

That's it! Our servers will start building your recommendation engine and provide an API endpoint for your application to pull recommendations

Getting Recommendations

Request:

from very_easy_recommendation_engine import VeryEasyRecommendationEngine

rec_engine = VeryEasyRecommendationEngine(model_name="user_movie_recommendations")

# Get recommendations for user number five
recommendations = rec_engine.get_recommendations_for_user(user_id=5)

print(recommendations, limit=15)

Output:

{
  "results": [
      {
        "objectId": "objectId1",
        "value": 4.89
        // ...
      },
      {
        "objectId": "objectId2",
        "value": 4.87
        // ...
      }
      //...
    ],
    "count": 15,
    "queryId": "43b15df305339e827f0ac0bdc5ebcaa7"
  ]
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

very_easy_recommendation_engine-0.0.1.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file very_easy_recommendation_engine-0.0.1.tar.gz.

File metadata

File hashes

Hashes for very_easy_recommendation_engine-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e9205c7e8481319b8bc54c5b17c986e7e78395ef73ed5db606a9958a1027ce75
MD5 8d66e74e8e4996d68d3bafcf1003f2d9
BLAKE2b-256 4842e7341df062afc2ab9762d86b4a08b79b86ac594a028774355d64488e1d33

See more details on using hashes here.

File details

Details for the file very_easy_recommendation_engine-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for very_easy_recommendation_engine-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 730a8e82a46b9617c830e93a35f2363244aceb1878e8094d12793013ae01bb52
MD5 5f116b3e7967e9b228c7ee7f5be3466b
BLAKE2b-256 ff816b74bcc4220b3578639b9593befc57f18b33fc2719244eb75a32076f837a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page