Code Monkey home page Code Monkey logo

kshitizrohilla / user-purchase-prediction-and-classification-using-support-vector-machine-algorithm Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 75 KB

This project implements the Support Vector Machine (SVM) algorithm for predicting user purchase classification. The goal is to train an SVM classifier to predict whether a user will purchase a particular product or not.

Jupyter Notebook 100.00%
support-vector-classification support-vector-classifier support-vector-machine support-vector-machine-svm support-vector-machines svm svm-classifier svm-kernel svm-model svm-training

user-purchase-prediction-and-classification-using-support-vector-machine-algorithm's Introduction

User Purchase Classification Prediction using SVM

This project implements the Support Vector Machine (SVM) algorithm for predicting user purchase classification. It utilizes the user-data.csv dataset, which contains information about users and their purchase behavior. The goal is to train an SVM classifier to predict whether a user will purchase a particular product or not.

Data Pre-processing Step

The first step in the project is data pre-processing. The user_data.csv file is imported using the Pandas library, and the independent variables (features) and the dependent variable (target) are extracted from the dataset. The dataset is then split into training and test sets using the train_test_split function from the sklearn.model_selection module. Feature scaling is performed using the StandardScaler class from the sklearn.preprocessing module.

SVM Algorithm

The SVM algorithm is implemented using the SVC (Support Vector Classifier) class from the sklearn.svm library. In this project, a linear kernel is used to create the SVM classifier for linearly separable data. The classifier is trained on the training set using the fit method.

Predicting the Test Set Result

The trained SVM classifier is used to predict the output for the test set. The predict method is used to obtain the predicted values, which are stored in the y_pred vector. The predicted values can be compared with the actual values (y_test) to evaluate the performance of the classifier.

Confusion Matrix

The performance of the SVM classifier is evaluated by creating a confusion matrix. The confusion_matrix function from the sklearn.metrics module is used to generate the confusion matrix. It takes the actual values (y_test) and the predicted values (y_pred) as parameters.

Visualizing the Training Set Result

The training set result is visualized using the contourf and scatter functions from the matplotlib.pyplot module. The contourf function is used to create a filled contour plot, representing the decision boundary of the SVM classifier. The scatter function is used to plot the data points, with different colors representing different classes. The plot is labeled with appropriate titles, axis labels, and legends.

Visualizing the Test Set Result

The test set result is visualized in a similar manner as the training set result. The contourf and scatter functions are used to create the filled contour plot and plot the data points, respectively. The plot is labeled with appropriate titles, axis labels, and legends.

Conclusion

The SVM classifier successfully predicts user purchase classification based on the provided dataset. The project demonstrates the use of SVM algorithm for binary classification tasks and provides visualizations of the decision boundary and class separation.

Dependencies

The following Python libraries are used in this project:

  • numpy
  • matplotlib.pyplot
  • pandas
  • sklearn.model_selection
  • sklearn.preprocessing
  • sklearn.svm
  • sklearn.metrics

user-purchase-prediction-and-classification-using-support-vector-machine-algorithm's People

Contributors

kshitizrohilla avatar

Watchers

 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.