pub fn compute_biases(
	labels: ArrayView1<Option<NonZeroUsize>>,
	n_trees_per_round: usize,
) -> Array1<f32> {
	let mut biases: Array1<f32> = Array::zeros(n_trees_per_round);
	for label in labels {
		let label = label.unwrap().get() - 1;
		biases[label] += 1.0;
	}
	let n_examples = labels.len().to_f32().unwrap();
	for bias in biases.iter_mut() {
		let proba = *bias / n_examples;
		let clamped_proba = clamp(proba, std::f32::EPSILON, 1.0 - std::f32::EPSILON);
		*bias = clamped_proba.ln();
	}
	biases
}
/// This function is used by the common train function to compute the biases for multiclass classification.
This function is used by the common train function to compute the biases for multiclass classification.
This function is used by the common train function to compute the biases for multiclass classification .
pub fn compute_biases(
	labels: ArrayView1<Option<NonZeroUsize>>,
	n_trees_per_round: usize,
) -> Array1<f32> {
	let mut biases: Array1<f32> = Array::zeros(n_trees_per_round);
	for label in labels {
		let label = label.unwrap().get() - 1;
		biases[label] += 1.0;
	}
	let n_examples = labels.len().to_f32().unwrap();
	for bias in biases.iter_mut() {
		let proba = *bias / n_examples;
		let clamped_proba = clamp(proba, std::f32::EPSILON, 1.0 - std::f32::EPSILON);
		*bias = clamped_proba.ln();
	}
	biases
}
pub fn compute_biases ( labels : ArrayView1 < Option < NonZeroUsize > > , n_trees_per_round : usize , ) -> Array1 < f32 > { let mut biases : Array1 < f32 > = Array :: zeros ( n_trees_per_round ) ; for label in labels { let label = label . unwrap ( ) . get ( ) - 1 ; biases [ label ] += 1.0 ; } let n_examples = labels . len ( ) . to_f32 ( ) . unwrap ( ) ; for bias in biases . iter_mut ( ) { let proba = * bias / n_examples ; let clamped_proba = clamp ( proba , std :: f32 :: EPSILON , 1.0 - std :: f32 :: EPSILON ) ; * bias = clamped_proba . ln ( ) ; } biases }
This function is used by the common train function to compute the biases for multiclass classification.
This function is used by the common train function to compute the biases for multiclass classification .
labels
ArrayView1<Option<NonZeroUsize>>
n_trees_per_round
usize