0
$\begingroup$

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?
$\endgroup$
  • $\begingroup$ What is your perceptron learning rule? $\endgroup$ – user31264 Dec 4 '14 at 0:36
  • $\begingroup$ @user31264: w(n+1) = w + delta *sum(missclassified points * class label) $\endgroup$ – Shirin Feiz Dec 4 '14 at 19:45
1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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 $\endgroup$ – Shirin Feiz Dec 4 '14 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.