我正在使用糖尿病数据集。我正在尝试拟合从我先前在训练集上获得的“最佳”模型,并报告该模型的测试错误。代码如下
library(nclSLR)
library(leaps)
library(glmnet)
data(diabetes)
set.seed(1)
(n = nrow(diabetes))
(p = ncol(diabetes) - 1)
train = diabetes [1:350,]
test = diabetes [351:442,]
grid=10^seq(10,-2,length=100)
best.subset=c("sex", "bmi", "map", "tc", "ldl", "ltg")
diabetes = diabetes[,best.subset]
#Train lm model
lm.mod=lm(sex~., diabetes[train,])
我在最后一行出现错误。它显示了
Error in xj[i] : invalid subscript type 'list'.
我尝试取消列表(),但仍然无法正常工作。
答案 0 :(得分:0)
问题在于我们使用import subprocess
import time
def execute(command):
print('start command: {}'.format(command))
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print('wait')
wait = 10
while process.poll() is None and wait > 0:
time.sleep(1)
wait -= 1
print('done')
if wait == 0:
print('terminate')
process.terminate()
print('communicate')
stdout, stderr = process.communicate()
print('rc')
exit_code = process.returncode
if exit_code != 0:
print('got bad rc')
if __name__ == '__main__':
execute(['ping','-n','15','127.0.0.1']) # correctly times out
execute(['ping','-n','5','127.0.0.1']) # correctly runs within the time limit
# incorrectly times out
execute(['C:\\dev\\jdk8\\bin\\java.exe', '-jar', 'JMXQuery-0.1.8.jar', '-url', 'service:jmx:rmi:///jndi/rmi://localhost:18080/jmxrmi', '-json', '-q', 'java.lang:type=Runtime;java.lang:type=OperatingSystem'])
即行索引作为data.frame。在这里,我们需要已经创建的data.frame的子集,即“火车”
i