python模块

pickle

import six.moves.cPickle as pickle

a = {'x':[1,3,32], 
     'b':5, }

with open('test.pickle', 'wb') as fp:
    pickle.dump(a, fp)

del a

with open('test.pickle', 'rb') as fp:
    a = pickle.load(fp)

print(a)    

sklearn

from sklearn.linear_model import LogisticRegression
import numpy as np
import pandas as pd

y, x = [2,-3, -3,2], [[1,0,1],  [-1,0.1,-1],[-1,0.5,-1],[1,0,1]]
X = pd.DataFrame(x)
clf2 = LogisticRegression(penalty='l2',C=1.0, max_iter=200).fit(X, y)

clf2.score
xx = clf2.predict_proba(X)
xx[:,1]
posted @ 2015-12-08 10:09  bregman  阅读(284)  评论(0编辑  收藏  举报