Giter Club home page Giter Club logo

binnr2's Introduction

binnr2

Refactoring binnr to S4. S4 provides multiple dispatch and a more rigorous class definition system. This allows different functions to be called based on multiple input arguments and not just the first one.

Otherwise, the main functionality is the same. The underlying "engine" is very different however. Binnr2 uses the same storage mechanism for both discrete and continuous variables which makes the rest of the code easier to create, update, and maintain. It is also a lot easier to reason about.

How to use

library(binnr2)

data(titanic)

# bin the data (notice the capital 'B')
# monotonicity and exceptions apply globally now
bins <- Bin(titanic[,-1] titanic[,1], mono=2, exceptions=-1)

# adjust the bins interactively
# press 'h' for list of commands -- not all of them are re-implemented
bins <- adjust(bins) 

# get a summary
# this takes longer because of the new underlying engine
su <- summary(bins

# fit the model
# uses the input dataset to fit, can pass new data
mod <- fit(bins)

# predict the score
scr.dev <- predict(mod)

# ... and on newdata
scr.val <- predict(mod, newdata = head(titanic))

# predict other things, too
woe <- predict(bins, type="woe")

predict(bins, type="bins")

Advanced usage

Binnr2 also support segmented bins and models. These can be created, adjust, and fit in the same way.


# created segmented bins by Sex
bins <- Bin(titanic[,-1], titanic[,1], seg=titanic$Sex)

# this will prompt a choice of which segment
bins <- adjust(bins)

# fit all segments using LASSO
mods <- fit(bins)

# predict using dev data 
scr <- predict(mods)

# or on new data -- requires segment to be passed
scr.new <- predict(mods, head(titanic), seg=head(titanic$Sex))

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.