GithubHelp home page GithubHelp logo

alteryx / alteryxpredictive Goto Github PK

View Code? Open in Web Editor NEW
15.0 6.0 15.0 610 KB

This is an R package containing utility functions used by the predictive tools in Alteryx.

License: GNU General Public License v3.0

R 100.00%

alteryxpredictive's Introduction

AlteryxPredictive

Build Status

This is an R package containing utility functions used by the predictive tools in Alteryx.

alteryxpredictive's People

Contributors

btoomey avatar dputler2 avatar kuol avatar piguy314159265 avatar ramnathv avatar tmmorley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

alteryxpredictive's Issues

Update function documentation to roxygen.

Most functions have detailed comments and/or Rd files for documentation. Moving over to roxygen will make it more easily maintainable for us in the long run. I am creating a checklist here so that we can keep track of the task's progress:

  • plotMeans (c2055ce)
  • pipeDelim (f3a283a)
  • matrixPipeDelim (f3a283a)
  • pStars
  • Alteryx.ReportLM
  • Alteryx.ReportGLM
  • Alteryx.ReportAnova
  • Alteryx.ParseCoefSum
  • Alteryx.ParseAnova
  • unitScale
  • bpCent

Document attributes added to model objects

Naive Bayes

the.model$x <- the.data[the.preds]
the.model$y <- the.data[the.target]
the.model$xlevels <- xlevels
the.model$xvars <- the.preds
the.model$yvars <- the.target

Add function to get list of packages to load based on models

This function fetches list of packages to load while dealing with a list of models specified.

#' Load packages based on a set of model classes. 
#' 
#' @param models list of model objects
#' @export
getPkgListForModels <- function(models){
  modelClasses <- unlist(lapply(models, class))
  pkgMap <- list(gbm = "gbm", rpart = "rpart", svm.formula = "e1071", 
    svm = "e1071", naiveBayes = "e1071", svyglm = "survey", 
    nnet.formula = "nnet", randomForest.formula = "randomForest", earth = "earth"
  )
  unique(unlist(pkgMap[modelClasses]))
}

Resolve workarounds

Some workarounds are present in the code that should be refactored:

  • createTreePlotDT.C5.0 assigns the.data to the global namespace to allow plotting functions access

Score Utils might need refactoring

Here is some code abstracted from getXVars, that is repeated in multiple places. It depends heavily on the fact that the final call has the full formula object as opposed to an intermediate variable.

xvars_from_call <- function(x){
  the.call <- x$call  
  the.formula <- as.character(the.call)[2]
  form.split <- unlist(strsplit(the.formula, " ~ "))
  unlist(strsplit(form.split[2], " \\+ "))
}

To better see this, consider the following two calls

Call 1

x1 <- lm(mpg ~ wt + vs, data = mtcars)
xvars_from_call(x1)
# [1] "wt" "vs"

Call 2

f <- mpg ~ wt + vs
x2 <- lm(f, data = mtcars)
xvars_from_call(x2)
# [1] NA

A more robust function that will handle both cases correctly is

xvars_from_call2 <- function(x){
  strsplit(as.character(formula(x))[3], "\\s*\\+\\s*")[[1]]
}
xvars_from_call2(x1) # [1] "wt" "vs"
xvars_from_call2(x2) # [1] "wt" "vs"

Here are some proposed steps to make this change systematically throughout the code base:

  • Clarify expected behavior of this function.
  • Write unit tests, carefully considering edge cases.
  • Identify the above pattern and replace with this function.

Finally, all tools refactored need to ensure that they work with the scoring tools. We can take advantage of the fact that the CrossValidation tool makes heavy use of scoreModel and so can write tests using those.

Namespace MRS functions to pass R CMD Check

Currently, this is the NOTE returned by R CMD Check. Namespacing these functions with the appropriate package name and adding it to Suggests will resolve the issue.

checking R code for possible problems ... NOTE
mrsDataObj: no visible global function definition for ‘RxTeradata’
mrsDataObj: no visible global function definition for ‘RxSqlServerData’
mrsLevels: no visible global function definition for ‘RxInTeradata’
mrsLevels: no visible global function definition for ‘RxInSqlServer’
mrsLevels: no visible global function definition for
  ‘rxSetComputeContext’
mrsLevels: no visible global function definition for ‘rxGetVarInfo’

@dputler can you let me know what package these functions come from? ScaleR maybe?

Installition problem

"replacing previous import by ‘magrittr::%>%’ when loading ‘AlteryxPredictive’"

got this error and can't use serialize func. after that

Automatically create XDF test cases from equivalent open source R test cases.

It should be possible to automate creation of XDF test cases from a test case (list of inputs and config) created for open source R. The basic logic will be to:

  1. Save data frame inputs to appropriately named XDF (admissions -> Extras/Data/admissions.xdf)
  2. Update inputs$XDFInfo to list(is_XDF = TRUE, xdf_path = "Extras/Data/admissions.xdf")
  3. Save updated inputs and config as a test.

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.