blob: 971c0106623bb2828f8d215cede1d74be1bb4ab4 [file] [log] [blame]
#-------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#-------------------------------------------------------------
F = as.frame(read($1));
Y = read($2);
depth = $3;
num_leafs = $4;
num_trees = $5;
impurity = $6;
jspec = "{ids: true, bin: ["
+ "{id: 1, method: equi-width, numbins: 10},"
+ "{id: 2, method: equi-width, numbins: 10},"
+ "{id: 3, method: equi-width, numbins: 10},"
+ "{id: 4, method: equi-width, numbins: 10},"
+ "{id: 5, method: equi-width, numbins: 10},"
+ "{id: 6, method: equi-width, numbins: 10},"
+ "{id: 7, method: equi-width, numbins: 10}]}";
[X,D] = transformencode(target=F, spec=jspec);
R = matrix(1, rows=1, cols=ncol(X)+1);
M = randomForest(X=X, y=Y, ctypes=R, num_trees=num_trees, seed=7,
max_depth=depth, min_leaf=num_leafs, impurity=impurity, verbose=TRUE);
randomForestPredict(X=X, y=Y, ctypes=R, M=M, verbose=TRUE);
write(M, $7);