File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 1
- # View more python learning tutorial on my Youtube and Youku channel!!!
1
+ # View more python tutorials on my Youtube and Youku channel!!!
2
2
3
3
# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
4
4
# Youku video tutorial: http://i.youku.com/pythontutorial
Original file line number Diff line number Diff line change
1
+ # View more python tutorials on my Youtube and Youku channel!!!
2
+
3
+ # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
4
+ # Youku video tutorial: http://i.youku.com/pythontutorial
5
+
6
+ from sklearn import svm
7
+ from sklearn import datasets
8
+
9
+ clf = svm .SVC ()
10
+ iris = datasets .load_iris ()
11
+ X , y = iris .data , iris .target
12
+ clf .fit (X , y )
13
+
14
+ # method 1: pickle
15
+ import pickle
16
+ # save
17
+ with open ('save/clf.pickle' , 'wb' ) as f :
18
+ pickle .dump (clf , f )
19
+ # restore
20
+ with open ('save/clf.pickle' , 'rb' ) as f :
21
+ clf2 = pickle .load (f )
22
+ print (clf2 .predict (X [0 :1 ]))
23
+
24
+ # method 2: joblib
25
+ from sklearn .externals import joblib
26
+ # Save
27
+ joblib .dump (clf , 'save/clf.pkl' )
28
+ # restore
29
+ clf3 = joblib .load ('save/clf.pkl' )
30
+ print (clf3 .predict (X [0 :1 ]))
You can’t perform that action at this time.
0 commit comments