Ticker

6/recent/ticker-posts

Sklearn Prediction Model - SVM (Iris Dataset)

 


In this post, we are gonna make a simple machine learning program using Support Vector Machine(SVM) and implement this model on the Iris dataset. Then we are gonna compare our predictions with the actual data.

We are gonna use machine learning libraries like Sklearn and Pandas.

There's no need to download Iris dataset as its preinstalled in Sklearn. Just store the dataset in any variable. This is the simplest of the Machine Learning program you'll ever see.


Preview:

  import pandas as pd
  import sklearn
  from sklearn import svm
  from sklearn.model_selection import train_test_split
  from sklearn import datasets
  from sklearn.metrics import accuracy_score


  iris= datasets.load_iris()

  # split it into features and labels

  x= iris.data
  y= iris.target

  #split the training and testing data

  x_train, x_test, y_train, y_test= train_test_split(x, y, test_size=0.2)

  #make the model and fit the training data into it
  model=svm.SVC()

  model.fit(x_train, y_train)

  predictions= model.predict(x_test)
  acc= accuracy_score(y_test, predictions)

  print(predictions)
  print(acc)
  print(y_test)

Post a Comment

0 Comments