我发现了这篇关于分类、数字、一个热编码和二进制编码@Laurae’s Data Science & Design curated posts的很棒的博客文章
不过,我最感兴趣的部分是用R写的:
my_data <- c("Louise",
"Gabriel",
"Emma",
"Adam",
"Alice",
"Raphael",
"Chloe",
"Louis",
"Jeanne",
"Arthur")
matrix(
as.integer(intToBits(as.integer(as.factor(my_data)))),
ncol = 32,
nrow = length(my_data),
byrow = TRUE
)[, 1:ceiling(log(length(unique(my_data)) + 1)/log(2))]
关于如何在Python中对Pandas数据帧的“category”列应用这一点有什么帮助吗?在
提前谢谢。在
Categoricals是一种pandas数据类型,它对应于统计数据中的分类变量:变量只能接受有限的(通常是固定的)数量的可能值(categories;levels in R),您可以使用documentation of pandas,这是文档中的一个小示例:
或者正如你在DataFrame中要求的那样:
^{pr2}$与R系数的差异:
可以观察到R因子函数的以下差异:
相关问题 更多 >
编程相关推荐