prediction: Predicting Function for Linear Model

Description Usage Arguments Details Value See Also Examples

View source: R/gradDescentR.SupportFunctions.R

Description

A function to predict testing data with built gradient descent model

Usage

1
prediction(model, dataTestInput)

Arguments

model

a matrix of coefficients used as a linear model to predict testing data input. This parameter exclusively produced by the gradient-descent-based learning function.

dataTestInput

a data.frame represented dataset with input variables only (m \times n-1), where m is the number of instances and n is the number of input variables only.

Details

This function used to predict testing data with only input variable named dataTestInput. The model parameter is the coefficients that produced by gradient-descent-based learning function. The result of this function is a dataset that contains dataTestInput combined with prediction data as the last column of dataset.

Value

a data.frame of testing data input variables and prediction variables.

See Also

GD, MBGD, SGD, SAGD, MGD, AGD, ADAGRAD, ADADELTA, RMSPROP, ADAM, SSGD, SVRG, SARAH, SARAHPlus

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
##################################
## Predict Testing Data Using GD Model
## load R Package data
data(gradDescentRData)
## get z-factor Data
dataSet <- gradDescentRData$CompressilbilityFactor
## do variance scaling to dataset
featureScalingResult <- varianceScaling(dataSet)
## split dataset
splitedDataSet <- splitData(featureScalingResult$scaledDataSet)
## built model using GD
model <- GD(splitedDataSet$dataTrain)
## separate testing data with input only
dataTestInput <- (splitedDataSet$dataTest)[,1:ncol(splitedDataSet$dataTest)-1]
## predict testing data using GD model
prediction <- prediction(model,dataTestInput)
## show result()
prediction


##################################
## Predict Testing Data Using SARAHPlus Model
## load R Package data
data(gradDescentRData)
## get z-factor Data
dataSet <- gradDescentRData$CompressilbilityFactor
## do variance scaling to dataset
featureScalingResult <- varianceScaling(dataSet)
## split dataset
splitedDataSet <- splitData(featureScalingResult$scaledDataSet)
## built model using SARAHPlus
model <- SARAHPlus(splitedDataSet$dataTrain, alpha=0.1, maxIter=10,
         innerIter=10, gammaS=0.125, seed=NULL)
## separate testing data with input only
dataTestInput <- (splitedDataSet$dataTest)[,1:ncol(splitedDataSet$dataTest)-1]
## predict testing data using GD model
prediction <- prediction(model,dataTestInput)
## show result()
prediction

computer-science-upi/gradDescent documentation built on May 29, 2019, 4:46 a.m.