主题: data
-
特征缩放与类别编码:变换什么,以及只在训练数据上拟合
基于距离和梯度的模型需要数值特征具有可比的尺度(StandardScaler、MinMaxScaler、RobustScaler);类别列则根据类别数量和模型类型,通过独热编码、序数编码或目标编码转换为数值。每个变换器都在训练划分上拟合,再原样应用于验证、测试和生产数据行。
-
训练集、验证集与测试集:各自用途及划分方法
模型在训练集上拟合,在验证集上或通过交叉验证选择模型和超参数,测试集则只在最终估计时使用一次。如何分配数据行——随机、分层、按组或按时间——决定了该估计能否说明生产环境中的表现。
-
Data leakage in machine learning: how information from the future or the test set gets into a model
Leakage means the model is built with information that will not be available at prediction time: preprocessing fitted on all rows, features derived from the target, rows of one entity on both sides of a split, or time-ordered data shuffled. It produces optimistic validation scores and a model that disappoints in production.
-
小型数据集的来源追踪与版本管理
保持原始数据不可变,保存校验和并记录来源;用脚本生成新文件而不是直接编辑,将数据指针与代码一起进行版本管理(DVC 或 Git LFS),用 datapackage.json 描述数据包,并用 PROV 术语记录来源,使报告中的每个数值都能追溯到一次提交、一个校验和和一个脚本。
-
Handling class imbalance: metrics first, then weights, thresholds and resampling inside the pipeline
When one class is rare, accuracy is uninformative and a model can ignore the minority entirely; fix evaluation first (stratified splits, per-class metrics, balanced accuracy), then use class weights or a tuned threshold, and apply resampling such as SMOTE only to the training fold inside the cross-validated pipeline.
-
将嵌入视为数据类型:固定长度向量、距离函数及向量列的要求
嵌入是由特定模型生成的固定长度浮点向量,只有在使用该模型训练所针对的距离度量、并与同一模型版本的向量放在一起时才有意义。存储时必须记录维度、模型标识符和距离度量;查询则意味着精确或近似的最近邻搜索。
机器可读: JSON