![]() |
#1
|
|||
|
|||
![]()
I am not familiar with libsvm.
I have succeeded to install the libsvm software for Python/windows. However I have not found any good documentation about the functions supported by Libsvm in Python. How to call the different functions, parameters, examples etc. Has anybody found a good tutorial that provides information about libsvm/Python?? I would like to check some very basic question to see if i getting it right. It seems that there are changes in the Python interface. I have seen in the Web some old examples using the following import statement in Python. But I cannot use this import statement (Python 2.73, libsvm 3.12). PHP Code:
PHP Code:
Any help about finding more info is really appreciated |
#2
|
|||
|
|||
![]() Quote:
|
#3
|
|||
|
|||
![]()
Hi !
All you need for this HW is svm_train and a bit svm_predict. So how to use them ? I found that svm_train cant take data from numpy.array, so this is what I do: Code:
with open('features.train') as f: lines=f.read().splitlines() numbers=[] numbers =[[float(e.strip().split()[0]), float(e.strip().split()[1]), float(e.strip().split()[2])] for e in lines] # or same, but with loop # for e in lines: # temp = e.strip().split() # numbers.append([float(temp[0]), float(temp[1]), float(temp[2])]) Y_train=[] X_train=[] for i in range(len(numbers)): Y_train.append(numbers[i][0]) X_train.append({1 : numbers[i][1], 2:numbers[i][2]}) Code:
import svmutil as svm options = 'your options, for example -c 2 -q 3 ...' model = svm.svm_train(Y_train, X_train, options) Code:
p_label, p_acc, p_val = svm.svm_predict(Y_train, X_train, model) Hope this helps. edit: one important note. If you train your model with '-v' parameter (for cross validation) function will not return the Model, but only a float number - 'Cross Validation Accuracy' |
#4
|
|||
|
|||
![]() Quote:
Gamma is not clearly defined in our formula and it is multiplicating the inner product. Are you setting the values 1 to gamma and coeff0 ? Any other parameters that I should pay attention (other than the degree = 2)? |
#5
|
|||
|
|||
![]() Quote:
|
![]() |
Tags |
libsvm, python |
Thread Tools | |
Display Modes | |
|
|