Пример #1
0
def test_recommendations() -> None:
    service = RecommendationService()
    request = RecommendationRequest(
        user_id=1, category=BookCategory.MYSTERY, max_results=1
    )
    response = service.Recommend(request, None)
    assert len(response.recommendations) == 1
def render_homepage():
    recommendations_request = RecommendationRequest(
        user_id=1, category=BookCategory.MYSTERY, max_results=3)
    recommendations_response = recommendations_client.Recommend(
        recommendations_request)
    return render_template(
        "homepage.html",
        recommendations=recommendations_response.recommendations,
    )
Пример #3
0
async def render_homepage(request: Request):
    recommendations_request = RecommendationRequest(
        user_id=1, category=BookCategory.MYSTERY, max_results=3)
    recommendations_response = recommendations_client.Recommend(
        recommendations_request)
    return templates.TemplateResponse(
        "homepage.html", {
            "request": request,
            "recommendations": recommendations_response.recommendations,
        })
Пример #4
0
import os

import grpc

from recommendations_pb2 import RecommendationRequest, BookCategory
from recommendations_pb2_grpc import RecommendationsStub

recommendations_host = os.getenv("RECOMMENDATIONS_HOST", "localhost:50051")
channel = grpc.insecure_channel(f"{recommendations_host}")
client = RecommendationsStub(channel)
request = RecommendationRequest(user_id=1,
                                category=BookCategory.SCIENCE_FICTION,
                                max_results=2)
result = client.Recommend(request)
print("Result from the server : ", result.recommendations)
Пример #5
0
import os
import sys
import csv
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from recommendations_pb2_grpc import RecommendationsStub
from recommendations_pb2 import RecommendationRequest

sys.argv[1] = os.environ.get(sys.argv[1],sys.argv[1])
var = sys.argv[1]
#var = 715318008
channel = grpc.insecure_channel("35.185.15.252:50051")
client = RecommendationsStub(channel)
request = RecommendationRequest(ID=int(var))
result = client.Recommend(request)
print(result)

# csv_columns = ['CLIENTNUM','Attrition_Flag','Customer_Age','Gender','Dependent_count','Education_Level','Marital_Status','Income_Category','Card_Category','Months_on_book','Total_Relantionship_Count','Months_Inactive_12_mon', 'Contacts_Count_12_mon', 'Credit_Limit','Total_Revolving_Bal','Avg_Open_To_Buy','Total_Amt_Chng_Q4_Q1','Total_Trans_Amt','Total_Trans_Ct','Total_Ct_Chng_Q4_Q1','Avg_Utilization_Ratio','Naive_Bayes_Classifier_Attrition_Flag_Card_Category_Contacts_Count_12_mon_Dependent_count_Education_Level_Months_Inactive_12_mon','Naive_Bayes_Classifier_Attrition_Flag_Card_Category_Contacts_Count_12_mon_Dependent_count_Education_Level_Months_Inactive_12_mon_2']
# result_to_dict = [
#     {"CLIENTNUM" : result.recommendations.CLIENTNUM,
#     "Attrition_Flag" : result.recommendations.Attrition_Flag,
#     "Customer_Age" : result.recommendations.Customer_Age ,
#     "Gender" : result.recommendations.Gender,
#     "Dependent_count" : result.recommendations.Dependent_count,
#     "Education_Level" : result.recommendations.Education_Level,
#     "Marital_Status" : result.recommendations.Marital_Status,
#     "Income_Category" : result.recommendations.Income_Category,
#     "Card_Category" : result.recommendations.Card_Category,
#     "Months_on_book" : result.recommendations.Months_on_book,