Coder Social home page Coder Social logo

svm-python's Introduction

SVM-python

The implementation of Support vector machine (SVM) using python-numpy.

Any nation popularly uses banknotes to carry-out financial activities. However, a lot of fake notes are produced in the market without legal sanction, and hinder the development of the enconomy of the world. Thus, it is very important for us to presicely detect the forgery banknotes. In this project, we perform the banknote authentication on public banknote authentication dataset by using support vector machine algorithm. The banknote dataset involves predicting whether a given banknote is authentic given a number of measures taken from a photograph. It contains 1,372 rows with 5 numeric variables. Exhaustive experiments have been conducted using different hyper-parameters for find the best configurations for support vector machine algorithm. We find that the support vector machine can perform well with 100% accuracy on this task.

Banknote authentication dataset

The dataset used for carrying out the experiments is taken from UCI machine learning repository [data_banknote_authentication.txt]. The dataset is owned by Volker Lohweg (University of Applied Sciences). The dataset has a total of 1372 instances. Each instance has five attributes, out of which four attributes are real-valued attributes, and one attribute is a corresponding label. Genuine banknotes labeled as 0, account for 55% of the whole data, and the fake banknotes, represented as 1, account for 45%.

Implementation

We use the Python to implement the support vector machine algorithm. For solving the final objective function, we use the SMO algorithm to find the optimized weights. Unless specified, we train the support vector machine with iterations of 40, C parameter of 0.6, tolerance of 0.001, and conduct a 5-fold cross-validation for each experiment.

Pre-prosessing

Image

As shown in Fig.hist, since each attribute has different means and standard deviations, we apply the linear normalization for better modeling. Moreover, we change labels with 0 to the value -1 for the convenience of the SVM training.

Image

Abalation study of the parameter C

In this subsection, we use the linear kernel to explore the influence of parameter C in a range from 0.001 to 3.0. As shown in Fig.parameter_C, with the increase of the parameter C, the model performance has a upward trend. However, when the value of C is higher than 0.5, the performance does not change too much.

Image

Abalation study of the parameter degree

Although the linear kernel can achieve around 97% accuracy in this task, there exists much room for improvement. Since the linear kernel cannot learn the non-linear correlation of data, we further apply the polynomial kernel to train the model. As shown in Fig.parameter_degree, we perform the ablation for the degree in the polynomial kernel. We conduct the 5-fold cross-validation for the degree with the range from 0.0001 to 10. We can find that we can get the performance gains when increasing the degrees of the polynomial kernel. If the degree is near zero, the performance of recognition decrease rapidly.

Image

Abalation study of the parameter sigma

We use the Gaussian kernel for leanring non-linear representations in the dataset for better performance. Thus, we conduct the ablation study of the parameter sigma in the range from 0.0001 to 10. The ablation is shown in Fig.parameter_sigma, we can find that when using small value of the sigma, the performance is not good and even the accuracy of this configuration is lower than model using linear kernel. Fortunately, when the sigma is higher than 5.0, the model can achive the best performance with accuracy of 100%, F1-score of 1.0, and AUPRC of 1.0, respectively.

svm-python's People

Contributors

longlongaaago avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.