This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<NumericInput | |
value={4} | |
onChange={value =>{ | |
let { quantityInput } = this.state; | |
quantityInput[index] = { | |
quantity: value, | |
element_id: item.id | |
}; | |
this.setState({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list of recommended books | |
bookISBN | |
bookTitle | |
bookGenre | |
bookDescription | |
bookAvgRating | |
bookPublisedDate | |
bookImg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def similar_recommendation(model, interaction_matrix, user_id, user_dikt, | |
item_dikt,threshold = 0,number_rec_items = 15): | |
#Function to produce user recommendations | |
n_users, n_items = interaction_matrix.shape | |
user_x = user_dikt[user_id] | |
scores = pd.Series(model.predict(user_x,np.arange(n_items))) | |
scores.index = interaction_matrix.columns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
details.html | |
{% extends "example/base.html" %} | |
{% load static %} | |
{% block body %} | |
<div class="container"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user_id = request.user.id + 278858 | |
book_id = isbn | |
new_rating = rating | |
x=mycol.find({"user_id":user_id,"activity.book_id":book_id},{"activity.$.activity":1,"_id":0}) | |
if x.count()==0: | |
y=mycol.find({"user_id":user_id},{"activity.$.activity":1,"_id":0}) | |
if(y.count()==0): | |
mycol.insert({"user_id":user_id,"isFifteen":0,"activity":[{"book_id":book_id,"activity":{"rating":new_rating,"net_rating":new_rating,"date_modified":datetime.datetime.now()}}]}) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get isFifteen (True or False) | |
x=mycol.find({"user_id":123,"isFifteen":1}) | |
isFifteen=x.count() | |
if isFifteen == True: | |
send 15 books recommendation | |
You may have to edit the query a bit as if it is being used for try now. | |
else: | |
send random books |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x=mycol.aggregate([{"$match":{"average_rating":{"$gt":4}}},{"$sort":{"average_rating":-1}},{"$limit":50},{"$sample":{"size":15}}]) | |
top_rated_books=list(x) | |
top_rated =mycol.aggregate([{"$match":{"ISBN":{"$in":top_rated_books}}}, | |
{"$project":{'_id':0, 'ISBN':'$ISBN', 'genres': '$genres', 'bookTitle': '$Book-Title', 'bookAuthor': '$Book-Author', 'publicationYear': '$Year-Of-Publication', 'publisher': '$Publisher', 'imageURL': '$Image-URL', 'averageRating': '$average_rating', 'description': '$description', 'publicationYear':'$publication_year'} }]) | |
print(top_rated) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
'_id': ObjectId('5d0afbe54e32454bf7bdc184'), | |
'genres': "{'young-adult': 1}", | |
'ISBN': '057004460X', | |
'Book-Title': "Women Through the Bible: Devotions for Women's Groups", | |
'Book-Author': 'Marlys, Taege', 'Year-Of-Publication': 1987, | |
'Publisher': 'Concordia Publishing House', | |
'Image-URL': 'http://images.amazon.com/images/P/057004460X.01.LZZZZZZZ.jpg', | |
'average_rating': 5.0, 'book_id': 3622636, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -----------This works!------------------------------- | |
book_search_variable= searchString | |
y=mydb['bookDataset'].find({"Book-Title":{"$regex":book_search_variable}}).limit(5) | |
bookSearched=list(y) | |
print(bookSearched) | |
#----------------trying to change Book-Author to bookAuthor----------------------------- | |
#----------------didn't work--------------------------- | |
#-----------book_search_data = [] always------------------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# date is hardcoded. Please fix that | |
x=mydb['bookDataset'].aggregate([{"$match":{"date_added":{"$gt":datetime.datetime(2019, 6, 21, 8, 25,50)}}},{"$project":{"_id":0,"ISBN":1}}]) | |
data=list(x) | |
print(data) | |
for i in data: | |
interaction_matrix_pickle[i['ISBN']]=0 |
OlderNewer