我正在尝试如下训练神经网络:
# just an example
def func(): # define a function
func.y = 4 # here y is a local variable, which I want to access; func.y defines
# a method for my example function which will allow me to access
# function's local variable y
x = func.y + 8 # this is the main task for the function: what it should do
return x
func() # now I'm calling the function
a = func.y # I put it's local variable into my new variable
print(a) # and print my new variable
它工作正常,但我必须纠正df的偏斜,该偏斜具有99%的错误和1%的真实。 nnet()函数有一个权重向量可以做到这一点,Neuronet()是否有类似的东西?如果没有,我该如何解决?
答案 0 :(得分:0)
我现在已经像这样修复了它,但是仍然对该软件包提供的任何工具感兴趣:
factor.list <- lapply(1:factor, function(x){df1[df1$a == 0,]})
factor.df <- do.call(rbind, factor.list)
model2 <- neuralnet(a ~ b + c + d + e ,data = rbind(df1,factor.df), hidden = c(10,10), lifesign = "full")
其中“因数”是1s和0s之间的比例