svm

ValueError: X has 3 features, but LinearSVC is expecting 64852 features as input

ValueError: X has 3 features, but LinearSVC is expecting 64852 features as input Question: I get the following error when I try to deploy this model. ValueError: X has 3 features, but LinearSVC is expecting 64852 features as input Example of data below. data = [[3409, False, ‘Lorum Ipsum’], [0409, True, ‘dolor sit amet consectetuer’], …

Total answers: 1

Error while doing SVR for multiple outputs

Error while doing SVR for multiple outputs Question: Trying to do SVR for multiple outputs. Started by hyper-parameter tuning which worked for me. Now I want to create the model using the optimum parameters but I am getting an error. How to fix this? from sklearn.svm import SVR from sklearn.model_selection import GridSearchCV from sklearn.multioutput import …

Total answers: 1

SVC text classification- TypeError: unhashable type: 'csr_matrix'

SVC text classification- TypeError: unhashable type: 'csr_matrix' Question: I’m quite new in the world of machine learning. I’m trying to build a SVC text classifier. However, when I try to do a single prediction I get the error: unhashable type: ‘csr_matrix’. I’m not sure why this is happening. The objective is to make a binary …

Total answers: 1

How to perform hyper-paramter tunning for SVC?

How to perform hyper-paramter tunning for SVC? Question: I am trying to perform hyper-parameter tuning of my model but this error keeps showing error : Invalid parameter svc_c for estimator SVC(). Check the list of available parameters with `estimator.get_params().keys() I am using the following code : param_grid = {‘svc_c’: [5, 10, 100], ‘svc_gamma’: [1,0.1,0.01,0.001], ‘svc_dgree’: …

Total answers: 2

Classification Model's parameters produce different results

Classification Model's parameters produce different results Question: I’m working on SVC model for classification and I faced different accuracy result in each time I changed the values of the parameters (svc__gamma, svc__kernel and svc__C), I read the documentation of Sklearn but I could not understand what those parameters mean, I have Three questions : What …

Total answers: 1

SVM bad input shape

SVM bad input shape Question: I created a dataset and split it into train and test sets. from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size = 0.20) When I tried to implement a SVM classifier with the code below: from sklearn.svm import SVC svc_classifier = SVC(kernel=’rbf’) svc_classifier.fit(X_train, y_train) X_train.shape and y_train.shape …

Total answers: 1

SVC python output showing the same value of "1" for every C or gamma used

SVC python output showing the same value of "1" for every C or gamma used Question: This is the code: import numpy as np from sklearn import svm numere=np.fromfile("sat.trn",dtype=int,count=-1,sep=" ") numereTest=np.fromfile("sat.tst",dtype=int,count=-1,sep=" ") numere=numere.reshape(int(len(numere)/37),37) numereTest=numereTest.reshape(int(len(numereTest)/37),37) etichete=numere[0:int(len(numere)),36] eticheteTest=numereTest[0:int(len(numereTest)),36] numere=np.delete(numere,36,1) numereTest=np.delete(numereTest,36,1) clf=svm.SVC(kernel=’rbf’,C=1,gamma=1) clf.fit(numere,etichete) predictie=clf.predict(numereTest) I took the data from a file that has it all and then I …

Total answers: 1

Implementation of Okapi BM25 in python

Implementation of Okapi BM25 in python Question: I am trying to implement Okapi BM25 in python. While I have seen some tutorials how to do it, it seems I am stuck in the process. So I have collection of documents (and has as columns ‘id’ and ‘text’) and queries (and has as columns ‘id’ and …

Total answers: 2

Error in running SVM and Logistic Regression in python

Error in running SVM and Logistic Regression in python Question: I am trying to tune the parameter between the SVM, Logistic regression, MLP and Random forest regression in the python but it shows a value error for SVM and logistic regression. my sample data is this: Wavelength Phase_velocity Shear_wave_velocity 1.50 202.69 240.73 1.68 192.72 240.73 …

Total answers: 1

Building an SVM with Tensorflow

Building an SVM with Tensorflow Question: I currently have two numpy arrays: X – (157, 128) – 157 sets of 128 features Y – (157) – classifications of the feature sets This is the code I have written to attempt to build a linear classification model of these features. First of all I adapted the …

Total answers: 2