GithubHelp home page GithubHelp logo

flipkart-incubator / statreduce Goto Github PK

View Code? Open in Web Editor NEW
1.0 11.0 3.0 208 KB

A library which to write Hadoop MapReduce jobs with map step in Java and reduce step in R for statistical computations

R 1.63% Java 98.37%

statreduce's Introduction

statreduce

statreduce is a library for writing Hadoop mapreduce jobs with map step in Java and reduce step in R for statistical computations. It provides simple abstractions like ListStatReducer and MatrixStatReducer.

ListStatReducer takes a list of int/double as input from map step, converts it to R vector, invokes R function and stores the result.

MatrixStatReducer takes a matrix of int/double as input from map step, converts it to R matrix, invokes R function and stores the result.

To use this library, add statreduce as dependency:

<dependency>
  <groupId>com.fk</groupId>
  <artifactId>statreduce</artifactId>
  <version>0.0.1</version>
</dependency>

For performing statistical operation on a vector of int/double, use ListStatReducer

public class TemperatureSummaryReducer extends ListStatReducer {
    public TemperatureSummaryReducer(){
        super("tempValues", "avgTemp", "", "avgTemp <- mean(tempValues)", Double.class, Double.class);
    }
}

tempValues is the double vector passed to R.

avgTemp <- mean(tempValues) is the function call.

avgTemp is the value returned as Reducer output.

For performing statistical operation on a matrix of int/double, use MatrixStatReducer:

public class MoneyballOnBasePercentageReducer extends MatrixStatReducer {
    public MoneyballOnBasePercentageReducer() {
        super("playerStats", "obp", ScriptUtils.fromFile("/tmp/on_base_percentage.R"),
                "obp <- calculateOBP(playerStats)", Double.class, Double.class);
    }
}

This calculates On-base percentage for baseball players by taking playerStats as input and returning obp as output. R functions can be loaded from files/hdfs/jar.

See MoneyballOnBasePercentageDriver or TemperatureSummaryDriver for usage examples. (Sample data and R functions are in data and functions dir)

statreduce's People

Contributors

sathish316 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

statreduce's Issues

Generate List output from ListStatReducer

ListStatReducer can currently generate only single int/double value as output.
Extend it to generate list of int/double values as output.

For example, If statistical summary for input series is generated as output, it should be possible to emit all values as list of int/double in reducer.

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.