fn compute_early_stopping_metric(
	task: &Task,
	trees_for_round: &[TrainTree],
	features: ArrayView2<TableValue>,
	labels: TableColumnView,
	mut predictions: ArrayViewMut2<f32>,
) -> f32 {
	match task {
		Task::Regression => {
			let labels = labels.as_number().unwrap();
			let labels = labels.as_slice().into();
			crate::regressor::update_logits(
				trees_for_round,
				features.view(),
				predictions.view_mut(),
			);
			crate::regressor::compute_loss(predictions.view(), labels)
		}
		Task::BinaryClassification => {
			let labels = labels.as_enum().unwrap();
			let labels = labels.as_slice().into();
			crate::binary_classifier::update_logits(
				trees_for_round,
				features.view(),
				predictions.view_mut(),
			);
			crate::binary_classifier::compute_loss(predictions.view(), labels)
		}
		Task::MulticlassClassification { .. } => {
			let labels = labels.as_enum().unwrap();
			let labels = labels.as_slice().into();
			crate::multiclass_classifier::update_logits(
				trees_for_round,
				features.view(),
				predictions.view_mut(),
			);
			crate::multiclass_classifier::compute_loss(predictions.view(), labels)
		}
	}
}
/// Compute the early stopping metric value for the set of trees that have been trained thus far.
Compute the early stopping metric value for the set of trees that have been trained thus far.
Compute the early stopping metric value for the set of trees that have been trained thus far .
fn compute_early_stopping_metric(
	task: &Task,
	trees_for_round: &[TrainTree],
	features: ArrayView2<TableValue>,
	labels: TableColumnView,
	mut predictions: ArrayViewMut2<f32>,
) -> f32 {
	match task {
		Task::Regression => {
			let labels = labels.as_number().unwrap();
			let labels = labels.as_slice().into();
			crate::regressor::update_logits(
				trees_for_round,
				features.view(),
				predictions.view_mut(),
			);
			crate::regressor::compute_loss(predictions.view(), labels)
		}
		Task::BinaryClassification => {
			let labels = labels.as_enum().unwrap();
			let labels = labels.as_slice().into();
			crate::binary_classifier::update_logits(
				trees_for_round,
				features.view(),
				predictions.view_mut(),
			);
			crate::binary_classifier::compute_loss(predictions.view(), labels)
		}
		Task::MulticlassClassification { .. } => {
			let labels = labels.as_enum().unwrap();
			let labels = labels.as_slice().into();
			crate::multiclass_classifier::update_logits(
				trees_for_round,
				features.view(),
				predictions.view_mut(),
			);
			crate::multiclass_classifier::compute_loss(predictions.view(), labels)
		}
	}
}
fn compute_early_stopping_metric ( task : & Task , trees_for_round : & [ TrainTree ] , features : ArrayView2 < TableValue > , labels : TableColumnView , mut predictions : ArrayViewMut2 < f32 > , ) -> f32 { match task { Task :: Regression => { let labels = labels . as_number ( ) . unwrap ( ) ; let labels = labels . as_slice ( ) . into ( ) ; crate :: regressor :: update_logits ( trees_for_round , features . view ( ) , predictions . view_mut ( ) , ) ; crate :: regressor :: compute_loss ( predictions . view ( ) , labels ) } Task :: BinaryClassification => { let labels = labels . as_enum ( ) . unwrap ( ) ; let labels = labels . as_slice ( ) . into ( ) ; crate :: binary_classifier :: update_logits ( trees_for_round , features . view ( ) , predictions . view_mut ( ) , ) ; crate :: binary_classifier :: compute_loss ( predictions . view ( ) , labels ) } Task :: MulticlassClassification { .. } => { let labels = labels . as_enum ( ) . unwrap ( ) ; let labels = labels . as_slice ( ) . into ( ) ; crate :: multiclass_classifier :: update_logits ( trees_for_round , features . view ( ) , predictions . view_mut ( ) , ) ; crate :: multiclass_classifier :: compute_loss ( predictions . view ( ) , labels ) } } }
Compute the early stopping metric value for the set of trees that have been trained thus far.
Compute the early stopping metric value for the set of trees that have been trained thus far .
task
&Task
trees_for_round
&[TrainTree]
features
ArrayView2<TableValue>
labels
TableColumnView
predictions
ArrayViewMut2<f32>