Code Monkey home page Code Monkey logo

spark-mrmr-feature-selection's Introduction

spark-ml

Machine learning enhancements to Spark MlLib

FeatureSelection based on Maximum-Relevance Minimum-Redundancy (importance of a feature measured by information gain)

Usage:

MrMrFeatureSelection(vectorModelRDD, labelBuckets, featuresBuckets, noRecords)

vectorModelRDD = rdd of LabeledPoint where features are of type DenseVector labelBuckets = type Array[Double] which corresponds to buckets of labels; the first element must be smaller than the minimum value of the label and the last element must be larger than the maximum value of the label featuresBuckets = type Array[Array[Double]] featuresBuckets[i] corresponds to the array of buckets pertaining to feature i (index based on input rdd); same rule as for the labels regarding the first and last element

featureSelection.minimumRedundancyMaximumRelevancy(noDesiredFeatures)

run the feature selection algorithm returns the indices of the features selected

featureSelection.relevancyRedundacyValues returns List[(Double,Int)] where each entry corresponds to a feature selected. Int is the index selected and Double the objective value of the feature upon selection. It is info_gain(feature,labels) - sum(all previously selected features j) info_gain(j,feature)/(number of features previously selected)

Example:

val noRecords = vectorModelRDD.count val labelBuckets:Array[Double] = .... // note: the first and last element must be below the minimum value and above the maximum value, respectively; For example, for a binary case, we need to specify [-1,0,1,2] val featuresBuckets: Array[Array[Double]] = ....

// create the object val featureSelection = new MrMrFeatureSelection(vectorModelRDD, labelBuckets, featuresBuckets, noRecords) val noDesiredFeatures = 30 // the number of desired features

/*

  • this function does all the computations
  • fs contains the indices selected */

val fs:Array[Int] = featureSelection.minimumRedundancyMaximumRelevancy(noDesiredFeatures)

/*

  • fsv contains pairs of (objective function value, index of feature)
  • the objective function value is info_gain(feature,labels) - sum(all previously selected features j)
  •                                                          info_gain(j,feature)/(number of features previously selected)
    

*/

val fsv:List[(Double,Int)] = featureSelection.relevancyRedundacyValues

spark-mrmr-feature-selection's People

Contributors

wxhc3sc6opm8m1hxbomy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.