Guest User

Untitled

a guest
Jul 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #start calculation for task1 iff y=1, otherwise use given prototypes
  2. #zeros(1) is a dummy default, overwrite it!!!
  3. #use y=0 if you want to do classification for task3
  4. def process_calculation(y=1,iter = 3, protos = zeros(1)):
  5. for i in range(iter):
  6. for k in ks:
  7. if y:
  8. protos = kmeans(train_images,k)
  9. plabels = prototype_labels(protos,train_images,train_labels)
  10. picture_protos(protos,i,k)
  11. err,n = errorrate(test_images,test_labels,protos,plabels)
  12. print 'Errorate with k=' + str(k) + ':\t' + str(err/float(n))
Add Comment
Please, Sign In to add comment