<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/syberia-a-development-framework-for-r-code-in-production/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2017/06/syberia.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>Putting R code into production generally involves orchestrating the execution of a series of R scripts. Even if much of the application logic is encoded into R packages, a run-time environment typically involves scripts to ingest and prepare data, run the application logic, validate the results, and operationalize the output. Managing those scripts, especially in the face of working with multiple R versions, can be a pain — and worse, very complex scripts are difficult to understand and reuse for future applications.</p>
<p>That's where <a rel="nofollow" href="http://syberia.io/" target="_blank">Syberia</a> comes in: an open-source framework created by Robert Krzyzanowski and other engineers at the consumer lending company Avant. There, Syberia has been used by more than 30 developers to build a production data modeling system. In fact, building production R systems was the <a rel="nofollow" href="http://syberia.io/docs/101.html" target="_blank">motivating tenet of Syberia</a>: </p>
<blockquote>
<p>Developing classifiers using the Syberia modeling engine follows one primary tenet: <strong>development equals production</strong>. When a web developer experiments with a new website layout or feature, they are targeting a <em>production system</em>. After they are satisfied with their work, they push a button and deploy the code base so it is live and others can interact with it.</p>
<p>Feature engineering and statistical modeling … should belong to the same class of work. When an architect designs a skyscraper their work has to be translated to reality through a construction team by replaying the design using a physical medium. This is the current industry standard for machine learning: prototype the model in one language, typically a Python or R &quot;notebook,&quot; and then write it in a &quot;solid production-ready&quot; language so it can survive the harsh winds of the real world.</p>
<p><strong>This is wrong</strong>.</p>
</blockquote>
<p>In much the same way that <a rel="nofollow" href="http://ggplot2.tidyverse.org/" target="_blank">ggplot2</a> is a completely different way of thinking about R graphics, Syberia is a completely different way of thinking about R scripts. It's also similarly difficult to get your head around at first, but once you do, it reveals itself as an elegant and customizable way of managing complex and interconnected R code — and a much better solution than simply <code>source</code>-ing an 800-line R script.</p>
<p>At its core, Syberia defines a set of conventions for defining the steps in a data-analysis workflow, and specifying them with a collection (in real-world projects, a large collection) of small R scripts in a standardized folder structure. Collectively, these define the complete data analysis process, which you can execute with a simple R command: <code>run</code>. To make modifying and maintaining this codebase (which you'd typically manage in a source-code control system) easier, Syberia is designed to isolate dependencies between filew. For example, rather than specifying a file name and format (say, <code>&quot;data.csv&quot;</code>) in a script that reads data, you'd instead define &quot;adapters&quot; to read and write data in the <code>adapters/adapters.R</code> script:</p>
<div>
<pre><span># ./adapters/csv.R</span>
read <span>&lt;-</span> <span>function</span>(key) {
  read.csv(file.path(<span>&quot;/some/path&quot;</span>, paste0(key, <span>&quot;.csv&quot;</span>)))
}

write <span>&lt;-</span> <span>function</span>(value, key) {
  write.csv(value, file.path(<span>&quot;/some/path&quot;</span>, paste0(key, <span>&quot;.csv&quot;</span>)))
}
</pre>
</div>
<p>Syberia will then use those &quot;read&quot; and &quot;write&quot; adapters to connect with your data. That way, when you later decide to source the data from a database, you can just write new adapters rather than trying to find the lines dealing with data I/O in a massive script. (This also helps avoid conflicts when working in a large code-base with multiple developers.) Syberia defines similar &quot;patterns&quot; for data preparation (including feature generation), statistical modeling, and testing; the &quot;run&quot; function conceptually synthesizes the entire codebase into a single R script to run.</p>
<p>Syberia also encourages you to break up your process into a series of distinct steps, each of which can be run (and tested) independently. It also has a <code>make</code>-like feature, in that results from intermediate steps are cached, and do not need to be re-run each time unless their dependencies have been modified.</p>
<p>Syberia can also be used to associate specific R versions with scripts, or even other R engines like Microsoft R. I was extremely impressed when during a 30-minute-break at the R/Finance conference last month, Robert was able to <a rel="nofollow" href="https://github.com/robertzk/MicrosoftR" target="_blank">sketch out a Syberia implementation</a> of a modeling process using the <a rel="nofollow" href="https://msdn.microsoft.com/en-us/microsoft-r/scaler/scaler" target="_blank">RevoScaleR</a> library. In fact Robert's talk from the conference, embedded below, provides a nice introduction to Syberia.</p>
<p><iframe width="450" allowfullscreen="" src="https://channel9.msdn.com/Events/RFinance/RFinance-2017/Syberia-A-development-framework-for-R/player" height="288"></iframe></p>
<p>Syberia is available now under the open-source MIT license. (Note: git is required to install Syberia.) To get started with Syberia check out the <a rel="nofollow" href="http://syberia.io/docs/" target="_blank">documentation</a>, which is available at the Syberia website linked below.</p>
<p>Syberia: <a rel="nofollow" href="http://syberia.io/" target="_blank">The development framework for R</a></p>
</div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://blog.revolutionanalytics.com/2017/06/syberia.html"> Revolutions</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...

	<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/4NcOoVT9mN4" height="1"></a></div>