# how is the affect of ordering the features in perceptron?

I Have 2 linearly separable classes and I have performed a simple perceptron for finding the classifier's threshold.

Since in simple perceptron I used all missclassified points in every iteration of algorithm I was wondering if :

1. does the order of accounting points affect the out put threshold line?
2. does the order of accounting points affect the number of iterations needed to achieve the line?
• What is your perceptron learning rule? – user31264 Dec 4 '14 at 0:36
• @user31264: w(n+1) = w + delta *sum(missclassified points * class label) – Shirin Feiz Dec 4 '14 at 19:45

Yes to both questions. You should experiment with a small example if you want to see this happening. Here is an example of a perceptron in R:

fit <- function(dat, y, w){

# dat a n x 2 matrix of data points
# y an n-vector of 0/1 classifications
# w starting weight vector

counter <- 0 # count number of iterations
error <- 100
n <- nrow(dat)

while (error > 0){
error <- 0
for (i in 1:n){
fitted <- sum(w*dat[i,]) > 0
if (fitted != y[i]){
error <- error + 1
}
w <- w + (y[i] - fitted)*dat[i,]
}
counter <- counter + 1
}
print(w) # final value of w
print(counter) # number of iterations through data set until convergence
}


You can try creating a small data set to classify:

dat <- matrix(c(1,1,2,2,2,1,1,0), nc=2)
y <- c(1, 1, 0, 0) # true classes
w <- c(0, 0) # weights


Classify it:

> fit(dat, y, w)
[1] -2  3
[1] 5
> z <- c(3, 2, 1, 4) # re-order data
> fit(dat[z, ], y[z], w)
[1] -1  2
[1] 4


You can see that it reaches a different solution and takes a different number of iterations to do so.

• Thank you for your answer.The algorithm that you have used is revised version of perceptron in reward and punishment manner (theodoridis page 99). The algorithm which I am using considers following learning rule in every iteration: w(n+1) = w + delta *sum(missclassified points * class label) where I have used constant delta =1 – Shirin Feiz Dec 4 '14 at 19:45