我正在上关于R中的监督学习:回归的课程。有一段我应该根据年龄和体重来预测血压。这是我的方法
# Create the formula and print it
fmla <- lm(blood_pressure ~ age + weight, data=bloodpressure)
fmla
# Fit the model: bloodpressure_model
bloodpressure_model <- fmla
# Print bloodpressure_model and call summary()
bloodpressure_model
summary(bloodpressure_model)这是一份不正确的报告。消息错误消息是--“变量fmla的内容不正确。”
DataCamp的解决方案是
# bloodpressure is in the workspace
summary(bloodpressure)
# Create the formula and print it
fmla <- blood_pressure ~ age + weight
fmla <- lm(blood_pressure ~ age + weight, data=bloodpressure)
fmla
# Fit the model: bloodpressure_model
bloodpressure_model <- lm(fmla, data = bloodpressure)
# Print bloodpressure_model and call summary()
bloodpressure_model
summary(bloodpressure_model) 这两种模型的诊断结果相同。我的方法有什么问题?
发布于 2020-06-15 09:02:05
这应该是他们服务器上的一个漏洞。fmla变量应该在您的代码和它们的代码中具有相同的内容。这是因为这两个脚本上的最后一个任务是
fmla <- lm(blood_pressure ~ age + weight, data=bloodpressure)
发布于 2020-06-19 06:33:11
fmla是模型公式:fmla <- formula(blood_pressure ~ age + weight)
所以正确的解决办法应该是
# bloodpressure is in the workspace
summary(bloodpressure)
# Create the formula and print it
fmla <- formula(blood_pressure ~ age + weight)
fmla
# Fit the model: bloodpressure_model
bloodpressure_model <- lm(fmla, data = bloodpressure)
# Print bloodpressure_model and call summary()
bloodpressure_model
summary(bloodpressure_model) https://datascience.stackexchange.com/questions/76015
复制相似问题