feat: E_in in problem 9
This commit is contained in:
parent
7322fb4f15
commit
e6219a0c81
@ -151,12 +151,19 @@ if __name__ == '__main__':
|
|||||||
root.decision_stump()
|
root.decision_stump()
|
||||||
root.expand()
|
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
|
errors = 0
|
||||||
for data in test:
|
for data in test:
|
||||||
predict_y = root.predict(data)
|
predict_y = root.predict(data)
|
||||||
error = square_error(data['y'], predict_y)
|
error = square_error(data['y'], predict_y)
|
||||||
errors += error
|
errors += error
|
||||||
print("ANS:", errors/len(test))
|
print("E_out:", errors/len(test))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user