Skip to content

Commit

Permalink
Gini impurity after policy relabel
Browse files Browse the repository at this point in the history
Bench: 1780731
  • Loading branch information
TomaszJaworski777 committed Dec 15, 2024
1 parent 9a3167b commit 73098b9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,16 @@ impl Tree {
total += *policy;
}

let mut sum_of_squares = 0.0;

for (action, &policy) in policies.iter().enumerate() {
self[*actions + action].set_policy(policy / total);
let policy = policy / total;
self[*actions + action].set_policy(policy);
sum_of_squares += policy * policy;
}

let gini_impurity = (1.0 - sum_of_squares).clamp(0.0, 1.0);
self[node_ptr].set_gini_impurity(gini_impurity);
}

pub fn propogate_proven_mates(&self, ptr: NodePtr, child_state: GameState) {
Expand Down

0 comments on commit 73098b9

Please sign in to comment.