![]() ~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in inner_f(*args, **kwargs)ħ2 kwargs.update() ~\Anaconda3\lib\site-packages\sklearn\base.py in _validate_data(self, X, y, reset, validate_separately, **check_params) ~\Anaconda3\lib\site-packages\sklearn\svm\_base.py in fit(self, X, y, sample_weight)ġ60 X, y = self._validate_data(X, y, dtype=np.float64, > 4 svcModel.fit(trainInput, trainOutput)ĥ y_train_pred = svcModel.predict(trainInput)Ħ y_test_pred = svcModel.predict(testInput) in fitness_function(posi, trainInput, trainOutput, testInput, testOutput)Ģ 3 svcModel = svm.SVC(kernel= ' rbf', C = posi, gamma = ' auto' ) > 57 fitness=objf(pos,trainInput,trainOutput, testInput, testOutput) in PSO(objf, lb, ub, dim, PopSize, iters, trainInput, trainOutput, testInput, testOutput)ĥ6 #Calculate objective function for each particle > 2 x = PSO(fitness_function,lb=lb,ub=ub,dim= 1,PopSize= 25,iters= 100,trainInput=x_train,trainOutput=y_train, testInput = x_test, testOutput = y_test) ValueError Traceback (most recent call last) X = PSO(fitness_function,lb=lb,ub=ub,dim= 1,PopSize= 25,iters= 100,trainInput=x_train,trainOutput=y_train, testInput = x_test, testOutput = y_test) Print( " the vale of c is" + str(svcModel.C) + " and gamma is" + str(svcModel.gamma)) Y_test_pred = svcModel.predict(testInput)Īcc = metrics.accuracy_score(testOutput, y_test_pred) Y_train_pred = svcModel.predict(trainInput) SvcModel = svm.SVC(kernel= ' rbf', C = posi, gamma = ' auto' ) ![]() Print ( " the individual is" + str(s.bestIndividual))ĭef fitness_function(posi,trainInput,trainOutput, testInput, testOutput): #Calculate objective function for each particleįitness=objf(pos,trainInput,trainOutput, testInput, testOutput) ![]() Print( " PSO is optimizing \""+objf._name_+ " \"") Pos=(np.random.uniform( 0, 1,(PopSize,dim)))*list(np.array(ub) - np.array(lb))+lb Tvec = TfidfVectorizer(stop_words= ' english',max_features= 10000)ĭef PSO(objf,lb,ub,dim,PopSize,iters,trainInput,trainOutput, testInput, testOutput): X_train, x_test, y_train, y_test = train_test_split(x,y, test_size= 0. From sklearn.model_selection import train_test_split
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |