Lab 03
Lab 03
Lab 03
Instructions
1. In this lab you will use Scikit-Learn for machine learning to train and test Perceptron
using the Perceptron class.
4. In skPerceptron.py write the following code: Do not copy and paste, you should
write line by line.
iris = datasets.load_iris()
X = iris.data[:, [2, 3]]
y = iris.target
# training
ppn = Perceptron(alpha=40, eta0=0.1, random_state=0)
ppn.fit(X_train_std, y_train)
# predict
y_pred = ppn.predict(X_test_std)
print('misclassified: %d' %(y_pred != y_test).sum())
print('accuracy is: %.2f' % accuracy_score(y_test, y_pred))
5. Now that you have completed the code, create a running con guration, name it
skPerceptron.
6. Run to see the results.
fi
fi
Arusha Technical College (ATC) Nicodemus M. M.
7. Study and understand what the code is doing, you will present your understanding
infant of me.
8. This lab is worthy 30 points earned during the interview.
9. The interviews will start on the 27th December 2024