Scaffold for turniing floats to hashable and fittinng to columns
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#![allow(clippy::ptr_arg)]
|
||||
//! # Encode categorical features as a one-hot numeric array.
|
||||
|
||||
use crate::error::Failed;
|
||||
use crate::linalg::{BaseVector, Matrix};
|
||||
use crate::math::num::RealNumber;
|
||||
|
||||
use crate::preprocessing::series_encoder::SeriesOneHotEncoder;
|
||||
|
||||
pub type HashableReal = u32;
|
||||
|
||||
fn hashable_num<T: RealNumber>(v: &T) -> HashableReal {
|
||||
// gaxler: If first 32 bits are the same, assume numbers are the same for the categorical coercion
|
||||
v.to_f32_bits()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OneHotEncoderParams {
|
||||
pub categorical_param_idxs: Option<Vec<usize>>,
|
||||
pub infer_categorical: bool,
|
||||
}
|
||||
/// Encode Categorical variavbles of data matrix to one-hot
|
||||
pub struct OneHotEncoder {
|
||||
series_encoders: Vec<SeriesOneHotEncoder<HashableReal>>,
|
||||
categorical_param_idxs: Vec<usize>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user