<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rflow [
<!ENTITY lt "&#38;#60;">
<!ENTITY gt "&#62;">
<!ENTITY amp "&#38;#38;">
<!ENTITY apos "&#39;">
<!ENTITY quot "&#34;">
]>
<rflow>
	<graph version="0.9" width="929" height="335" locationtype="a" offsetx="50" offsety="30">
		<setting>
			<entry key="USE_GRID">true</entry>
			<entry key="FOLDER">Edit_an_Analysis_Flow</entry>
			<entry key="GRID_DISTANCE2">10</entry>
		</setting>
<properties>
<v key="packages"/>
</properties>
		<node id="0" date="1449224331060" uid="a391148b23990a1a" x="-20" y="270">
			<command></command>
			<packages/>
			<property/>
			<option type="com.ef_prime.rflow.node.base.CommentNodeModel">
				<entry key="state">opened</entry>
				<entry key="comment">You can change the name of a node by the &quot;Property&quot; tab below.

A node can be opened in a tab by double-clicking on it.
Ctrl + W shortcut is a convinient way to close a tab.
(Command + W on Mac)</entry>
			</option>
		</node>
		<node id="1" date="1449224168173" uid="66e89f087d7c48c7" x="210" y="210">
			<command>test[[&quot;Predict&quot;]] &lt;- (function(object){
	if (inherits(object, &quot;nnet&quot;)) {
		requireNamespace(&quot;nnet&quot;)
	}
	
	if (inherits(object, &quot;xgb.Booster&quot;)) {
		requireNamespace(&quot;xgboost&quot;)
	}
	
	if (inherits(object, c(&quot;glmnet&quot;, &quot;cv.glmnet&quot;))) {
		requireNamespace(&quot;glmnet&quot;)
	}
	
	if (inherits(object, &quot;rpart&quot;) &amp;&amp; object$method == &quot;class&quot; &amp;&amp; !is.null(attr(object, &quot;ylevels&quot;))) {
		attr(object, &quot;ylevels&quot;) &lt;- attr(object, &quot;ylevels&quot;)[seq_len(object$numresp-2)]
	}
	
	cl &lt;- bquote(predict(object = .(object)))
	
	if (inherits(object, &quot;ranger&quot;)) {
		requireNamespace(&quot;ranger&quot;)
		cl$data &lt;- quote(test)
	} else if (inherits(object, c(&quot;xgb.Booster&quot;, &quot;glmnet&quot;, &quot;cv.glmnet&quot;))) {
		if(!is.null(attr(object, &quot;_rflow_&quot;))) {
			bq &lt;- bquote(local({
				att &lt;- attr(.(object), &quot;_rflow_&quot;)
				mt &lt;- delete.response(att$terms)
				mf &lt;- model.frame(mt, test, na.action = na.pass, xlev = att$xlevels)
				model.matrix(mt, mf)
			}))
			if(inherits(object, &quot;xgb.Booster&quot;)) {
				cl$newdata &lt;- bq
				cl$reshape &lt;- TRUE
			} else if (inherits(object, c(&quot;glmnet&quot;, &quot;cv.glmnet&quot;))) {
				cl$newx &lt;- bq
			}
		}
	} else {
		cl$newdata &lt;- quote(test)
	}
	if (!(&quot;type&quot; %in% names(cl))) {
		if (inherits(object, &quot;glm&quot;)) {
			cl$type &lt;- &quot;response&quot;
		} else if (inherits(object, &quot;multinom&quot;)) {
			# Treat 0/1 or TRUE/FALSE Output as Flag
			cl$type &lt;- if (length(object$lev) == 2 &amp;&amp; (all(object$lev %in% c(&quot;0&quot;, &quot;1&quot;)) || all(object$lev %in% c(&quot;FALSE&quot;, &quot;TRUE&quot;))))
				&quot;probs&quot;
			else
				&quot;class&quot;
		} else if (inherits(object, &quot;rpart&quot;) &amp;&amp; !is.null(object$frame$yval2)) {
			# Treat 0/1 or TRUE/FALSE Output as Flag
			cl$type &lt;- if (length(attr(object, &quot;ylevels&quot;)) == 2 &amp;&amp; (all(attr(object, &quot;ylevels&quot;) %in% c(&quot;0&quot;, &quot;1&quot;)) || all(attr(object, &quot;ylevels&quot;) %in% c(&quot;FALSE&quot;, &quot;TRUE&quot;))))
				&quot;prob&quot;
			else
				&quot;class&quot;
		} else if (inherits(object, &quot;nnet&quot;) &amp;&amp; !is.null(object$lev)) {
			# Treat 0/1 or TRUE/FALSE Output as Flag
			cl$type &lt;- if (length(object$lev) == 2 &amp;&amp; (all(object$lev %in% c(&quot;0&quot;, &quot;1&quot;)) || all(object$lev %in% c(&quot;FALSE&quot;, &quot;TRUE&quot;))))
				&quot;raw&quot;
			else
				&quot;class&quot;
		} else if (inherits(object, c(&quot;glmnet&quot;, &quot;cv.glmnet&quot;))) {
			cl$type &lt;- &quot;response&quot;
			.GLMNET_AUTO_TYPE &lt;- TRUE
		}
	}
	
	pred &lt;- eval.parent(cl)
	
	# Treat 0/1 or TRUE/FALSE Output as Flag
	if (inherits(object, &quot;rpart&quot;) &amp;&amp; !is.null(attr(object, &quot;ylevels&quot;))) {
		if (all(attr(object, &quot;ylevels&quot;) %in% c(&quot;0&quot;, &quot;1&quot;))) pred &lt;- pred[, &quot;1&quot;]
		if (all(attr(object, &quot;ylevels&quot;) %in% c(&quot;FALSE&quot;, &quot;TRUE&quot;))) pred &lt;- pred[, &quot;TRUE&quot;]
	}
	
	if (inherits(object, &quot;nnet&quot;)) {
		if(length(object$lev) == 2 &amp;&amp; is.numeric(pred)) {
			# Treat 0/1 or TRUE/FALSE Output as Flag
			if(all(object$lev %in% c(&quot;0&quot;, &quot;1&quot;)) || all(object$lev %in% c(&quot;FALSE&quot;, &quot;TRUE&quot;))) {
				if(object$lev[2] %in% c(&quot;0&quot;, &quot;FALSE&quot;)) pred &lt;- 1 - pred
			} else {
				pred &lt;- cbind(1 - pred, pred)
				colnames(pred) &lt;- object$lev
			}
		} else if(is.character(pred) &amp;&amp; !is.null(object$lev)) {
			pred &lt;- factor(pred, levels = object$lev)
		}
		if (is.matrix(pred) &amp;&amp; ncol(pred) == 1) {
			pred &lt;- as.vector(pred)
		}
	}
	if (inherits(object, &quot;ranger&quot;)) {
		pred &lt;- pred$predictions
		if (!(&quot;type&quot; %in% names(cl)) &amp;&amp; object$treetype == &quot;Probability estimation&quot;) {
			# Treat 0/1 or TRUE/FALSE Output as Flag
			if(all(colnames(pred) %in% c(&quot;0&quot;, &quot;1&quot;)) || all(colnames(pred) %in% c(&quot;FALSE&quot;, &quot;TRUE&quot;))) {
				if(any(c(&quot;1&quot;, &quot;TRUE&quot;) %in% colnames(pred))) {
					pred &lt;- pred[, which(colnames(pred) %in% c(&quot;1&quot;, &quot;TRUE&quot;))]
				} else {
					pred &lt;- 1 - pred[, which(colnames(pred) %in% c(&quot;0&quot;, &quot;FALSE&quot;))]
				}
			} else {
				pred &lt;- factor(colnames(pred)[apply(pred, 1, which.max)], levels = object$forest$levels)
			}
		}
	}
	if(inherits(object, &quot;xgb.Booster&quot;) &amp;&amp; length(ylev &lt;- attr(object, &quot;_rflow_&quot;)$ylevels) &gt; 1 &amp;&amp; !any(c(&quot;predleaf&quot;, &quot;predcontrib&quot;) %in% names(cl))) {
		# Treat 0/1 or TRUE/FALSE Output as Flag
		if (all(ylev %in% c(&quot;0&quot;, &quot;1&quot;))) {
			pred &lt;- pred[, ylev == &quot;1&quot;]
		} else if (all(ylev %in% c(&quot;FALSE&quot;, &quot;TRUE&quot;))) {
			pred &lt;- pred[, ylev == &quot;TRUE&quot;]
		} else {
			pred &lt;- factor(ylev[apply(pred, 1, which.max)], levels = ylev)
		}
	}
	if(inherits(object, c(&quot;glmnet&quot;, &quot;cv.glmnet&quot;))) {
		if (is.matrix(pred) &amp;&amp; ncol(pred) == 1) {
			pred &lt;- as.vector(pred)
		} else if(is.array(pred) &amp;&amp; length(dim(pred)) == 3 &amp;&amp; dim(pred)[3] == 1) {
			pred &lt;- pred[, , 1]
		}
	if (exists(&quot;.GLMNET_AUTO_TYPE&quot;) &amp;&amp; is.matrix(pred)) {
		# Treat 0/1 or TRUE/FALSE Output as Flag
		if(all(colnames(pred) %in% c(&quot;0&quot;, &quot;1&quot;)) || all(colnames(pred) %in% c(&quot;FALSE&quot;, &quot;TRUE&quot;))) {
			if(any(c(&quot;1&quot;, &quot;TRUE&quot;) %in% colnames(pred))) {
				pred &lt;- pred[, which(colnames(pred) %in% c(&quot;1&quot;, &quot;TRUE&quot;))]
			} else {
				pred &lt;- 1 - pred[, which(colnames(pred) %in% c(&quot;0&quot;, &quot;FALSE&quot;))]
			}
		} else {
			pred &lt;- factor(colnames(pred)[apply(pred, 1, which.max)], levels = colnames(pred))
		}
	}
	}
	pred
})(object = model)
</command>
			<packages/>
			<property/>
			<option type="com.ef_prime.rflow.node.ui.UINodeModel">
<ui cls="com.ef_prime.rflow.core.app.r.RPredict" version="0.3.1">
<v key="interface">single</v>
<v key="model_object">model</v>
<v key="data">test</v>
<v key="output_type">input</v>
<v key="output_parent">test</v>
<v key="output_parent@auto">false</v>
<v key="append">true</v>
<v key="output">Predict</v>
<v key="output@auto">false</v>
<v key="models"/>
<v key="models_list"/>
<v key="output_prefix">Predict_</v>
<v key="type">class</v>
<v key="auto_flag">true</v>
<v key="advanced"/>
</ui>
			</option>
		</node>
		<node id="2" date="1449218292754" uid="1c85489720dc651d" x="-30" y="-10">
			<command></command>
			<packages/>
			<property/>
			<option type="com.ef_prime.rflow.node.base.CommentNodeModel">
				<entry key="state">opened</entry>
				<entry key="comment">Nodes can be edited in common ways as copy, paste or delete.
Edges can be deleted with right-click menu.
Try editting the following flow.</entry>
			</option>
		</node>
		<node id="3" date="1449224168153" uid="84cf6b2f3755b303" x="120" y="210">
			<command>model &lt;- rpart::rpart(formula = Species ~ ., data = train)
</command>
			<packages>
				<package name="rpart" attach="false"/>
			</packages>
			<property/>
			<option type="com.ef_prime.rflow.node.ui.UINodeModel">
<ui cls="com.ef_prime.rflow.core.app.r.RModeling" version="0.5.2.0">
<v key="interface">single</v>
<v key="data">train</v>
<v key="_output">model</v>
<v key="_output@auto">false</v>
<v key="formula">UI</v>
<v key="formula_text"/>
<v key="formula_object"/>
<v key="formula_y">Species</v>
<v key="formula_x">all</v>
<v key="formula_list"/>
<v key="formula_intercept">true</v>
<v key="models"/>
<v key="method">rpart</v>
<v key="family">binomial</v>
<v key="exclude_intercept">false</v>
<v key="include_interaction">false</v>
<v key="stepwise">false</v>
<v key="stepwise_direction">backward</v>
<v key="lower">false</v>
<v key="lower_formula">UI</v>
<v key="lower_x"/>
<v key="lower_formula_object"/>
<v key="lower_formula_text"/>
<v key="rpart_method"/>
<v key="rpart_auto_pruning">false</v>
<v key="rpart_cp"/>
<v key="rpart_xval"/>
<v key="rpart_minsplit"/>
<v key="rpart_minbucket"/>
<v key="rpart_maxdepth"/>
<v key="nnet_size">3</v>
<v key="nnet_decay"/>
<v key="nnet_maxit"/>
<v key="ranger_mtry"/>
<v key="ranger_num_trees"/>
<v key="ranger_min_node_size"/>
<v key="ranger_importance">"impurity"</v>
<v key="ranger_auto_prob">true</v>
<v key="ranger_classify_binary">true</v>
<v key="xgboost_cv">true</v>
<v key="xgboost_cv_nfolds">5</v>
<v key="xgboost_cv_maxit">50</v>
<v key="xgboost_cv_early_stop">5</v>
<v key="xgboost_nrounds">5</v>
<v key="xgboost_importance">true</v>
<v key="xgboost_max_depth"/>
<v key="xgboost_eta"/>
<v key="glmnet_family"/>
<v key="glmnet_type">grid_search</v>
<v key="append">false</v>
<v key="skip_error">false</v>
<v key="subset_type">include</v>
<v key="subset_logical">AND</v>
<v key="subset_conditions"/>
<v key="weights"/>
<v key="exclude_weight">false</v>
<v key="args_switch">rpart::rpart</v>
<v key="args_lm"/>
<v key="eval">false</v>
<v key="test_data"/>
<v key="eval_output">.eval</v>
<v key="eval_output@auto">true</v>
<v key="eval_type">numeric</v>
<v key="eval_type_auto">true</v>
<v key="eval_sort_result">true</v>
<v key="eval_sort_column">Mean.Squared.Error</v>
<v key="eval_conf_matrix">false</v>
<v key="eval_chart">false</v>
<v key="args_glm"/>
<v key="args_multinom"/>
<v key="args_rpart"/>
<v key="args_rpart.control"/>
<v key="args_nnet"/>
<v key="args_ranger"/>
<v key="args_xgboost"/>
<v key="args_xgboost_cv"/>
<v key="args_glmnet"/>
<v key="args_cv.glmnet"/>
<v key="args_step"/>
</ui>
			</option>
		</node>
		<node id="4" date="1449224168144" uid="b3e75c8efeee28a0" x="30" y="210">
			<command>(function(x){
	smpl &lt;- sample(x = nrow(x), size = 100, replace = FALSE)
	assign(x = &quot;train&quot;, value = x[sort(smpl), , drop = FALSE], pos = parent.frame())
	assign(x = &quot;test&quot;, value = x[-smpl, , drop = FALSE], pos = parent.frame())
})(x = iris)
</command>
			<packages/>
			<property/>
			<option type="com.ef_prime.rflow.node.ui.UINodeModel">
<ui cls="com.ef_prime.rflow.core.app.r.RSampling" version="0.2.0.1">
<v key="data">iris</v>
<v key="output">train</v>
<v key="output@auto">false</v>
<v key="output_remaining">true</v>
<v key="output2">test</v>
<v key="output2@auto">false</v>
<v key="type">random</v>
<v key="keep_order">true</v>
<v key="size">100</v>
<v key="size_type">row</v>
<v key="remove_row_names">false</v>
</ui>
			</option>
		</node>
		<node id="5" date="1449224168151" uid="1417abb685571b6c" x="30" y="110">
			<command>data(iris)
</command>
			<packages/>
			<property/>
			<option type="com.ef_prime.rflow.node.ui.UINodeModel">
<ui cls="com.ef_prime.rflow.core.app.r.RSampleData" version="0.0.0">
<v key="data">iris</v>
<v key="package"/>
</ui>
			</option>
		</node>
		<node id="6" date="1449224168141" uid="e614198cebb3d1d7" x="120" y="80">
			<command>print(lattice::histogram(x = ~ Sepal.Length | Species, data = iris, type = &quot;percent&quot;))
</command>
			<packages>
				<package name="lattice" attach="false"/>
			</packages>
			<property/>
			<option type="com.ef_prime.rflow.node.ui.UINodeModel">
<ui cls="com.ef_prime.rflow.core.app.r.RLatticeHistogram" version="0.1.0">
<v key="data">iris</v>
<v key="variable">Sepal.Length</v>
<v key="conditioning">Species</v>
<v key="nint"/>
<v key="type">"percent"</v>
<v key="main"/>
<v key="sub"/>
<v key="xlab"/>
<v key="xmin"/>
<v key="xmax"/>
<v key="ylab"/>
<v key="ymin"/>
<v key="ymax"/>
<v key="advanced"/>
<v key="subset_type">include</v>
<v key="subset_logical">AND</v>
<v key="subset_conditions"/>
</ui>
			</option>
		</node>
		<node id="7" date="1449224168148" uid="d0daf14b858bfffb" x="300" y="210">
			<command>cross &lt;- xtabs(data = test, formula = ~ Species + Predict)
</command>
			<packages/>
			<property/>
			<option type="com.ef_prime.rflow.node.ui.UINodeModel">
<ui cls="com.ef_prime.rflow.core.app.r.RXTabs" version="0.1.0.1">
<v key="data">test</v>
<v key="_output">cross</v>
<v key="_output@auto">false</v>
<v key="columns">
<row>
<v>Species</v>
</row>
<row>
<v>Predict</v>
</row>
</v>
<v key="type">count</v>
<v key="advanced"/>
</ui>
			</option>
		</node>
		<node id="8" date="1449224168167" uid="e5e63ef2568d1801" x="120" y="140">
			<command>print(lattice::xyplot(x = Sepal.Width ~ Sepal.Length, data = iris, auto.key = list(space = &quot;right&quot;), groups = Species, type = c(&quot;p&quot;, &quot;spline&quot;), par.settings = list(superpose.symbol = list(pch = seq_along(lattice::trellis.par.get(&quot;superpose.symbol&quot;)$pch)))))
</command>
			<packages>
				<package name="lattice" attach="false"/>
			</packages>
			<property/>
			<option type="com.ef_prime.rflow.node.ui.UINodeModel">
<ui cls="com.ef_prime.rflow.core.app.r.RLatticeXYPlot" version="0.2.0">
<v key="data">iris</v>
<v key="x">Sepal.Length</v>
<v key="y">Sepal.Width</v>
<v key="groups">Species</v>
<v key="change_colors">true</v>
<v key="change_points">true</v>
<v key="change_lines">false</v>
<v key="auto.key">RIGHT</v>
<v key="conditioning"/>
<v key="points">true</v>
<v key="lines">false</v>
<v key="line_type">"l"</v>
<v key="sort_by_x">true</v>
<v key="fitted_line">true</v>
<v key="fitted_line_type">"spline"</v>
<v key="grid">false</v>
<v key="grid_type">TRUE</v>
<v key="main"/>
<v key="sub"/>
<v key="xlab"/>
<v key="xmin"/>
<v key="xmax"/>
<v key="x_log_scale"/>
<v key="ylab"/>
<v key="ymin"/>
<v key="ymax"/>
<v key="y_log_scale"/>
<v key="advanced"/>
<v key="subset_type">include</v>
<v key="subset_logical">AND</v>
<v key="subset_conditions"/>
</ui>
			</option>
		</node>
		<edge from="5" to="6"/>
		<edge from="3" to="1"/>
		<edge from="4" to="3"/>
		<edge from="5" to="8"/>
		<edge from="5" to="4"/>
		<edge from="1" to="7"/>
	</graph>
	<task>
		<taskgroup>
			<taskproperty/>
		</taskgroup>
	</task>
</rflow>
