mirror of
https://github.com/task-17-lct/backend.git
synced 2024-11-24 03:23:42 +03:00
add match
This commit is contained in:
parent
7d8f0578f5
commit
97df3fa982
|
@ -191,9 +191,14 @@ def get_personal_movies_recommendation(user):
|
||||||
|
|
||||||
|
|
||||||
def dist_func(event1: Event, event2: Event):
|
def dist_func(event1: Event, event2: Event):
|
||||||
cords1 = [event1.lat, event1.lon]
|
# cords1 = [event1.lat, event1.lon]
|
||||||
cords2 = [event2.lat, event2.lon]
|
# cords2 = [event2.lat, event2.lon]
|
||||||
return GD(cords1, cords2).km
|
# try:
|
||||||
|
# dist = GD(cords1, cords2).km
|
||||||
|
# return dist
|
||||||
|
# except:
|
||||||
|
# return 1000000
|
||||||
|
return (event1.lon - event2.lon) ** 2 + (event1.lat - event2.lat) ** 2
|
||||||
|
|
||||||
|
|
||||||
def generate_nearest():
|
def generate_nearest():
|
||||||
|
@ -219,12 +224,15 @@ def generate_hotel_nearest():
|
||||||
if i % 100 == 0:
|
if i % 100 == 0:
|
||||||
print(i)
|
print(i)
|
||||||
|
|
||||||
def match_museums():
|
def match_points():
|
||||||
regions = list(Region.objects.all())
|
regions = list(City.objects.all())
|
||||||
for museum in Event.objects.filter(type='museum'):
|
for i, point in enumerate(Event.objects.all()):
|
||||||
s_regions = list(sorted(regions.copy(), key=lambda x: dist_func(museum, x)))
|
s_regions = list(sorted(regions.copy(), key=lambda x: dist_func(point, x)))
|
||||||
museum.region = s_regions[0]
|
point.city = s_regions[0]
|
||||||
museum.save()
|
point.save()
|
||||||
|
if i % 10 == 0:
|
||||||
|
print(i)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def calculate_mean_metric(favorite_events: Iterable[Event], target_event: Event, model: AnnoyIndex, rev_mapping):
|
def calculate_mean_metric(favorite_events: Iterable[Event], target_event: Event, model: AnnoyIndex, rev_mapping):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user