3 SVM - Jupyter Notebook
3 SVM - Jupyter Notebook
...
In [5]: iris_versicolor
...
In [10]: # training dataset which contains 25 from all 3 datasets by using concat
iris_train = pd.concat([df1,df2,df3])
In [11]: iris_train
...
In [12]: # Dividing the input and output variable for Training Dataset - xtrain and Y trai
X_train = iris_train.iloc[:,0:4]
X_train
y_train = iris_train.iloc[:,4]
y_train
X_train
...
In [13]: # next 25 observation from Setosa dataset
df1 = pd.DataFrame(iris_setosa.iloc[25:50,0:5])
# next 25 observation from Versicolor dataset
df2 = pd.DataFrame(iris_versicolor.iloc[25:50,0:5])
# next 25 observation from Vergenica dataset
df3 = pd.DataFrame(iris_vergenica.iloc[25:50,0:5])
In [15]: iris_test.shape
Out[15]: (75, 5)
...
In [26]: # X_train and X_test are the dataset for training and Testing
#y_train ,y_test are target predictor for Training and Testing Dataset
...
...
In [19]: # Predicting the Test set results by applying on only input variables of
# testind dataset (Xtest)
y_pred = classifier.predict(X_test)
In [20]: y_pred
...
In [22]: y_test
...
In [23]: # Making the Confusion Matrix by validating the predicted and Actual Values
# importing required libraries
from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_pred)
In [24]: cm
[ 0, 24, 1],
[ 0, 3, 22]], dtype=int64)
In [26]: Accuracy_Score
Out[26]: 0.9466666666666667
...
...
...
In [34]: from sklearn.metrics import accuracy_score
Accuracy_Score = accuracy_score(y_test, y_pred1)
In [35]: Accuracy_Score
Out[35]: 0.9333333333333333