forum.coppermine-gallery.net

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Miscellaneous => Topic started by: jp-photo.dk on September 15, 2004, 03:03:18 pm

Title: TopRated shows pictures with most votes not best average?
Post by: jp-photo.dk on September 15, 2004, 03:03:18 pm
Have I understood this correct? That TopRated shows the pictures with the most votes, and not the best average? I have an example here: http://www.jp-photo.dk/galleri/thumbnails.php?album=toprated&cat=0

Is is possible to get CPG to show the best average instead?

Regards,
Jan
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Nibbler on September 15, 2004, 03:08:10 pm
They are sorted by rating first, then by  number of votes. Should be clearer if you look at the last page of your top rated section, the last pic has 30 votes, the second to last has 18.
Title: Re: TopRated shows pictures with most votes not best average?
Post by: jp-photo.dk on September 15, 2004, 03:16:45 pm
But the #1 picture has a rating of 4.7 with 38 votes and #2 a rating of 4.8 with 37 votes??

Regards,
Jan
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Casper on September 15, 2004, 09:30:06 pm
OK, you are both correct, in that it is done by rating first, but is note done to the nearest fraction of a point.  If you look at page 2, you will see the 2 horses picture has had 137 votes, but several pics rated above it have only 3 votes.
This is something we can look at.

But if we do go to fractions, it means that a pic with just 1 vote at 5, will be shown above one with 100 votes, 99 of which were 5, but 1 was 4.
Title: Re: TopRated shows pictures with most votes not best average?
Post by: jp-photo.dk on September 16, 2004, 07:50:24 am
Yes - that could be solved by adjusting the number of votes needed before shown in the TopRated. This is already in the configuration. So a listing with fractions would be really great.

Regards,
Jan
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Joachim Müller on September 16, 2004, 08:28:07 am
jp-photo.dk is right, we should add this to the code (busy sites with huindreds of votes per pic will surely not set the number of votes needed to such low values as "1"). Casper, could you do this?

Joachim

Title: Re: TopRated shows pictures with most votes not best average?
Post by: Casper on September 16, 2004, 10:49:31 am
OK,
I don't have a setup with multiple votes already applied, so this is not well tested.

@jp-photo.dk, please test this on your site, and report if it works without problem.  If it does, I will commit to cvs.

Open include/functions.inc.php, and find;

Code: [Select]
$ALBUM_SET ORDER BY ROUND((pic_rating+1)/2000) DESC, votes DESC $limit";
Change this to;

Code: [Select]
$ALBUM_SET ORDER BY ROUND((pic_rating+1)/2000.23) DESC, votes DESC $limit";
From my limited understanding of the mysql manual, and my limited testing, this seems to do it.
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Casper on September 16, 2004, 11:15:31 am
Change to above, which did not work fully.  The new code should be;

Code: [Select]
$ALBUM_SET ORDER BY ROUND((pic_rating+1)/1.298) DESC, votes DESC $limit";
Please report if this works for you.
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Tarique Sani on September 16, 2004, 02:20:30 pm
Casper can you explain how you got 1.298
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Casper on September 16, 2004, 02:47:10 pm
Not really  :-[.

I was reading the mySQL manual, with reference to the 'ROUND' function, and getting confused.  This is the info in the manual;

Quote
ROUND(X,D)
Returns the argument X, rounded to the nearest integer. With two arguments, returns X rounded to D decimals. If D is negative, the integer part of the number is zeroed out. mysql> SELECT ROUND(-1.23);
        -> -1
mysql> SELECT ROUND(-1.58);
        -> -2
mysql> SELECT ROUND(1.58);
        -> 2
mysql> SELECT ROUND(1.298, 1);
        -> 1.3
mysql> SELECT ROUND(1.298, 0);
        -> 1
mysql> SELECT ROUND(23.298, -1);
        -> 20


I tried adding the decimal points to the existing '2000' (where that came from I don't know) and it worked to a degree, but not completely.  I then thought I'd try with the 1.298 as in the manual, and it seemed to work, albeit on my site with extremely linited scope to test this.

I don't know why it works, or if it works fully as we want, which is why I've asked for it to be tested on sites that have plenty of pics and votes.
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Nibbler on September 16, 2004, 03:00:00 pm
Those numbers are examples for rounding, it says you round 1.298 to 0 decimal places you get 1.

Can we not simply order by pic_rating ?
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Casper on September 16, 2004, 03:12:18 pm
Alright, I was tired this morning, and confused.  I saw that query, with numbers like 2000, and thought it would be more complicated than it really is. :-[

I have tried this on my site, and it seems to work, so please test.

Change the above code to;

Code: [Select]
$ALBUM_SET ORDER BY pic_rating DESC, votes DESC $limit";
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Tranz on September 16, 2004, 03:22:02 pm
I tried adding the decimal points to the existing '2000' (where that came from I don't know)
2000 is the value per point. So, a vote of 5/5 is worth 10000, 1/5 is 2000. That was what I figured from looking at the vote values in the dB.
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Casper on December 12, 2004, 02:14:38 pm
Bump;

has anyone tested this yet (my post above), so I can add this to the next version.
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Casper on December 15, 2004, 11:05:21 am
I have committed the above fix to version 1.4.
Title: Re: TopRated shows pictures with most votes not best average?
Post by: panwac on December 15, 2004, 11:28:44 pm
It was tested in my test-gallery - in this moment it looks fine. ;)
Title: Re: TopRated shows pictures with most votes not best average?
Post by: peakoverload on January 17, 2005, 12:25:11 pm
I think/hope that this is the answer to the problem I am having here http://forum.coppermine-gallery.net/index.php?topic=13787.0

The thing is that I am now totally confused as to how Top Rated is NOW working with this hack as I wasnt that sure how it worked BEFORE the hack  :-[ and the difference it made was huge!

Before I applied this hack I found that:
The photos in 20th (photo ID 1652) and 21st (photo ID 1663) position were, I think, the wrong way around.

Photo 1652 has a score of 4.7/5 with 3 votes
Photo 1663 has a score of 5/5 with 3 votes

Looking in the database
Photo 1652 has a score of 9333
Photo 1663 has a score of 10000

So by my thinking they should have been the other way around.

Now that I have applied this hack these two photos are now the opposite way around just much further apart 1663 has moved from 21st place to 5th place whilst 1652 has moved from 20th place to 25th place.

I guess what I am getting at is that to my thinking a photo that has received 3 votes of 5 stars should be higher than a photo that gets 2 votes of 5 stars obviously but that a photo that 3 votes each of 4 stars should be higher than a photo that got 2 votes of 5 stars i.e. the scores are added. 3x5=15, 2x5=10, 3x4=12

That WAS how I thought the Coppermine voting system originally worked anyway but then that doesnt explain the order I was seeing. Sorry to be thick but is that how this hack then organises them? I'm sooooo confused  :D
Title: Re: TopRated shows pictures with most votes not best average?
Post by: radial on January 18, 2005, 02:40:45 am
This is just an idea I had, i could be absolutely wrong, but wanted to throw my 2 cents in.

None of the ideas i've seen calculate date into the equation.

A picture that has been on the site for 5 days and has 10 views should be higher rated / more popular than a picture that has been on the site for 20 days and has 15 views.

Just an idea ;)

Phil Hart
www.radialmonster.com/photogallery
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Casper on January 18, 2005, 11:19:03 am
@ Peakoverload,

you are comparing 2 pics with only 3 votes each.  What about the others in the equation.  This is fairly low voting, but are they all now correctly placed, they should be.

And differences should become more apparent as they receive more votes.

At radial,

your idea would remove the individuals choice of which photos to vote on.  Just by going to the pic would give it a vote, even if once there the viewer decided they did not like it.
Title: Re: TopRated shows pictures with most votes not best average?
Post by: peakoverload on January 18, 2005, 12:07:51 pm
Thanks for this hack Casper and for explaining this to me (sorry for being slow on the uptake). Can I just ask one last question.

With this hack is the voting system more open to abuse than it was before? By that I mean if someone wanted to increase the position of their photo could they deliberately give a low vote to someone elses photo to make their's jump higher?

This is the main thing with average scores that I dont really understand.
Title: Re: TopRated shows pictures with most votes not best average?
Post by: Casper on January 18, 2005, 12:21:06 pm
This doesn't change the way the voting system works, only makes sure they are displayed in the correct order.

When there are only a few votes being counted, then any such deliberate spoiling will affect the overall result, but that will happen whatever system is used.   But the more votes received, the less effect such a bad vote will have.

When a pic has only 2 votes, 1 of 5 and 1 of 0, then it will have an average of 2.5.  When 10 votes have been cast, 9 of 5 and 1 of 0, then it will have an average of 4.5, so the spoiling vote has less effect.  If 100 votes are cast, 99 at 5 and 1 at 0, then it will have a score of 4.9.

Hope this makes it clear.
Title: Re: TopRated shows pictures with most votes not best average?
Post by: peakoverload on January 18, 2005, 12:49:03 pm
Thanks Casper that makes perfect sense now, much appreciated.
Title: Re: TopRated shows pictures with most votes not best average?
Post by: matu111 on April 03, 2005, 07:06:51 pm
sorting by pic_rating works well, thanks