R Library

You can use our R API Client to call a subset of API endpoints.

Installing

You can install the SigOptR package directly from CRAN, or you can use the devtools package to grab the latest version from GitHub.

CRAN

Install the SigOptR package directly from CRAN:

install.packages("SigOptR", repos = "http://cran.us.r-project.org")
library(SigOptR)

Latest Version from GitHub

Install the latest SigOptR package from GitHub by using devtools:

install.packages("devtools", repos = "http://cran.us.r-project.org")
library(devtools)
install_github("sigopt/SigOptR")
library(SigOptR)

Setting API token

Sign up for an account at https://sigopt.com. In order to use the API, you’ll need your SIGOPT_API_TOKEN from your user dashboard. Then, put your api token into the R environment variable SIGOPT_API_TOKEN:

Sys.setenv(SIGOPT_API_TOKEN=SIGOPT_API_TOKEN)

Run Some Code

Now, you can run SigOpt's Optimization Loop.

First, setup the experiment:

install.packages("devtools", repos = "http://cran.us.r-project.org")
library(devtools)
install_github("sigopt/SigOptR")
library(SigOptR)
Sys.setenv(SIGOPT_API_TOKEN=SIGOPT_API_TOKEN)


experiment <- create_experiment(list(
  name="Franke Optimization (R)",
  parameters=list(
    list(name="x", type="double", bounds=list(min=0.0, max=1.0)),
    list(name="y", type="double", bounds=list(min=0.0, max=1.0))
  )
))
print(paste(
  "Created experiment: https://sigopt.com/experiment",
  experiment$id,
  sep="/"
))

Then, run the optimization loop itself:

# Evaluate your model with the suggested parameter assignments
# Franke function - http://www.sfu.ca/~ssurjano/franke2d.html
evaluate_model <- function(assignments) {
  return(franke(assignments$x, assignments$y))
}

# Run the Optimization Loop between 10x - 20x the number of parameters
for(i in 1:30) {
  suggestion <- create_suggestion(experiment$id)
  value <- evaluate_model(suggestion$assignments)
  create_observation(experiment$id, list(
    suggestion=suggestion$id,
    value=value
  ))
}

Run More Code: Tune a Random Forest

Learn how to Tune a Random Forest using SigOpt's R API Client. This simple example uses an open source machine learning library and can be extended to tune the hyperparameters of any machine learning model.

More Examples

To see more examples of how to use Sigopt and R to tune machine learning models and more, clone our GitHub examples repository:

git clone https://github.com/sigopt/sigopt-examples.git