Python Sklearn Calculating the membership degree of SVM

Source: Internet
Author: User
Tags svm

the Sklean in Python already integrates the SVM algorithm, It includes fit (), predict (), etc., so we can get the results of the classification by simply inputting the training samples and markers, as well as the model parameters.

There are many implementations of this code, and the SVC parameters are described in:

Detailed Address: Http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC

But for the implementation of LIBSVM in the degree of membership calculation has not found similar explanations and examples, first give the following source code.

Import Numpydata_set = []lab_set = []for k in Range (5):    arr = Numpy.random.random ([30000,45]) for    i in Numpy.arang E (0,30000):        j = i%3        arr[i,k*9+j*3:k*9+j*3+3] = arr[i,k*9+j*3:k*9+j*3+3]+k*0.25    print arr.shape    Data _set.extend (arr)    Tmp_lab = [k]* (arr.shape[0])    lab_set = lab_set+tmp_labimport sklearnfrom SKLEARN.SVM Import SVCCLF = svc (probability=true) Clf.fit (Data_set, Lab_set) SVC (c=1.0, cache_size=200, Class_weight=none, coef0=0.0, Degree=3,    gamma=0.0, kernel= ' RBF ', Max_iter=-1, Probability=true, Random_state=none, Shrinking=true,    tol= 0.001, verbose=false) Pre_lab = clf.predict (data_set) PRE_SCR = Clf.score (data_set,lab_set) print (Pre_lab.shape)


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Python sklearn Calculation of SVM membership

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.