How do you write a django model that can crunch numbers and automatically populate another field with results?
There's a more detailed version of this question where I've embedded
graphics and explained my algorithm to make it more clear on
stackoverflow. I haven't gotten a response on it yet so I thought I
might come here and see if anyone can help me out.
http://stackoverflow.com/questions/10493279/how-do-you-write-a-django-model-that-can-automatically-normalize-data
In a nutshell, I'm putting together a music recommendation engine and
I need to store data about the different tracks in a sqlite database.
I've set it up so that you can easily add the data using the admin
interface. There's one particular piece of data for each track called
tfidf that's basically a sentiment score for the lyrics. I'm trying to
set up the model in such a way once you manually enter the tfidf value
of the track in admin, it automatically calculates a normalized value
for it. The algorithm basically just looks at the tfidf value of the
track and subtracts the smallest tfidf value of all the tracks in the
column from that. Then it divides that number by the difference of the
largest tfidf and the smallest tfidf values in the column. That gives
you a number between 0 and 1.
The problem is that django doesn't seem to have the methods that would
allow me to automatically select minimum and maximum tfidf values in a
table the way I could with SQL statements. Basically, to code this
algorithm, I need to be able to select minimum and maximum tfidf
values in a column, along with the tfidf value of the track, and then
it's just a matter of doing calculations. I'm pretty new to django and
am not fully aware of what it's capable of. The model for the table
I'm talking about is this:
class Party(models.Model):
song = models.CharField(max_length = 30)
tfidf = models.FloatField(max_length = 50)
normalized_tfidf = models.FloatField(max_length = 50)
Anybody have any idea what tools are available in django to
automatically take the tfidf data, do calculations on it, and then
automatically have the results populate the normalized_tfidf field?
thnx
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home