Code Monkey home page Code Monkey logo

genetic-algorithm-feature-selection's Introduction

Feature Selection using Genetic Algorithms in R

This script select the 'best' subset of variables based on genetic algorithms in R.

It uses a custom fitness function for binary-class classification. Please modify it to use in other scenarios.

This sctipt is realated to the blog post: Feature Selection using Genetic Algorithms in R.

How to run the example?

The code is ready to calculate the best subset for a cancer dataset (data_breast_cancer2.csv), included in the repo. This is in var_sel_gen_alg.R.

The initial data preparation removes the NA, and it converts the target variable (data_y) into a factor in order to create the predictive model. Both are conditions for the Random Forest that is built behind, using caret package.

You can find how the predictive model is created in the function get_roc_metric, inside the lib_ga.R file. And it is, as the name suggests, prepared for a binary classification problem.

My suggestion before applying with your data is, use the function get_roc_metric directly with your current dataset, and see if it ends ok. If so, proceed to apply the GA procedure.

My idea was to encapsulate the fitness function so you can adjust it better for your purposes. For example, if you want to return Kappa statistic (multi-class target), or RMSE (regression-target). You have to replace get_roc_metric function.

--

Feel free to share your insights, have fun!

Twitter

genetic-algorithm-feature-selection's People

Contributors

pablo14 avatar sambrista 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.