Dear Andreas,

thanks for your reply.

Strangely enough, I'm getting different results after loading in the 
model.

Below are my code snippets. The data source is of course identical.
I will investigate it on that issue further, but maybe someone already 
sees a bug in my code.


Cheers & Thanks,
Paul


"
# RF
clf_RF     = 
RandomForestClassifier(compute_importances=True,random_state=0)
clf_RF     = clf_RF.fit(X_train,y_train)
y_predict  = clf_RF.predict(X_test)
accuracy   = clf_RF.score(X_test,y_test)
precision  = precision_score(y_test,y_predict)
recall     = recall_score(y_test,y_predict)
model_file = "clf_RF.descr.pkl"
cPickle.dump(clf_RF,file(model_file,"wb+")
"
==>
acc  0.89
prec 0.45
rec  0.17


"
RF_clf_frompkl = cPickle.load(file("./clf_RF.descr.pkl","rb"))
y_predict_RF   = RF_clf_frompkl.predict(X_test)
accuracy       = RF_clf_frompkl.score(X_test,y_test)
precision      = precision_score(y_test,y_predict_RF)
recall         = recall_score(y_test,y_predict_RF)
"
==>
acc   0.9
prec  0.55
rec   0.2


> 
> Hi Paul.
> Doing the documentation is in the issue tracker, but no-one wrote it yet 
:-/
> The unpickled model should be trained, i.e. it is not necessary to 
re-run fit.
> Running fit again will just forget the old model.
> 
> Hth,
> Andy
> 
> 
> On 01/04/2013 05:19 PM, [email protected] wrote:
> Dear SciKitters, 
> 
> there is one thing I don't understand when cPickling a model. Here 
> is my code to pickle a model: 
> " 
> clf_kNN       = KNeighborsClassifier() 
> clf_kNN       = clf_kNN.fit(dataDescrs_array,dataActs_array) 
> cPickle.dump(clf_kNN,file("clf_kNN.descr.pk","wb+")) 
> " 
> 
> And this is the way to extract the model: 
> " 
> kNN_clf_frompkl = cPickle.load(file("./clf_kNN.descr.pkl","rb")) 
> y_predict = kNN_clf_frompkl.predict(X_test) 
> # 
> kNN_clf_frompkl = kNN_clf_frompkl.fit(X_train,y_train) 
> y_predict2 = kNN_clf_frompkl.predict(X_test) 
> " 
> 
> Is it necessary to run the "fit" step? - in my understanding, 
> "kNN_clf_frompkl" already contains a kNN model. 
> What is the difference between the loaded models with and without 
> the "fit" step? 
> 
> Is there any documentation about cPickling models? The only 
> documentation I found comes from the mailing list. 
> 
> Cheers & Thanks,
> Paul 


This message and any attachment are confidential and may be privileged or 
otherwise protected from disclosure. If you are not the intended recipient, you 
must not copy this message or attachment or disclose the contents to any other 
person. If you have received this transmission in error, please notify the 
sender immediately and delete the message and any attachment from your system. 
Merck KGaA, Darmstadt, Germany and any of its subsidiaries do not accept 
liability for any omissions or errors in this message which may arise as a 
result of E-Mail-transmission or for damages resulting from any unauthorized 
changes of the content of this message and any attachment thereto. Merck KGaA, 
Darmstadt, Germany and any of its subsidiaries do not guarantee that this 
message is free of viruses and does not accept liability for any damages caused 
by any virus transmitted therewith.

Click http://www.merckgroup.com/disclaimer to access the German, French, 
Spanish and Portuguese versions of this disclaimer.
------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to