Ask Your Question
0

Loading a pre-trained KNN classifier - python

asked 2016-02-22 14:16:24 -0600

I know there is a save command for the KNN classifier, that outputs the model in XML.

Is there any corresponding load command to load that model back into python

I am using cv2 3.0.0 and Python 2.7

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
-1

answered 2017-05-23 05:09:05 -0600

alexMm1 gravatar image

This code save an img as xml but should be similar in your case:

import cv2
import numpy as np

img = cv2.cv.LoadImage('0.jpg',0)
cv2.cv.Save('sof.xml',img)
e=cv2.cv.Load("sof.xml")

print e
edit flag offensive delete link more

Comments

deprecated cv2.cv does no more exist in opencv3 (and you must not use it)

berak gravatar imageberak ( 2017-05-23 05:11:37 -0600 )edit

@berak....oops sorry

alexMm1 gravatar imagealexMm1 ( 2017-05-23 05:12:38 -0600 )edit

nvm, it's nice, that you're trying to help ! ;) (it's just not the correct answer. there have been efforts taken for SVM and ANN to add a model = XXX_save() method, unfortunately not for knn.)

berak gravatar imageberak ( 2017-05-23 05:15:10 -0600 )edit

I got the point.....i tought that the method were the same. thanks for your clarification

alexMm1 gravatar imagealexMm1 ( 2017-05-23 05:25:33 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-02-22 14:16:24 -0600

Seen: 630 times

Last updated: May 23 '17