| #------------------------------------------------------------- |
| # |
| # 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. |
| # |
| #------------------------------------------------------------- |
| |
| findBetas = function(Matrix[double] X, Matrix[double] y) |
| return (Matrix[double] all_betas) |
| { |
| R = matrix(0, rows=10*(ncol(X)+1), cols=5); |
| for (lamda in 20:39) { |
| #betas = multiLogReg(X=X, Y=y, maxii=0, verbose=FALSE); |
| betas = multiLogReg(X=X, Y=y, icpt=2, tol=0.000001, |
| reg=lamda, maxi=100, maxii=0, verbose=FALSE); |
| R[1:ncol(X)+1,] = betas; |
| } |
| all_betas = R; |
| } |
| |
| findIcpt = function(Matrix[double] X, Matrix[double] y) |
| return (Matrix[double] all_betas) |
| { |
| R = matrix(0, rows=12*(ncol(X)+2), cols=5); |
| for (lamda in 20:29) { |
| for (icpt in 1:2) { |
| #Function level reuse of 3 out of 6 calls. |
| betas = multiLogReg(X=X, Y=y, icpt=icpt, tol=0.000001, |
| reg=lamda, maxi=100, maxii=0, verbose=FALSE); |
| #betas = multiLogReg(X=X, Y=y, icpt=icpt, maxii=0, verbose=FALSE); |
| R[1:ncol(X)+1,] = betas; |
| } |
| } |
| all_betas = R; |
| } |
| |
| |
| X = rand(rows=1000, cols=100, sparsity=1.0, seed=42); |
| y = rand(rows=1000, cols=1, min=0, max=6, sparsity=1.0, seed=42); |
| y = floor(y); |
| |
| all_betas1 = findBetas(X, y); |
| all_betas2 = findIcpt(X, y); |
| while(FALSE){} |
| R = rbind(all_betas1, all_betas2); |
| |
| write(R, $1, format="text"); |
| |