perceptrain: An original perceptron algorithm

Description Usage Arguments Details Value Author(s) Examples

Description

Train data with perceptron algorithm

Usage

1
perceptrain(S, y, alpha_k = 1, endcost = 0)

Arguments

S

Each row represents a data points with last column equal to 1; S=[X,1]

y

Class label for data points in S

alpha_k

The speed of converge

endcost

The termination condition of cost function

Details

S is especially designed for perceptron.

For more information fakedata

Value

z

Normal vector of a hyperplane

Z_history

Trajactory of normal vector of a hyperplane

NumofIteration

Number of iterations for algorithm

Author(s)

Xiaoyao Yang

Examples

1
2
3
4
5
set.seed(1024)
z <- runif(n=3)
mydata <- fakedata(w=z,n=100)
r <- perceptrain(S=mydata$S,y=mydata$y,alpha_k=1,endcost=0)
r

Example output

$z
[1] 19.00000 14.08172 56.54584

$Z_history
  [,1]       [,2]       [,3]
z    1  0.4335301 -0.2182004
z  -47  8.7424575 52.7355557
z   -4  9.7415032 60.6371789
z   15 17.4914799 56.9740857
z   16 16.6390402 56.8670250
z   17 15.7866006 56.7599643
z   18 14.9341609 56.6529036
z   19 14.0817213 56.5458429

$NumofIteration
[1] 8

attr(,"class")
[1] "pt"

freestats documentation built on May 2, 2019, 1:18 p.m.