UserWarning: The priors do not sum to 1. Renormalizing [python] -


all needed modules code below imported

date = [] usage = []  date = genfromtxt(‘date.csv’) usage = genfromtxt(‘usage.csv’) test = genfromtxt(‘test.csv’)  print (len(date))  print (len(usage))  dataframe = pd.dataframe({ ‘date’: (date), ‘usage’: (usage) }) 

drop nan data

dataframe = dataframe.dropna() print (dataframe)  df = dataframe.drop(dataframe.index[[-1,-4]])  array = df.values  x = array[:,0:1] y = array[:,1]  validation_size = 0.20 seed = 7  x_train, x_validation, y_train, y_validation =            model_selection.train_test_split(x, y, test_size=validation_size, random_state=seed)  seed = 7 scoring = ‘accuracy’ 

spot check algorithms

models = [] models.append((‘lr’, logisticregression())) models.append((‘lda’, lineardiscriminantanalysis())) models.append((‘knn’, kneighborsclassifier())) models.append((‘cart’, decisiontreeclassifier())) models.append((‘nb’, gaussiannb())) models.append((‘svm’, svc())) 

evaluate each model in turn

results = [] names = [] name, model in models: kfold = model_selection.kfold(n_splits=10, random_state=seed) cv_results = model_selection.cross_val_score(model, x_train, y_train,           cv=kfold, scoring=scoring) results.append(cv_results) names.append(name) msg = “%s: %f (%f)” % (name, cv_results.mean(), cv_results.std()) print(msg) 

compare algorithms

fig = plt.figure() fig.suptitle(‘algorithm comparison’) ax = fig.add_subplot(111) plt.boxplot(results) ax.set_xticklabels(names) plt.show() 

error message :

1.userwarning: priors not sum 1. renormalizing userwarning) traceback (most recent call last):

file “data_0.py”, line 111, in 

2.the line error shows up:

cv_results = model_selection.cross_val_score(model, x_train, y_train,cv=kfold, scoring=scoring)  file “/users/nelsondsouza/anaconda/lib/python2.7/sitepackages/sklearn/model_selection/_validation.py”, line 140,          in cross_val_score train, test in cv_iter)  file “/users/nelsondsouza/anaconda/lib/python2.7/sitepackages/sklearn/externals/joblib/parallel.py”, line 758,          in __call__ while self.dispatch_one_batch(iterator):  file “/users/nelsondsouza/anaconda/lib/python2.7/sitepackages/sklearn/externals/joblib/parallel.py”, line 608,          in dispatch_one_batch self._dispatch(tasks)  file “/users/nelsondsouza/anaconda/lib/python2.7/sitepackages/sklearn/externals/joblib/parallel.py”, line 571,          in _dispatch job = self._backend.apply_async(batch, callback=cb)  file “/users/nelsondsouza/anaconda/lib/python2.7/sitepackages/sklearn/externals/joblib/_parallel_backends.py”, line 109,          in apply_async result = immediateresult(func)  file “/users/nelsondsouza/anaconda/lib/python2.7/sitepackages/sklearn/externals/joblib/_parallel_backends.py”, line 326,          in __init__ self.results = batch()  file “/users/nelsondsouza/anaconda/lib/python2.7/sitepackages/sklearn/externals/joblib/parallel.py”, line 131,          in __call__ return [func(*args, **kwargs) func, args, kwargs in self.items]  file “/users/nelsondsouza/anaconda/lib/python2.7/sitepackages/sklearn/model_selection/_validation.py”, line 238,          in _fit_and_score estimator.fit(x_train, y_train, **fit_params)  file “/users/nelsondsouza/anaconda/lib/python2.7/sitepackages/sklearn/discriminant_analysis.py”, line 468,          in fit self._solve_svd(x, y)  file “/users/nelsondsouza/anaconda/lib/python2.7/sitepackages/sklearn/discriminant_analysis.py”, line 378,          in solve_svd fac = 1. / (n_samples – n_classes) 

3.zerodivisionerror: float division zero


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -