当我运行此代码(或任何类似的代码)时:
x1 <- c(runif(100, 0.0, 10.0))
y1 <- c(runif(100, 0.0, 10.0))
data <- data.frame(x1, y1)
data$label <- with(data, ifelse((x1-5)^2 + (y1-5)^2 < 9, 1, 0))
lm_fit <- lm(formula = label ~ .,data = data)
x_vals <- seq(0, 10, 0.25)
y_vals <- seq(0, 10, 0.25)
grid <- expand.grid(x_vals, y_vals)
predict(lm_fit, grid)
我收到一条警告信息:
'newdata'有1681行,但找到的变量有100行
我也没有预测到所需的标签。我不明白R在这里做什么,有人可以帮忙吗?
答案 0 :(得分:1)
如果测试数据中的变量名称与训练数据中的变量名称匹配,则警告消失:
public class MyIterator implements Iterator<MyComponent> {
MyComponent component;
MyIteratorStrategy strategy;
public MyIterator(MyComponent component, MyIteratorStrategy strategy) {
this.component = component;
this.strategy = strategy;
}
@Override
public Component next() {
if(strategy.isDone(component) {
//return some child component
} else {
//return some other child component
}
}
//rest of implementation
}