Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: OT: predicting related content

by roboticus (Chancellor)
on Jan 03, 2014 at 16:59 UTC ( [id://1069174]=note: print w/replies, xml ) Need Help??


in reply to OT: predicting related content

gwhite:

I'd start simple by having a table of "score modifiers" for questions based on demographic group type. Then for a respondent, sort the questions by score and pick your questions from near the front of the list.

create table questions ( QID number constraint questions_pk primary key, question varchar2(1000) ); insert into questions (qid, question) values (1, 'Duz ya likes teh exersize equips?'); insert into questions (qid, question) values (2, 'Would you like fast relief from muscle aches?'); create table group_attributes ( GAID number constraint groups_attributes_pk primary key, gr_attr varchar2(30) ); insert into group_attributes (gaid, gr_attr) values (1, 'Male'); insert into group_attributes (gaid, gr_attr) values (2, 'Female'); insert into group_attributes (gaid, gr_attr) values (3, 'Under 15'); insert into group_attributes (gaid, gr_attr) values (4, '16-20'); insert into group_attributes (gaid, gr_attr) values (5, '20-35'); insert into group_attributes (gaid, gr_attr) values (6, '35-65'); create table question_bonuses ( QID number constraint question_bonuses_FK1 references questions(QID), GAID number constraint question_bonuses_FK2 references group_attributes(GAID), bonus number ); create index question_bonuses_pk on question_bonuses(QID,GAID); -- people from 16-35 are more interested in exercise equip insert into question_bonuses (qid, gaid, bonus) values (1, 4, .2); insert into question_bonuses (qid, gaid, bonus) values (1, 5, .2); -- A slight preference for males? insert into question_bonuses (qid, gaid, bonus) values (1, 1, .05); -- Older people are much less interested... insert into question_bonuses (qid, gaid, bonus) values (1, 6, -.5); -- But pain relief is more welcome in this case... insert into question_bonuses (qid, gaid, bonus) values (2, 6, .3);

Then when you have a respondent, add all the question bonuses and sort them by score and you can choose from the better questions.

select qid, question, ( select sum(bonus) from question_bonuses qb join group_attributes ga on ga.gaid=qb.gaid where qb.qid = q.qid and ga.ga_attr in (...respondent attribs...) ) as score from questions q order by score descending

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1069174]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found