INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Album Average Rating  (Read 8555 times)

Humbledore

  • Galactic Citizen
  • ****
  • Posts: 269
Album Average Rating
« on: July 25, 2015, 05:26:18 pm »

Hi,
I found this post from mark_h, dated 2012-05-09, in order to achieve an album average rating value:

Quote
Global variables were added to MC a couple of builds back, which has opened up a new world of functionality within MC.

Here is my method for generating album ratings using variables.

Create a smartlist and copy this string into the import/export dialogue:

[Media Type]=[Audio] [=save(0,v_tracks[album artist (auto)][album])1]=1 [=save(math(1+load(v_tracks[album artist (auto)][album])),v_tracks[album artist (auto)][album])1]=1 [=save(0,v_albumratingsum[album artist (auto)][album])1]=1 [=if(compare([rating],=,0),save(-1,v_albumratingsum[album artist (auto)][album]),)1]=1 [=if(compare(load(v_albumratingsum[album artist (auto)][album]),>,-1),save(math([rating]+load(v_albumratingsum[album artist (auto)][album])),v_albumratingsum[album artist (auto)][album]),)1]=1 ~sort=[Album Artist (auto)],[Album],[Track #],[Media Type],[Disc #],[Name]

Add an expression column 'Album Rating'

if(compare(load(v_albumratingsum[album artist (auto)][album]),>,0),formatnumber(math( load(v_albumratingsum[album artist (auto)][album]) / load(v_tracks[album artist (auto)][album]) ),2),0)

Notes:

v_albumratingsum[album artist (auto)][album] is the variable that holds the album average, or -1 if tracks remain unvoted for.
v_tracks[album artist (auto)][album] contains the number of tracks in the album

The expression column could be moved into a user field, but by leaving the actual calculations in a smartlist you can refresh the ratings at any time, eg after you've made rating changes.  Views that want to display them or smartlists that want to use them can call the generating smartlist to ensure the ratings are correct and ready for use.

Enjoy!

Mark

Is this still the preferable method to achieve an album average rating value or has it become 'easier'?

I tested the code and noticed two things I would like to change:

   1. Rounding the sum to one digit.
   2. Ignoring non rated songs, i.e if a ten songs album has five non rated songs (0 stars) and five 3 stars songs, then the average album rating should be 3.

Besides that it would be nice if I can use an Album Thumbnails view sorted on the album average rating value...
 
Thanks!
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Album Average Rating
« Reply #1 on: July 25, 2015, 07:12:00 pm »

Variables are the only way to currently average anything over a whole album

You can round the results for sure with formatnumber(n,1), you could ignore non rates songs too id probably use is empty(n,1) to check for either missing or zero
Logged

Humbledore

  • Galactic Citizen
  • ****
  • Posts: 269
Re: Album Average Rating
« Reply #2 on: July 26, 2015, 03:40:27 am »

Thanks ferday, I'll try if I can implement these changes.

So I guess then, that there is still no easy/user friendly way to achieve album thumbnail views showing album ratings. Let's hope for MC 21...
Logged

Humbledore

  • Galactic Citizen
  • ****
  • Posts: 269
Re: Album Average Rating
« Reply #3 on: July 26, 2015, 07:28:16 am »

You can round the results for sure with formatnumber(n,1), you could ignore non rates songs too id probably use is empty(n,1) to check for either missing or zero

I think I succeeded to implement formatnumber(n,1) but to ignore non rating tracks by using empty(n,1) I need some additional help with... Where shall I put this condition, and what is the exact definition?

And how to view the average rating value in an album thumbnails view? And perhaps with some desirable graphical stars...

Thanks!
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Album Average Rating
« Reply #4 on: July 26, 2015, 11:09:22 am »

My guess (haven't had time to test) is replace the iscompare(load(v...),>,0) with !isempty(load(v...),1)

The compare is asking for it to be greater than 0, the !isempty(n,1) is testing for NOT (0 or empty)

Edit: reading his expression above, it looks like non-rated gets a -1 rather than an empty.  If this is true you'll have to test for !iscompare(load(v...),<=,0) this means if NOT less than or equal to zero

To use it in thumbnails you'll have to make a custom field rather than an expression column

What I usually do in these things is make the custom field "simple"

load(v...) / load(v...) ignoring the if() part

I've made my v_numtracks into a smartlist of its own, then I can call it at will to do calculations in (ideally) other smart lists or fields and expression columns depending on the situation

I think you can then use the custom field in the thumbnail.  You could make the custom field a star field as well...I'm not sure as I don't really do thumbnail views but I seem to recall its possible now.  If you use a star field you'll want to round your output since we don't use half stars

I don't do ratings at all so I can't do a direct test but I could rate a few albums and try later when I'm not working

In case it helps, there's a small error in his explanation above.  V_albumratingsum does NOT hold the average, it holds the SUM, then the math function load() / load () is doing the average.  Variables are cool but they are black boxes...we don't outright define them in MC like we would in C or excel so I don't always understand why they work but they do
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Album Average Rating
« Reply #5 on: July 26, 2015, 11:50:25 am »

So I guess then, that there is still no easy/user friendly way to achieve album thumbnail views showing album ratings. Let's hope for MC 21...

If that's all you want, you can... Quite easily. In fact, I think it does it by default, but...

In Standard View, edit the Thumbnail Text:


Add something like this:
Code: [Select]
[Name] If(IsEmpty(RatingStars()),, / ◦ RatingStars())
This will result in:


Where the stars shown are album averages.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

Humbledore

  • Galactic Citizen
  • ****
  • Posts: 269
Re: Album Average Rating
« Reply #6 on: July 26, 2015, 12:47:25 pm »

If that's all you want, you can... Quite easily. In fact, I think it does it by default, but...

Ah, thanks glynor, quite elegant :)  I didn't know there was a RatingStars field...
But what I can notice is that your code snippet isn't able to show half stars at non integer/whole number values. Is it possible as well?
And is it also possible to get a corresponding number/figure value for use in other views, for sorting, filtering and so on?  
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Album Average Rating
« Reply #7 on: July 26, 2015, 12:54:39 pm »

Read my last post, I believe it's all there....

Logged

Humbledore

  • Galactic Citizen
  • ****
  • Posts: 269
Re: Album Average Rating
« Reply #8 on: July 26, 2015, 01:05:46 pm »

Read my last post, I believe it's all there....

Thanks ferday!
I'll maybe give it a try later on although I probably will discover it's a little too tricky/time consuming for me to get into that much of code right now...
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Album Average Rating
« Reply #9 on: July 26, 2015, 01:34:29 pm »

And is it also possible to get a corresponding number/figure value for use in other views, for sorting, filtering and so on?  

Categories automatically average Ratings (and other fields) when the results are essentially "(Varies)" (otherwise, they'd always say "Varies" which isn't very useful).  When used or displayed within a Category, some fields sum (like [Track #], for example) and some show averages.

If you wanted to show a number, you could just use the raw [Rating] field like this:
Code: [Select]
[Name]
[Track #] Tracks If(IsEmpty(RatingStars()),, / ◦ RatingStars() [Rating])


If you switch the Categories List Style from Thumbnails to Details, you can display all sorts of statistics:

Click to embiggen.


But, if you want to use them on any single-file entry, rather than a Category, then you have to calculate them yourself as described above.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

Humbledore

  • Galactic Citizen
  • ****
  • Posts: 269
Re: Album Average Rating
« Reply #10 on: July 26, 2015, 01:46:49 pm »

Categories automatically average Ratings (and other fields) when the results are essentially "(Varies)" (otherwise, they'd always say "Varies" which isn't very useful).  When used or displayed within a Category, some fields sum (like [Track #], for example) and some show averages.

Thanks glynor, I take a look at this after my holiday!
Logged

Humbledore

  • Galactic Citizen
  • ****
  • Posts: 269
Re: Album Average Rating
« Reply #11 on: July 28, 2015, 10:12:39 am »

My guess (haven't had time to test) is replace the iscompare(load(v...),>,0) with !isempty(load(v...),1)

The compare is asking for it to be greater than 0, the !isempty(n,1) is testing for NOT (0 or empty)

Edit: reading his expression above, it looks like non-rated gets a -1 rather than an empty.  If this is true you'll have to test for !iscompare(load(v...),<=,0) this means if NOT less than or equal to zero

I postponed my holiday, bad weather... So then I gave the code a try, but unfortunately, I cannot exclude non rated tracks from the average calculation, I don't get it right. I believe I need help with the exact syntax for this to work (and for me to understand a bit more of the expression language)...
Thanks!
Logged

DoubtingThomas

  • Citizen of the Universe
  • *****
  • Posts: 564
Re: Album Average Rating
« Reply #12 on: July 28, 2015, 12:20:05 pm »

Just make it more difficult.... simply averaging the track ratings to come up with an album rating is not really accurate, the time of the track must be considered.
Logged

Humbledore

  • Galactic Citizen
  • ****
  • Posts: 269
Re: Album Average Rating
« Reply #13 on: July 28, 2015, 04:44:57 pm »

Just make it more difficult.... simply averaging the track ratings to come up with an album rating is not really accurate, the time of the track must be considered.

Good point, but I think that is more a matter of preferences and the principal of the evaluation. For me the time of a track is of secondary/minor importance and can simply be ignored, at least in general.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8009
Re: Album Average Rating
« Reply #14 on: July 28, 2015, 06:21:15 pm »

I've hacked on this a little and I think I've got it doing Album Rating as an average of only those tracks that have a rating.  So if you have 10 tracks and only 2 are rated, in only considers the ratings from those 2 tracks.  Here's the smartlist definition:

Code: [Select]
[Media Type]=[Audio]
[=save(0,v_albumratingsum[album artist (auto)][album])1]=1
[=if(compare([rating],>,0),save(math([rating]+load(v_albumratingsum[album artist (auto)][album])),v_albumratingsum[album artist (auto)][album]),)1]=1
[=save(0,v_rated_tracks[album artist (auto)][album])1]=1
[=if(compare([rating],>,0),save(math(1+load(v_rated_tracks[album artist (auto)][album])),v_rated_tracks[album artist (auto)][album]),)1]=1
~sort=[Album Artist (auto)],[Album],[Track #],[Media Type],[Disc #],[Name]

...and the Expression Column for Album Rating:

Code: [Select]
formatnumber(math( load(v_albumratingsum[album artist (auto)][album]) / load(v_rated_tracks[album artist (auto)][album]) ),2)
Give it a try and let me know how it works.

Brian.
Logged

Humbledore

  • Galactic Citizen
  • ****
  • Posts: 269
Re: Album Average Rating
« Reply #15 on: July 29, 2015, 09:26:28 am »

I've hacked on this a little and I think I've got it doing Album Rating as an average of only those tracks that have a rating.  So if you have 10 tracks and only 2 are rated, in only considers the ratings from those 2 tracks.

Brilliant, it's working! :D  I just modified the calculation to round off to one digit instead of two.
Thanks a lot blgentry!
Logged

zeltak

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 478
Re: Album Average Rating
« Reply #16 on: October 29, 2018, 02:54:52 am »

Give it a try and let me know how it works.

Brian.

it works great for me! one question though. is there a way to make it factor '0' values somehow. seems to me now a 2 "4" star album with many '0' starts still gets a 4 while i want it to me much lower rated :D

thx
Z
Logged
Pages: [1]   Go Up