- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有来自 Kaggle 实践比赛的房屋数据,我正在使用 rpart 训练一个简单的第一个模型来预测销售价格。
该模型未正确识别销售条件异常或预付定金的销售。因此,我想增加这个在模型中明显被忽略的变量的重要性。
我假设这是通过使用“权重”参数来完成的,但是这个参数是如何使用的?如何确定哪些变量需要更高的权重?
最佳答案
来自 documentation :
重量
optional case weights.
a vector of non-negative costs, one for each variable in the model. Defaults to one for all variables. These are scalings to be applied when considering splits, so the improvement on splitting on a variable is divided by its cost in deciding which split to choose.
positiveWeight = 1.0 / (nrow(subset(training, Y == TRUE)) / nrow(training))
negativeWeight = 1.0 / (nrow(subset(training, Y != TRUE)) / nrow(training))
modelWeights <- ifelse(training$Y== TRUE, positiveWeight, negativeWeight)
dtreeModel <- rpart(predFormula, training, weights = modelWeights)
关于r - 如何在rpart中应用权重?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43452106/
我正在参加 Coursera 实用机器学习类(class),该类(class)要求使用此 dataset 构建预测模型。根据感兴趣的结果(此处标记为 y,但实际上是 数据集中的 classe 变量):
我正在使用 prp来自 rpart.plot 的函数用于绘制树的包。对于像状态这样的分类数据,它提供了一个非常长的变量列表,并且降低了可读性。如果超过一定长度,有没有办法将文本换行到两行或更多行? 最
我目前正在使用 rpart用于将回归树拟合到观测值相对较少的数据和采用两个可能值的数千个分类预测变量的数据包。 通过在较小的数据上测试包,我知道在这种情况下,我是否将回归量声明为分类变量(即因子)或保
我有以下问题。我编写了一个函数,在该函数中使用 rpart 包一次性计算分类树。 在函数内部,我初始化了树的权重。但是,我收到一个错误,即 rpart 函数找不到权重变量(这是确切的错误消息: Err
ID Ethnicity MaritalStatus EmploymentStatus type 1 10 5 3 1 3
RPART 对连续变量、序数变量和分类变量使用不同的分割过程。有没有办法“告知”RPART变量类型?为了便于说明,我有一个具有整数值 (1,..,5) 的序数变量。现在,我需要将其强制转换为字符,这样
我正在努力解决 Rpart 包中的 NA 功能。我得到了以下数据框(下面的代码) Outcome VarA VarB 1 1 1 0 2 1 1 1
我正在使用 rpart 制作决策树。例如: fit <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis) 如何从文本文件中读取公式部分并以
我想向我的树添加一些信息。例如,假设我有一个这样的数据库: library(rpart) library(rpart.plot) set.seed(1) mydb= node], ] } parent
> fit rpart.plot(fit, type = 4, extra = 101) 我尝试了选项(scipen=10),但没有成功。如何删除科学记数法? 最佳答案 对digits参数使用负值。
我在 R 中使用 rpart 时遇到了一些标签问题。 这是我的情况。 我正在处理具有分类变量的数据集,这是我的数据的摘录 head(Dataset) Entity IL CP TD Budge
我一生都无法弄清楚如何计算 rpart 上的混淆矩阵。 这是我所做的: set.seed(12345) UBANK_rand <- UBank[order(runif(1000)), ] UBank_
我有一个事件率低于 3% 的数据集(即大约有 700 条 1 类记录和 27000 条 0 类记录)。 ID V1 V2 V3 V5 V6 Target S
iris = 2.5 & Petal.Width = 2.5 & Petal.Width >= 1.8 和 options(width=1000) rpart.predict(iris.rpart,
我想绘制通过递归二元拆分构造的二维协变量空间的分区。更准确地说,我想编写一个函数来复制下图(取自 Elements of Statistical Learning,第 306 页): 上面显示的是二维
假设我用 RPART 建立一个玩具树模型,我怎样才能得到树的深度? library(rpart) library(partykit) fit=rpart(factor(am)~.,mtcars,con
我有一个包含 14 个特征的数据集,其中很少有如下特征,其中性别和婚姻状况是分类变量。 height,sex,maritalStatus,age,edu,homeType SEX 1
我观察到,仅对于 rpart 包(用于决策树模型),当我增加数据中的因子级别数时,该包会急剧变慢。我和其他包对比过,只针对rpart,好像是这样。下面是在我的数据上尝试各种算法的图表。 X 轴显示使用
在rpart.plot函数中(从rpart.plot包扩展到rpart包),有一个参数box.col,它控制树中节点的颜色。如何设置它为节点着色,以使相同响应的节点着色相同? 我用box.col参数尝
说我有 head(kyphosis) inTrain predict_nodes(kyph_tree, TEST_KYPHOSIS) [1] 5 3 4 3 3 5 5 3 3 3 3 5 5 4
我是一名优秀的程序员,十分优秀!