Professional Web Applications Themes

programming amazon-like recommendations - PHP Development

Well, I meant more like sessions but stored in normal cookies and then your own DB instead of PHP's own session thingy... Maybe a directory with a file for each user storing info? MySQL isn't the best option for EVERYthing... -- // DvDmanDT MSN: [email]dvdmandthotmail.com[/email] Mail: [email]dvdmandttelia.com[/email] "Floris van den Berg" <flvdbergwxs.nl> skrev i meddelandet news:bglsdt$5s1$1reader08.wxs.nl... > > "DvDmanDT" <dvdmandttelia.com> schreef in bericht > news:AmuXa.18697$mU6.18641newsb.telia.net... > > Time to use cookies and databases... > > I already stated i use mysql. > > Floris > >...

  1. #1

    Default Re: programming amazon-like recommendations

    Well, I meant more like sessions but stored in normal cookies and then your
    own DB instead of PHP's own session thingy... Maybe a directory with a file
    for each user storing info? MySQL isn't the best option for EVERYthing...
    --
    // DvDmanDT
    MSN: [email]dvdmandthotmail.com[/email]
    Mail: [email]dvdmandttelia.com[/email]
    "Floris van den Berg" <flvdbergwxs.nl> skrev i meddelandet
    news:bglsdt$5s1$1reader08.wxs.nl...
    >
    > "DvDmanDT" <dvdmandttelia.com> schreef in bericht
    > news:AmuXa.18697$mU6.18641newsb.telia.net...
    > > Time to use cookies and databases...
    >
    > I already stated i use mysql.
    >
    > Floris
    >
    >

    DvDmanDT Guest

  2. #2

    Default Re: programming amazon-like recommendations

    "Floris van den Berg" <flvdbergwxs.nl> wrote in message
    news:bgm011$7hq$1reader08.wxs.nl...
    >
    > > On Mon, 04 Aug 2003 15:57:31 +0200, Floris van den Berg wrote:
    > > > - per user keep a history of visited products
    > > > - per product keep a list of related products
    > > > - show the related products of the visited products as
    recommendations,
    > but
    > > > only if these are not already purchased or flagged as not interesting.
    > > >
    > > > Any thoughts if i could do it better?
    >
    > I indeed keep track of what customers ordered in a table, as well as what
    > products they watch. But knowing what someone ordered or watches, doesn't
    > tell me what other products these customers might be interested in.
    > Currently i keep a 'relation' table, where i relate one product to
    another.
    > I show the contents of this table everytime someone views a product, so
    that
    > they can easily find other items they might be interested in (and keep
    them
    > on the website).
    >
    > The relation table is rather static, because i set it manually from my
    > content files (i wrote a tool that takes a number of modified ini-files
    and
    > outputs pictures and sql). I would like to make things a bit more dynamic.
    > Somehow gather statistical data that allows me to dynamically relate one
    > product to another based on what products they watch and purchase. Not
    sure
    > how to go about this though.
    >
    > Floris
    >
    You're on the right track by creating a "related products" table for items
    that are similar. The easy way to solve your problem is to grab a list of a
    single visitor's purchase, and create links from each of these products to
    the other in your RDB. This will create a Many-to-Many relationship within
    a single table. You won't want to modify the products themselves, but
    rather an external linking table. The linking table would look like this:

    create table product_links_internal (
    id_source int not null,
    id_target int not null,
    strength int not null default 1 );

    I added a non-RDB column called "strength" to indicate the statistical
    strength of the link. This is, at best, a kludge, but works rather nicely
    for being as simple as it is.

    For now, pretend this is your products table:

    create table products (
    id int not null auto_increment primary key,
    name varchar(127) );

    Say someone orders three games:
    Game 1: id = 1, name = "Pong"
    Game 2: id = 2, name = "Centipede"
    Game 3: id = 3, name = "Wolfenstein 3D"

    If you want these products to now have a set of relationships with each
    other, just check to see if they are already linked, and, if not, create a
    new link. Note: since this is an internally-linked list, you should always
    link ascending items to prevent "cross-links" which would undermine your
    statistics.

    For these items, I would sort the order by "id," then check for links.
    Let's assume only Pong and Centipede are linked together. And, Wolfenstein
    3D is not linked to any of them.

    Therefore, we will have a record already established for the 1->2 link with
    some unknown strength value. In this case, we would want to increase the
    strength of this relationship by updating the record:

    update product_links_internal set strength = strength + 1 where id_source
    = 1 and id_target = 2

    Since Wolfenstein is not related to the other two games, it will need to get
    its first link set to both games:

    insert into product_links_internal (id_source, id_target) values (1,3)
    (2,3)

    Now that you have a list of links with a relative rating for "relatedeness,"
    you can start to display a list of "related items" without anything too
    fancy:

    select products.* from products,product_links_internal where product.id =
    product_links_internal.id_source or product.id =
    product_links_internal.id_target having product_links_internal.id_source =
    $CURRENT_PRODUCT or product_links_internal.id_target = $CURRENT_PRODUCT
    order by product_links_internal.strength desc limit 5

    The value for "$CURRENT_PRODUCT" is supplied by your reporting script and is
    the id of the item for which you currently wish to display a list of
    "related items." This query will return the top 5 related items for any
    given item. (Remove the "having" clause to see a list of the top 5
    strongest links.)

    I've used a similar method for a community-managed content system (a fancy
    term for a bulletin board that is self-managing). I came up with the idea
    when I was drawing out my RDB diagrams and wanted a way to represent a
    really thick line connecting two records and relatively thin line connecting
    two records. The "real" RDB method would be to create a new instance of the
    link each time and add up the total number of links when reporting, but
    since we're in a web-based environment, I decided to break that rule in
    favor of depleting processor resources on the backend instead of the
    frontend.

    Hopefully, this will give you some ideas as to how to solve your particular
    problem.

    Take care,
    Zac


    Zac Hester Guest

  3. #3

    Default Re: programming amazon-like recommendations

    "Zac Hester" <newsplanetzac.net> schreef in bericht
    news:3f2f0aee$1news.enetis.net...

    [snip]
    > I think you understand. This method is good if you want to "datamine"
    > information from your customers. However, like you said, this means that
    > items may not be related at all.
    I made a variation on your technique. I think it will work fine:

    - i keep my hard-set relation table
    - each time a user views a product i put that product in a table
    - each time a user purchases a product i put that product in another table
    - once in a while i start my 'dataminer' script. this script goes through
    all visited products, grabs the related items and puts them into a link
    table
    - the strength value in the link table increases when multiple links are
    found
    - products that were purchased have a larger 'weight' than products that
    were just viewed
    - in the end i show a list of recommendations sorted from the highest
    strength to the lowest.

    Ofcourse the disadvantage of this is that my relations are pretty much set.
    I will have to continously update my relations as new products arrive. But
    with enough products in the database, the recommendations will probably be
    diverse enough to be usefull. If this doesn't work too well, i could always
    revert to your (simpler) approach. What do you think?

    Floris



    Floris van den Berg Guest

Similar Threads

  1. Programming 3D book recommendations?
    By John B in forum Macromedia Director 3D
    Replies: 4
    Last Post: July 7th, 12:03 PM
  2. Replies: 0
    Last Post: May 5th, 06:41 PM
  3. Socket Programming Book Recommendations
    By david_news2000 in forum AIX
    Replies: 2
    Last Post: September 28th, 11:46 PM
  4. Amazon.com Web Services
    By Jim Deitzel webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 0
    Last Post: July 29th, 11:12 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139