Ex 5 NN Wheat Seed Data
Ex 5 NN Wheat Seed Data
1
195 11.23 12.88 0.8511 5.140 2.795
196 13.20 13.66 0.8883 5.236 3.232
197 11.84 13.21 0.8521 5.175 2.836
198 12.30 13.34 0.8684 5.243 2.974
Asymmetry.Coeff Kernel.Groove
0 2.221 5.220
1 1.018 4.956
2 2.699 4.825
3 2.259 4.805
4 1.355 5.175
.. … …
194 3.631 4.870
195 4.325 5.003
196 8.315 5.056
197 3.598 5.044
198 5.637 5.063
[3]: Type
0 1
1 1
2 1
3 1
4 1
.. …
194 3
195 3
196 3
197 3
198 3
2
0.2 Training the Perceptron Classifier
[5]: # importing Perceptron Class
from sklearn.linear_model import Perceptron
corr = corr.round(2)
corr
3
Area -0.22 0.86 -0.34
Perimeter -0.21 0.89 -0.32
Compactness -0.33 0.23 -0.54
Kernel.Length -0.17 0.93 -0.25
Kernel.Width -0.25 0.75 -0.42
Asymmetry.Coeff 1.00 -0.00 0.57
Kernel.Groove -0.00 1.00 0.04
Type 0.57 0.04 1.00
fig = px.imshow(corr ,
width = 700,
height = 700 ,
text_auto = True,
color_continuous_scale = 'tealgrn',
)
fig.show()
It can be observed that the attribute “Kernel.Groove” has very least correlation on
the target variable
[8]: # remove Kernel.Groove attribute from X
X = X.loc[:, X.columns != 'Kernel.Groove']
X
Asymmetry.Coeff
0 2.221
1 1.018
2 2.699
3 2.259
4 1.355
.. …
4
194 3.631
195 4.325
196 8.315
197 3.598
198 5.637
Processing c:\users\gurram\appdata\local\pip\cache\wheels\7d\42\93\b99bd6392fb56
ec7831a695cb7a23dd9c73382b258614b62ed\scikit_neuralnetwork-0.7-py3-none-any.whl
Processing c:\users\gurram\appdata\local\pip\cache\wheels\a3\72\b6\89bbeb6140ee3
756fa2bdd2fb03003dd60d289851314b35fd7\lasagne-0.1-py3-none-any.whl
Processing c:\users\gurram\appdata\local\pip\cache\wheels\26\68\6f\745330367ce78
22fe0cd863712858151f5723a0a5e322cc144\theano-1.0.5-py3-none-any.whl
Requirement already satisfied: colorama in d:\anaconda\lib\site-packages (from
scikit-neuralnetwork) (0.4.3)
Requirement already satisfied: scikit-learn>=0.17 in
c:\users\gurram\appdata\roaming\python\python37\site-packages (from scikit-
neuralnetwork) (1.0.2)
Requirement already satisfied: numpy in d:\anaconda\lib\site-packages (from
5
Lasagne>=0.1->scikit-neuralnetwork) (1.18.1)
Requirement already satisfied: scipy>=0.14 in
c:\users\gurram\appdata\roaming\python\python37\site-packages (from
Theano>=0.8->scikit-neuralnetwork) (1.7.3)
Requirement already satisfied: six>=1.9.0 in d:\anaconda\lib\site-packages (from
Theano>=0.8->scikit-neuralnetwork) (1.14.0)
Requirement already satisfied: joblib>=0.11 in d:\anaconda\lib\site-packages
(from scikit-learn>=0.17->scikit-neuralnetwork) (0.14.1)
Collecting threadpoolctl>=2.0.0
Downloading threadpoolctl-3.1.0-py3-none-any.whl (14 kB)
Installing collected packages: Lasagne, Theano, scikit-neuralnetwork,
threadpoolctl
Successfully installed Lasagne-0.1 Theano-1.0.5 scikit-neuralnetwork-0.7
threadpoolctl-3.1.0
pred_test = mlp.predict(X_test)
mlp_accuracy = accuracy_score(y_test, pred_test)
print('% of Accuracy using MultiLayer Perceptron: ', "{0:0.2f}".
↪format(mlp_accuracy*100))