Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Help: Designing Models for Matches in a Dating App?

I’m working on a dating app for a hackathon project. We have a series of questions that users fill out, and then every few days we are going to send suggested matches. If anyone has a good tutorial for these kinds of matching algorithms, it would be very appreciated. One idea is to assign a point value for each question and then to do a
def comparison(person_a, person_b) function where you iterate through these questions, and where there’s a common answer, you add in a point. So the higher the score, the better the match. I understand this so far, but I’m struggling to see how to save this data in the database.

In python, I could take each user and then iterate through all the other users with this comparison function and make a dictionary for each person that lists all the other users and a score for them. And then to suggest matches, I iterate through the dictionary list and if that person hasn’t been matched up already with that person, then make a match.

person1_dictionary_of_matches = {‘person2’: 3, ‘person3’: 5, ‘person4’: 10, ‘person5’: 12, ‘person6’: 2,……,‘person200’:10}
person_1_list_of_prior_matches = [‘person3’, 'person4']

I'm struggling on how to represent this in django. I could have a bunch of users and make a Match model like:

class Match(Model):
person1 = models.ForeignKey(User)
person2 = models.ForeignKey(User)
score = models.PositiveIntegerField()

Where I do the iteration and save all the pairwise scores.

and then do
person_matches = Match.objectsfilter(person1=sarah, person2!=sarah).order_by('score').exclude(person2 in list_of_past_matches)

But I’m worried with 1000 users, I will have 1000000 rows in my table if do this. Will this be brutal to have to save all these pairwise scores for each user in the database? Or does this not matter if I run it at like Sunday night at 1am or just cache these responses once and use the comparisons for a period of months? Is there a better way to do this than matching everyone up pairwise? Should I use some other data structure to capture the people and their compatibility score? Thanks so much for any guidance!

/r/django
https://redd.it/7lo21q
Project collaborations

Anyone have a project that I can join into?

/r/Python
https://redd.it/7lpbfo
A mini-tutorial on deploying smart contracts with python

I wanted to learn smart contract development for work and started off with a simple tutorial that was in javascript. To challenge myself I started converting the tutorial to python.

https://github.com/adamyala/Your_First_Decentralized_Application_Python

I tried to make it as simple as possible and added lots of notes I wish I had when I was learning.

I'd love to know if there is anything I can add/change to make it clearer and more simple. My goal is to eventually convert the entire thing to 100% python.

/r/Python
https://redd.it/7lr48g
[D] What ML publication hacks are you familiar with, and which annoy you the most?

This is in line with "When a measure becomes a target, it ceases to be a good measure."

In ML literature (and other literature, especially academic) the measure/target is 'good reviews from reviewers'.

So which publication hacks are you familiar with, and which annoy you the most?

I'll start, motivated by a comment from https://github.com/hengyuan-hu/bottom-up-attention-vqa :

> The third point is simply because we feel the two stream classifier and pre-training in the original paper is over-complicated and not necessary.

Hack: Begin complex, and do not 'waste' your time with ablation studies / trying to simplify.

Reason this improves the measure/target: Reviewers will more often complain about simplicity ('incremental research') than complexity.

Reason this sucks for everyone involved except the authors: Leads to overly complex models, with little to no understanding of which components are actually useful.

Edit: Fixed URL

/r/MachineLearning
https://redd.it/7lq58j
How do I create a checkbox using model fields?

I have to create a field in a model, what field class can I use to represent the checkbox? How can I use this in the Modelform?



/r/django
https://redd.it/7lurgg
[AF] SocketIO -- Server not opening websocket connection

Hi, I'm trying to run a (very) simple websocket server.

I'm trying to connect using a command line tool:
> $ wscat -c ws://localhost:5000/

Starting the server, and running the *wscat* request, I see:

* Serving Flask-SocketIO app "main"
* Forcing debug mode on
* Restarting with stat
* Debugger is active!
* Debugger PIN: 243-427-340
(1983) wsgi starting up on http://127.0.0.1:5000
(1983) accepted ('127.0.0.1', 50372)
127.0.0.1 - - [24/Dec/2017 09:19:18] "GET / HTTP/1.1" 200 132 0.003266

It's making the http connection, but doesn't seem to be promoting to websockets. There's a debugging "print" doesn't print, and an "emit" that doesn't emit for the "connect".

I can use *wscat* to connect to echo servers just fine.

I'm clearly not doing something right, I'm just really not sure what!

I've tried with web pages too -- but here I'm trying to keep it simple.

[GitHub app](https://github.com/hanhanhan/fake_bus_api/blob/ws_troubleshoot/main.py)

[conda installed requirements](https://github.com/hanhanhan/fake_bus_api/blob/ws_troubleshoot/requirements_conda.txt)

[pip installed requirements](https://github.com/hanhanhan/fake_bus_api/blob/ws_troubleshoot/requirements.txt)

I'd really appreciate another pair of eyes, if anyone has troubleshooting advice or can see a bug.

Thanks, and Happy Christmas!

EDIT:
I just tried running Miguel Grinberg's Flask-SocketIO off of github, but with the same environment I was running my own test with.

It works!

Though some of the responses are labelled polling, and some are websockets, which seems funny to me that it's doing both in the same browser.

But this confirms it's me not seeing / understanding some concept.

127.0.0.1 - - [24/Dec/2017 14:43:40] "GET / HTTP/1.1" 200 6028 0.001638
127.0.0.1 - - [24/Dec/2017 14:43:40] "GET /socket.io/?EIO=3&transport=polling&t=1514144620687-0 HTTP/1.1" 200 381 0.001277

(2632) accepted ('127.0.0.1', 51051)
Client disconnected 19392765e6d8415f9c2654d2cf924186
127.0.0.1 - - [24/Dec/2017 14:47:18] "GET /socket.io/?EIO=3&transport=websocket&sid=19392765e6d8415f9c2654d2cf924186 HTTP/1.1" 200 0 217.415311



/r/flask
https://redd.it/7lvfuh
Best of /r/Python 2017

This is our Best of 2017 thread.

Submit things that you loved about /r/Python this year. It can be people, posts, comments, or whatever you want, as long as it is something that is in this subreddit.

Going to keep this post stickied until January 2nd, then hand out some gold to the people that the votes tell us are the best!

Merry Christmas everyone!

/r/Python
https://redd.it/7lyxpw
Jupyter Auto Starting in Atom Terminal

Not sure if this is the right place to post this but I thought I'd try.

Whenever I run the terminal in atom, it automatically starts a jupyter notebook. Not sure why this happens but its really annoying.

I also opened just a terminal window directly. It opened fine but this was the second line in the window:

env: jupyter-notebook: No such file or directory


Not sure what's going on here... Any help would be appreciated!

/r/Python
https://redd.it/7lz9rm
context in class-based views

So I recently switched to class based views, and found this code to pass in additional context to template:

class DetailView(generic.DetailView):
model = Language

template_name = 'languages/detail.html'

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)

context['year'] = Details.objects.filter(year=2016)

return context

However, I fail to be able to display values/the variable in the HTML. How do i go about this in template.html?

/r/django
https://redd.it/7m01au
[News] New NVIDIA EULA prohibits Deep Learning on GeForce GPUs in data centers.

According to German tech magazine golem.de, the new NVIDIA EULA prohibits Deep Learning applications to be run on GeForce GPUs.

Sources:

https://www.golem.de/news/treiber-eula-nvidia-untersagt-deep-learning-auf-geforces-1712-131848.html

http://www.nvidia.com/content/DriverDownload-March2009/licence.php?lang=us&type=GeForce

The EULA states:

"No Datacenter Deployment. The SOFTWARE is not licensed for datacenter deployment, except that blockchain processing in a datacenter is permitted."

EDIT: Found an English article: https://wirelesswire.jp/2017/12/62708/





/r/MachineLearning
https://redd.it/7ly5gi
Django's autoreload function is unusably slow

Hello.

I have never had this problem in the past, but I am starting a new project and Django's autoreload feature (where it restarts the server after a code change) has been ridiculously slow (15 seconds - never). I am using WSL. I think this is something new with Django 2.0.

/r/django
https://redd.it/7m0gqu