feat: E_in in problem 9

This commit is contained in:
Ting-Jun Wang 2023-12-21 03:49:57 +08:00
parent 7322fb4f15
commit e6219a0c81
Signed by: snsd0805
GPG Key ID: 48D331A3D6160354

View File

@ -151,12 +151,19 @@ if __name__ == '__main__':
root.decision_stump()
root.expand()
errors = 0
for data in train:
predict_y = root.predict(data)
error = square_error(data['y'], predict_y)
errors += error
print("E_in:", errors/len(test))
errors = 0
for data in test:
predict_y = root.predict(data)
error = square_error(data['y'], predict_y)
errors += error
print("ANS:", errors/len(test))
print("E_out:", errors/len(test))