model.frame.default()变量长度中的错误有所不同(针对“(权重)”发现)

时间:2018-12-02 02:14:42

标签: r logistic-regression

我是R的新手,并且正在R中运行多项式逻辑回归,但是它一直显示错误:

library(nnet)
train <-read.csv("train.csv", header = TRUE)
train <-multinom(Crime_code~Year+Month+Day+Weekday+Time+Hour+Area+District+Longitude+Latitude,data=train,size=11,maxit=1700,weights=1700)
## Error in model.frame.default(formula = Crime_code ~ Year + Month + Day +  : variable lengths differ (found for '(weights)')
summary(train)
## Error in object[[i]] : object of type 'closure' is not subsettable

这是数据结构:

str(train)
'data.frame':   1760097 obs. of  12 variables:
$ DR        : int  120215758 160512269 112104909 121523303 162107991 
161407795 180409993 130911557 120405961 160221815 ...
$ Year      : int  2012 2015 2011 2012 2016 2016 2018 2013 2011 2016 ...
$ Month     : int  8 9 1 12 2 2 5 6 9 12 ...
$ Day       : int  5 1 18 9 24 24 18 3 1 12 ...
$ Weekday   : int  6 1 1 6 2 2 4 0 3 0 ...
$ Time      : int  2345 800 5 1200 1630 910 1910 1240 2000 1800 ...
$ Hour      : int  23 8 0 12 16 9 19 12 20 18 ...
$ Area      : int  2 5 21 15 21 14 4 9 4 2 ...
$ District  : int  201 513 2105 1583 2185 1453 489 964 416 233 ...
$ Longitude : num  -118 -118 -119 -118 -119 ...
$ Latitude  : num  34.1 33.8 34.2 34.1 34.2 ...
$ Crime_code: int  624 354 220 745 310 624 626 624 230 420 ...

1 个答案:

答案 0 :(得分:0)

问题似乎出在您的体重值上。我找不到关于此参数的大量文档,但是如果它是神经网络的权重,我希望它可以是矩阵或向量,每个节点一个权重。您是否尝试过仅将,weights= 1700取出?