"A meek endeavor to the triumph" by Sampath Jayarathna

Wednesday, December 30, 2015

[Weka] Attribute Selection/Ranking using Relief Algorithm

Following code snippet will show you how to find attribute ranking of the features from a data set before using in classification applications. I will be using the standard Weka 3.7.13 and the sample data file "weather.numeric.arff" inside your data folder of the Weka. I assume you know how to setup weka.jar files in your development environment.

Attribute means the something as feature in Weka.

This is the content of the sample data file,
@relation weather
@attribute outlook {sunny, overcast, rainy}
@attribute temperature numeric
@attribute humidity numeric
@attribute windy {TRUE, FALSE}
@attribute play {yes, no}
@data
sunny,85,85,FALSE,no
sunny,80,90,TRUE,no
overcast,83,86,FALSE,yes
rainy,70,96,FALSE,yes
rainy,68,80,FALSE,yes
rainy,65,70,TRUE,no
overcast,64,65,TRUE,yes
sunny,72,95,FALSE,no
sunny,69,70,FALSE,yes
rainy,75,80,FALSE,yes
sunny,75,70,TRUE,yes
overcast,72,90,TRUE,yes
overcast,81,75,FALSE,yes
rainy,71,91,TRUE,no
To perform attribute selection, three elements are required. One is search method, and the second is evaluation method. Both elements need to be initiated and defined in a container class AttributeSelection. The third element is data. So the general framework of setting up attribute selection is like this:

 public static void main(String[] args) throws Exception {
         // load data
         String workingDirectory = System.getProperty("user.dir");
        String fs = System.getProperty("file.separator");
        String wekadatafile = workingDirectory + fs + "data" + fs + "weather.numeric.arff";
        BufferedReader datafile = readDataFile(wekadatafile);
        Instances data = new Instances(datafile);

         if (data.classIndex() == -1)
                data.setClassIndex(data.numAttributes() - 1);
         useLowLevel(data, wekadatafile);
  }

 /**
   * uses the low level approach
   */
  protected static void useLowLevel(Instances data, String datafile) throws Exception {
         System.out.println("\n3. Low-level");
         AttributeSelection attsel = new AttributeSelection();
         Ranker search = new Ranker();
         ReliefFAttributeEval evals = new ReliefFAttributeEval();
         attsel.setRanking(true);
         attsel.setEvaluator(evals);
         attsel.setSearch(search);
         attsel.SelectAttributes(data);
         // un-comment here to display the results from the ranking
        //System.out.println(attsel.toResultsString());
 
         // expand the ranked attributes so you can find the index, name and weight of the features
         double[][] ranked = attsel.rankedAttributes();
         System.out.println("ranked attributes!!!\n");
         for(int i=0;i<ranked.length;i++){
          System.out.println(" Feature:"+ data.attribute(index).name() +" weight:"+ ranked[i][1]);
         }
  }

Output
3. Low-level
ranked attributes!!!
Feature:outlook weight:0.0548
Feature:humidity weight:0.0113
Feature:windy weight:-0.0024
Feature:temperature weight:-0.0314

The overall setup for attribute selection is clear and intuitive. What's not so obvious is that search methods include ranking and sub-setting methods, and correspondingly, evaluation methods have individual evaluation and subset evaluation. Ranking search can't be used together with a subset evaluator, and vice versa. 

If you are using Subset evaluation methods like CfsSubsetEval, then you need to use Subset search method like GreedyStepwise etc. 
    //CfsSubsetEval eval = new CfsSubsetEval();
    //GreedyStepwise greedySearch = new GreedyStepwise();
    //search.setSearchBackwards(true);
    //attsel.setEvaluator(eval);
    //attsel.setSearch(greedySearch);

Subset Search Methods:
1. BestFirst
2. GreedyStepwise
3. FCBFSearch (ASU)

Subset Evaluation Methods:
1. CfsSubsetEval
2. SymmetricalUncertAttributeSetEval (ASU)

Individual Search Methods:
1. Ranker

Individual Evaluation Methods:
1. CorrelationAttributeEval
2. GainRatioAttributeEval
3. InfoGainAttributeEval
4. OneRAttributeEval
5. PrincipalComponents (used with a Rander search to perform PCA and data transform
6. ReliefFAttributeEval
7. SymmetricalUncertAttributeEval

Monday, December 07, 2015

58th Annual Grammy Awards, Full list of nominations, Award Predictions, Winners

The first batch of nominations for the 58th Annual Grammy Awards was announced at 8:15 a.m. ET on CBS This Morning Monday.

Here's my predictions for the winners of 58th Annual Grammy Awards,

Album of the Year
Alabama Shakes, Sound and Color
Kendrick Lamar, To Pimp a Butterfly
Chris Stapleton, Traveller
Taylor Swift, 1989
The Weekend, Beauty Behind the Madness

Song of the Year
Kendrick Lamar, "Alright"
Taylor Swift, "Blank Space"
Little Big Town, "Girl Crush"
Wiz Kahifa feat. Charlie Puth, "See You Again"
Ed Sheeran, "Thinking Out Loud"

Record of the Year
D'Angelo and the Vanguard, "Really Love"
Mark Ronson feat. Bruno Mars, "Uptown Funk"
Ed Sheeran, "Thinking Out Loud"
Taylor Swift, "Blank Space"
The Weeknd, "Can't Feel my Face"

Best New Artist
Courtney Barnett
James Bay
Sam Hunt
Tori Kelly
Meghan Trainor

Best Pop Duo/Group Performance
Florence + The Machine, " Ship to Wreck"
Maroon 5, "Sugar"
Mark Ronson feat. Bruno Mars, "Uptown Funk"
Taylor Swift feat. Kendrick Lamar, "Bad Blood"
Wiz Khalifa feat. Charlie Puth, "See You Again"

Best Traditional Pop Vocal Album
Tony Bennett & Bill Charlap, The Silver Lining: The Songs of Jerome Kern
Bob Dylan, Shadows in the Night
Josh Groban, Stages
Seth MacFarlane, No One Ever Tells You
Barry Manilow (& Various Artists), My Dream Duets

Best Pop Vocal Album
Kelly Clarkson, Piece by Piece
Florence + The Machine, How Big, How Blue, How Beautiful
Mark Ronson, Uptown Special
Taylor Swift, 1989
James Taylor, Before This World

Best Dance Recording
Above & Beyond feat. Zoë Johnston, :We're All We Need"
The Chemical Brothers, "Go:
Flying Lotus feat. Kendrick Lamar, "Never Catch Me"
Galantis, "Runaway (U & I)"
Skrillex and Diplo With Justin Bieber, "Where Are Ü Now"

Best Rock Performance
Alabama Shakes, "Don't Wanna Fight"
Florence + The Machine,"What Kind Of Man"
Foo Fighters, "Something From Nothing"
Elle King, "Ex's & Oh's"
Wolf Alice, "Moaning Lisa Smile"

Best Alternative Music Album
Alabama Shakes, Sound & Color
Björk, Vulnicura
My Morning Jacket, The Waterfall
Tame Impala, Currents
Wilco, Star Wars

Best Urban Contemporary Album
The Internet, Ego Death
Kehlani, You Should Be Here
Lianne La Havas, Blood
Miguel, Wildheart
The Weeknd, Beauty Behind the Madness

Best Rap Album
J. Cole, 2014 Forest Hills Drive
Dr. Dre, Compton
Drake, If Youre Reading This Its Too Late
Kendrick Lamar, To Pimp a Butterfly
Nicki Minaj, The Pinkprint

Best Country Album
Sam Hunt, Montevallo
Little Big Town, Pain Killer
Ashley Monroe, The Blade
Kacey Musgraves, Pageant Material
Chris Stapleton, Traveller

Best Jazz Instrumental Album
Joey Alexander, My Favorite Things
Terence Blanchard feat. The E-Collective, Breathless
Robert Glasper & The Robert Glasper Trio, Covered: Recorded Live at Capitol Studios
Jimmy Greene, Beautiful Life
John Scofield, Past Present

Best Gospel Album
Karen Clark Sheard, Destined to Win (Live)
Dorinda Clark-Cole, Living It
Tasha Cobbs, One Place Live
Israel & Newbreed, Covered: Alive Is Asia [Live] (Deluxe)
Jonathan McReynolds, Life Music: Stage Two

Best Contemporary Christian Music Album
Jason Crabb, Whatever the Road
Lauren Daigle, How Can It Be
Matt Maher, Saints and Sinners
Tobymac, This Is Not a Test
Chris Tomlin, Love Ran Red

Best Latin Pop Album
Pablo Alborán, Terral
Alex Cuba, Healer
Ricky Martin, A Quien Quiera Escuchar (Deluxe Edition)
Alejandro Sanz, Sirope
Julieta Venegas, Algo Sucede

Best Americana Album
Brandi Carlile, The Firewatcher's Daughter
Emmylou Harris & Rodney Crowell, The Traveling Kind
Jason Isbell, Something More Than Free
The Mavericks, Mono
Punch Brothers, The Phosphorescent Blues

Best Dance/Electronic Album
Caribou, Our Love
The Chemical Brothers, Born in the Echoes
Disclosure, Caracal
Jamie XX, In Colour
Skrillex and Diplo, Skrillex and Diplo Present Jack Ü

Best Contemporary Instrumental Album
Bill Frisell, Guitar in the Space Age!
Wouter Kellerman, Love Language
Marcus Miller, Afrodeezia
Snarky Puppy & Metropole Orkest, Sylva
Kirk Whalum, The Gospel According to Jazz, Chapter IV

Best Metal Performance
August Burns Red, "Identity"
Cirice, "Ghost"
Lamb of God, "512"
Sevendust, "Thank You"
Slipknot, "Custer"

Best Rock Song
Alabama Shakes, "Don't Wanna Fight"
Elle King, "Ex's & Oh's"
James Bay, "Hold Back the River"
Highly Suspect, "Lydia"
Florence + the Machine, "What Kind of Man"

Best Rock Album
James Bay, Chaos and the Calm
Death Cab for Cutie, Kintsugi
Highly Suspect, Mister Asylum
Muse, Drones
Slipknot, .5: The Gray Chapter

Best R&B Performance
Tamar Braxton, "If I Don't Have You"
Andra Day, "Rise Up"
Hiatus Kaiyote, "Breathing Underwater"
Jeremih feat. J. Cole, "Planes"
The Weeknd, "Earned It (Fifty Shades of Grey)"
Best Traditional R&B Performance
Faith Evans, "He Is"
Lalah Hathaway, "Little Ghetto Boy"
Jazmine Sullivan, "Let It Burn"
Tyrese, "Shame"
Charlie Wilson, "My Favorite Part of You"

Best R&B Song
Miguel, "Coffee"
The Weeknd, "Earned It (Fifty Shades of Grey)"
Jazmine Sullivan, "Let It Burn"
D'Angelo and The Vanguard, "Really Love"
Tyrese, "Shame"

Best R&B Album
Leon Bridges, Coming Home
D'Angelo and the Vanguard, Black Messiah
Andra Day, Cheers to the Fall
Jazmine Sullivan, Reality Show
Charlie Wilson, Forever Charlie

Best Rap Performance
J. Cole, "Apparently"
Drake, "Back to Back"
Fetty Wap, "Trap Queen"
Kendrick Lamar, "Alright"
Nicki Minaj feat. Drake & Lil Wayne, "Truffle Butter"
Kanye West feat. Theophilus London, Allan Kingdom & Paul McCartney, "All Day"

Best Rap/Sung Collaboration
Big Sean feat. Kanye West & John Legend, "One Man Can Change the World"
Common & John Legend, "Glory"
Jidenna feat. Roman GianArthur, "Classic Man"
Kendrick Lamar feat. Bilal, Anna Wise & Thundercat, "These Walls"
Nicki Minaj feat. Drake, Lil Wayne & Chris Brown, "Only"

Best Rap Song
Kanye West feat. Theophilus London, Allan Kingdom & Paul McCartney, "All Day"
Kendrick Lamar, "Alright"
Drake, "Energy"
Common & John Legend, "Glory"
Fetty Wap, "Trap Queen"

Best Country Duo/Group Performance
Brothers Osborne, "Stay a Little Longer"
Joey + Rory, "If I Needed You"
Charles Kelley, Dierks Bentley & Eric Paslay, "The Driver"
Little Big Town, "Girl Crush"
Blake Shelton feat. Ashley Monroe, "Lonely Tonight"

Best Country Song
Lee Ann Womack, "Chances Are"
Tim McGraw, "Diamond Rings And Old Barstools"
Little Big Town, "Girl Crush"
Brandy Clark, "Hold My Hand"
Chris Stapleton, "Traveller"

Best Country Solo Performance
Cam, "Burning House"
Chris Stapleton, "Traveller"
Carrie Underwood, "Little Toy Guns"
Keith Urban, "John Cougar, John Deere, John 3:16"
Lee Ann Womack, "Chances Are"

Best Pop Solo Performance
Kelly Clarkson, "Heartbeat Song"
Ellie Goulding, "Love Me Like You Do"
Ed Sheeran, "Thinking Out Loud"
Taylor Swift, "Blank Space"
The Weeknd, "Can't Feel My Face"

Best Compilation Soundtrack for Visual Media
Empire: Season 1
Fifty Shades of Grey
Glen Campbell: I'll Be Me
Pitch Perfect 2
Selma

Best Compilation Soundtrack for Visual Media
The Weeknd, "Earned It (Fifty Shades Of Grey)"
Common & John Legend, "Glory"
Ellie Goulding, "Love Me Like You Do"
Wiz Khalifa feat. Charlie Puth, "See You Again"
Lady Gaga, "Til It Happens to You"

Score Soundtrack for Visual Media
Birdman
The Imitation Game
Interstellar
The Theory of Everything
Whiplash

Best Music Video
A$AP Rocky, "LSD"
The Dead Weather, "I Feel Love"
Kendrick Lamar, "Alright"
Taylor Swift feat. Kendrick Lamar, "Bad Blood"
Pharrell Williams, "Freedom"

Best Music Film
Foo Fighters, Sonic Highways
James Brown, Mr. Dynamite: The Rise of James Brown
Nina Simone, What Happened, Miss Simone
Roger Waters, The Wall
Amy Winehouse, Amy

Best New Age Album
Paul Avgerinos, Grace
Madi Das, Bhakti Without Borders
Catherine Duc, Voyager
Peter Kater, Love
Ron Korb, Asia Beauty

Best Improvised Jazz Solo
Joey Alexander, "Giant Steps"
Christian McBride, "Cherokee"
Donny McCaslin, "Arbiters of Evolution"
Joshua Redman, "Friend or Foe"
John Scofield, "Past Present"

Best Jazz Vocal Album
Karrin Allyson, Many a New Day: Karrin Allyson Sings Rodgers & Hammerstein
Denise Donatelli, Find a Heart
Lorraine Feather, Flirting With Disaster
Jamison Ross, Jamison
Cécile McLorin Salvant, For One to Love

Best Large Jazz Ensemble Album
Gil Evans Project, Lines of Color
Marshall Gilkes & WDR Big Band, Köln
Arturo O'Farrill & The Afro Latin Jazz Orchestra, Cuba: The Conversation Continues
Maria Schneider Orchestra, The Thompson Fields
Patrick Williams, Home Suite Home

Best Latin Jazz Album
Eliane Elias, Made in Brazil
The Rodriguez Brothers, Impromptu
Gonzalo Rubalcaba, Suite Caminos
Wayne Wallace Latin Jazz Quintet, Intercambio
Miguel Zenón, Identities Are Changeable

Best Gospel Performance/Song
Anthony Brown & Group Therapy, "Worth [Live]"
Kirk Franklin, "Wanna Be Happy?"
Travis Greene, "Intentional"
Israel & Newbreed feat. Yolanda Adams, "How Awesome Is Our God [Live]"
Brian Courtney Wilson, "Worth Fighting For [Live]"

Best Contemporary Christian Music Performance/Song
Francesca Battistelli, "Holy Spirit"
Crowder, "Lift Your Head Weary Sinner (Chains)"
Matt Maher, "Because He Lives (Amen)"
Third Day feat. All Sons & Daughters, "Soul on Fire"
Tobymac feat. Mr. Talkbox, "Feel It"