2016-05-21 4 views
0

SGDClassifierでデータをモデル化しようとしていますが、何らかの理由で恐ろしい精度が得られます。私はこれには全く新しいので、なぜ私は本当に理解していない。SciKit Learn - Bad SGDClassifierの精度

from sklearn.preprocessing import StandardScaler 
import numpy as np 
from sklearn.linear_model import SGDClassifier 
import numpy as np 
from sklearn import metrics as ms 

msk = np.random.rand(len(beers)) < 0.8 

train = beers[msk] 
test = beers[~msk] 

X = train [['Price', 'Net price', 'Purchase price','Hour','Product_id','product_group2']] 
y = train[['Quantity']] 
y = y.as_matrix().ravel() 

X_test = test [['Price', 'Net price', 'Purchase price','Hour','Product_id','product_group2']] 
y_test = test[['Quantity']] 
y_test = y_test.as_matrix().ravel() 

scaler = StandardScaler() 
scaler.fit(X) 
X = scaler.transform(X) 
X_test = scaler.transform(X_test) 

clf = SGDClassifier(loss="hinge", alpha=0.01, n_iter=1000, fit_intercept=True) 
clf.fit(X, y)  

predictions = clf.predict(X_test) 
print "Accuracy:", ms.accuracy_score(y_test,predictions) 

印刷精度は約0.38である、本当に悪いです:

は、ここに私のコードです。私のデータは次のようになります:

Product_id/Date/product_group1/Price/Net price/Purchase price/Hour/Quantity/product_group2/KPI 
0 107 12/31/2012 10 300 236 220 10 1 108 16 

そして私は200000以上のデータラインを持っています。

他に何をすべきですか?データはスケーリングされているので、問題ではないはずです。また、モデルは1000回の反復後に収束する必要があります。 ありがとうございました!

+0

データを予測するのは難しいかもしれません。あなたは、より高い精度を得ることができると思いますか? – BrenBarn

答えて

1

GridSearchCVを使用して、SGDクラシファイアのパラメータを最適化できます。 sklearn.feature_selectionも参照して、最適な機能をご利用ください。

関連する問題