Tugas Perceptron Dan BP Ann - A - f1d019055 - M. Arfriyandri
Tugas Perceptron Dan BP Ann - A - f1d019055 - M. Arfriyandri
Tugas Perceptron Dan BP Ann - A - f1d019055 - M. Arfriyandri
y = ['A','B','A','A','A','A','B','B','B','B']
weights = [0,0,0,0,0,0]
Perceptron
In [3]: #activation function dengan fungsi aktivasi bipolar step function bipolar
def actFunction(dt):
return 1.0 if dt >= 0.0 else -1.0
In [7]: testing(x)
Expected=0, Predicted=1
Expected=0, Predicted=1
Expected=1, Predicted=1
Expected=0, Predicted=1
Expected=1, Predicted=1
Expected=1, Predicted=1
Expected=0, Predicted=1
Expected=0, Predicted=1
Expected=1, Predicted=1
Expected=1, Predicted=1
Back Propagation
In [5]: #mengimport library
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import confusion_matrix
from sklearn.metrics import classification_report
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
#trainning data
BP.fit(trainX, trainY)
#Prediction Training
print("\n--- PREDICTION TRAINING ---" )
pred_y = BP.predict(trainX)
generateClassificationReport(trainY,pred_y)
accuracy 1.00 8
macro avg 1.00 1.00 1.00 8
weighted avg 1.00 1.00 1.00 8
[[4 0]
[0 4]]
accuracy is 1.0
In [ ]: