I'm trying to use SkLearn Bayes classification.
gnb = GaussianNB() gnb.set_params('sigma__0.2') gnb.fit(np.transpose([xn, yn]), y)
But I get:
set_params() takes exactly 1 argument (2 given)
now I try to use this code:
gnb = GaussianNB() arr = np.zeros((len(labs),len(y))) arr.fill(sigma) gnb.set_params(sigma_ = arr)
And get:
ValueError: Invalid parameter sigma_ for estimator GaussianNB
Is it wrong parameter name or value?
set_params(**params)[source] Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as Pipeline ). The latter have parameters of the form <component>__<parameter> so that it's possible to update each component of a nested object.
The fit() method takes the training data as arguments, which can be one array in the case of unsupervised learning, or two arrays in the case of supervised learning.
fit method takes two parameters, the list of points and another list of just y coordinates. X are your data samples, where each row is a datapoint (one sample, a N-dimensional feature vector). y are the datapoint labels, one per datapoint.
Fitting data: the main API implemented by scikit-learn is that of the estimator . An estimator is any object that learns from data; it may be a classification, regression or clustering algorithm or a transformer that extracts/filters useful features from raw data.
I just stumbled upon this, so here is a solution for multiple arguments from a dictionary:
from sklearn import svm params_svm = {"kernel":"rbf", "C":0.1, "gamma":0.1, "class_weight":"auto"} clf = svm.SVC() clf.set_params(**params_svm)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With