Startup Hire
2015-12-28 10:38:48 UTC
Hi all,
Hope you are doing well.
I am working on fine tuning the following parameters in SGD Classifier
which I am using inside OneVsRest Classifier.
I am using GridSearch to use the same.
I have following questions:
1. How to use GridSearch to optimize OneVsRest Classifier?
2. Any reason why the below code does not work? Error is bad input shape
though the classifier.fit works find separately!
from sklearn.grid_search import GridSearchCV
# Set the parameters by cross-validation
tuned_parameters = [{'alpha': [0.001, 0.01,0.1,0.5] ,
'penalty': ['l1','l2','elasticnet'],
'loss':['log','modified_huber']}]
scores = ['precision', 'recall']
for score in scores:
print("# Tuning hyper-parameters for %s" % score)
print()
clf =
GridSearchCV(SGDClassifier(random_state=0,learning_rate='optimal',class_weight='auto',n_iter=100),
tuned_parameters, cv=5,
scoring='%s_weighted' % score)
clf.fit(Finaldata, y)
print("Best parameters set found on development set:")
print()
print(clf.best_params_)
print()
Regards,
Sanant
Hope you are doing well.
I am working on fine tuning the following parameters in SGD Classifier
which I am using inside OneVsRest Classifier.
I am using GridSearch to use the same.
I have following questions:
1. How to use GridSearch to optimize OneVsRest Classifier?
2. Any reason why the below code does not work? Error is bad input shape
though the classifier.fit works find separately!
from sklearn.grid_search import GridSearchCV
# Set the parameters by cross-validation
tuned_parameters = [{'alpha': [0.001, 0.01,0.1,0.5] ,
'penalty': ['l1','l2','elasticnet'],
'loss':['log','modified_huber']}]
scores = ['precision', 'recall']
for score in scores:
print("# Tuning hyper-parameters for %s" % score)
print()
clf =
GridSearchCV(SGDClassifier(random_state=0,learning_rate='optimal',class_weight='auto',n_iter=100),
tuned_parameters, cv=5,
scoring='%s_weighted' % score)
clf.fit(Finaldata, y)
print("Best parameters set found on development set:")
print()
print(clf.best_params_)
print()
Regards,
Sanant