-
Notifications
You must be signed in to change notification settings - Fork 3
Matching admin #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
README.md
Outdated
|
|
||
| ## Main page | ||
|
|
||
| ```/index``` is the main page. It shows you a map (google or leaflet) with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the map?
| from django.contrib import admin | ||
| from django.http import HttpResponse | ||
|
|
||
| from .models import Iteration, MarkedObjects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я за полные импорты
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
у меня пайчарм против тогда будет. если я установлю прям приложение, то из-за того, что оно лежит в подпапке, оно будет импортить из установленного приложения, а не откуда надо. ну и из-за того, что у меня нет этого установленного приложения, пайчарм не ходит по декларациям.
это всё можно пофиксить при помощи sys.path.append и настройками ИДЕ, но запускающему чуваку, которому просто надо чтобы запустилось один раз, надо будет это тоже проделывать, что приведет к вопросам ко мне (фиксится ридми, но периодическое нечтение ридми ничем не фиксится).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Имхо, редактор - это не причина.
|
|
||
|
|
||
| class MarkedObjects(models.Model): | ||
| obj_id = models.IntegerField() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
мне кажется, что лучше тут и дальше полностью object_X
| meta = models.TextField() | ||
|
|
||
|
|
||
| class MarkedObjects(models.Model): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
что такое obj, а что такое other? реквестирую докстринг
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
возможно здесь вообще лучше сделать просто таблицу объектов и сделать внешнюю m2m?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obj - это obj, а other - это other_obj без четырех букв) напишу
м2м не хочу потому что будет малоюзабельно: тут дело в том, что предполагается матчинг сферических объектов в вакууме и мне надо получить на выходе только таблицу, что с чем матчится и некоторую метаинфу, по которой можно было бы обучать.
если бы это какой-то веб был (в смысле в продакшене и где больше одного юзера), где надо хранить инфу об объектах и выводить всякое разное - имело бы смысл.
а так мне придется сначала распихать это всё по разным таблицам, а потом собирать обратно. если очень надо будет - шелл скриптом это можно сделать из оригинальных данных, а не записанных мной.
| <head> | ||
|
|
||
|
|
||
| <style> html, body, #map { height: 100%; width: 100%; padding: 0; margin: 0; } </style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
отступы бы добавить (2 пробела)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| while True: | ||
| lineno = random.randint(1, len(settings.dataset)) | ||
| row = settings.dataset[lineno: lineno + 1].to_dict(orient='records')[0] | ||
| if float(row['dist_1']) > 0.02: # ~3km |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в константу наверх?
| break | ||
| row['obj_lat'], row['obj_lon'] = map( | ||
| float, | ||
| row.pop('geometry').replace('POINT (', '').replace(')', '').split() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
предлагаю это преобразование в какой-нибудь отдельный метод запихнуть
|
|
||
| import os | ||
| import pandas as pd | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ строка после импортов
| STATIC_URL = '/static/' | ||
|
|
||
|
|
||
| dataset = pd.read_csv('../hotels_geomatched.csv', sep='\t', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
из конфига?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вообще на мой взгляд идея строить датасет в настроечках - не очень. хочу я shell, например вызвать, а оно мне жахнет все это
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Категорически против операций в сеттингах жЫрнее чем O(1).
| @@ -0,0 +1,7 @@ | |||
| osmium | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
версии?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
предположила, что это будет только на локальных тачках, так что может сойти что угодно имеющееся
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну хз, breaking changes и все такое. я бы прибила гвоздями
| </body> | ||
|
|
||
| <script> | ||
| var map = new L.Map('map', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я не знаток js, тут не нужен свой скоуп?
(function() {
// code
})();There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не, не обязательно, эти глобально просто определятся, тут все же не совсем продакшон-код. но по-хорошему, надо, конечно, завернуть в метод и повесить на коллбэк загрузки страницы
| </body> | ||
|
|
||
| <script> | ||
| var map = new L.Map('map', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не, не обязательно, эти глобально просто определятся, тут все же не совсем продакшон-код. но по-хорошему, надо, конечно, завернуть в метод и повесить на коллбэк загрузки страницы
|
|
||
|
|
||
| function setNewData () { | ||
| var fss = $.getJSON('http://127.0.0.1:8000/row/', function(features) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
из конфига порт?
|
|
||
| from shapely.geometry import Point | ||
|
|
||
| from .internals.constants import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я за полные пути
| import geopandas as gpd | ||
| import pandas as pd | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это сторонний же модуль? почему отступы тогда?
|
|
||
|
|
||
| class HotelsOSMHandler(OSMHandler): | ||
| def not_dependency(self, elem): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_not_dependency
| osmhandler = HotelsOSMHandler() | ||
| # scan the input file and fills the handler list accordingly | ||
| osmhandler.apply_file("../hotels_wo_unwanted.osm") | ||
|
|
||
| # transform the list into a pandas DataFrame | ||
| data_colnames = ['type', 'id', 'ntags', 'name', 'geometry', ] | ||
|
|
||
| crs = {'init': 'epsg:4326'} # OSM | ||
| gdf_osm = gpd.GeoDataFrame(osmhandler.osm_data, crs=crs, columns=data_colnames) | ||
|
|
||
|
|
||
| df = pd.read_csv('../hotels_booking_latest.csv', sep='\t', header=None, | ||
| names=[ | ||
| 'other_id', 'other_lat', 'other_lon', | ||
| 'other_name', 'addr', 'n', | ||
| 'm', 'i', 'rating', | ||
| 'web', 'j', 'trans'], | ||
| na_values='None') | ||
| geometry = [Point(xy) for xy in zip(df.other_lat, df.other_lon)] | ||
|
|
||
|
|
||
| crs2 = {'init': 'epsg:3857'} # google | ||
| gdf_booking = gpd.GeoDataFrame(df, crs=crs2, geometry=geometry) | ||
|
|
||
| c = ckdnearest(gdf_osm, gdf_booking, gdfB_cols=B_COLS) | ||
| c.sort_values(by=['type', 'id']) | ||
| c.to_csv('hotels_geomatched.csv', sep='\t', index_label='lineno') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в __main__?
| gdf_osm = gpd.GeoDataFrame(osmhandler.osm_data, crs=crs, columns=data_colnames) | ||
|
|
||
|
|
||
| df = pd.read_csv('../hotels_booking_latest.csv', sep='\t', header=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
путь в константу
| from sklearn.tree import DecisionTreeClassifier | ||
| from sklearn.dummy import DummyClassifier | ||
| from ..internals.tools import get_df, get_sets, get_fit_classifier | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 стр
| from sklearn.metrics import accuracy_score | ||
| from sklearn.tree import DecisionTreeClassifier | ||
| from sklearn.dummy import DummyClassifier | ||
| from ..internals.tools import get_df, get_sets, get_fit_classifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я за полные пути
| marked_df = get_df(os.environ['MARKED_DATA']) | ||
|
|
||
| # Here we get 50/50 true and false marked objects | ||
| X_train, X_test, y_train, y_test = get_sets(marked_df, test_size=0.5, get_all_as_test=False) | ||
|
|
||
|
|
||
| clf = get_fit_classifier(DummyClassifier, X_train, y_train) | ||
| y_pred = clf.predict(X_test) | ||
| dummy_score = accuracy_score(y_test, y_pred) | ||
|
|
||
|
|
||
| clf = get_fit_classifier(DecisionTreeClassifier, X_train, y_train) | ||
| y_pred = clf.predict(X_test) | ||
| clf_score = accuracy_score(y_test, y_pred) | ||
|
|
||
| print("50/50 dataset") | ||
| print(f"Dummy accuracy: {dummy_score}, should be ~0.5") | ||
| print(f"DecisionTreeClassifier accuracy: {clf_score}, should be more than Dummy accuracy") | ||
|
|
||
|
|
||
| _, X_test, _, y_test = get_sets(marked_df, test_size=0.5, get_all_as_test=True) | ||
|
|
||
| y_pred = clf.predict(X_test) | ||
| clf_score = accuracy_score(y_test, y_pred) | ||
|
|
||
| print("Full dataset") | ||
| print(f"DecisionTreeClassifier accuracy: {clf_score}, should be more than Dummy accuracy") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
предлагаю завернуть в main
| import os | ||
|
|
||
| from setuptools import setup | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 стр
| @@ -0,0 +1,43 @@ | |||
| import os | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не нужна строка
A django web application to mark hotels match.