简体   繁体   English

如何使用Rminer和nnet

[英]How use Rminer and nnet

I'm new programmer in R and i'm writing my thesis for training a neural network. 我是R语言的新程序员,我正在写论文以训练神经网络。 First i use rminer for datamining and after nnet for training. 首先,我使用rminer进行数据挖掘,然后使用nnet进行培训。 Now i don't know which function use for divide data-set in training set and validation set, therefore k-fold cross validation, and after use nnet for each of this. 现在我不知道在训练集和验证集中将数据集划分为哪个函数,因此不进行k折交叉验证,而在每一个之后使用nnet。 sorry for my english. 对不起我的英语不好。 Thanks in advance 提前致谢

Here is a way to get help on a new topic / package in R when you don't know how to go about it: 当您不知道如何处理时,可以通过以下方法获得有关R中新主题/程序包的帮助:

library(help=package.name)

This will give you an overview of all the functions and data sets defined in the language with a brief title of each. 这将为您提供该语言定义的所有功能和数据集的概述,并简要说明每个功能和数据集。 After you have identified the functions that you need, you can consult the documentation of the functions of interest like so: 在确定所需的功能之后,可以像下面这样查询感兴趣的功能的文档:

?function.name

In the documentation, also pay attention to the See Also section which typically lists functions that are useful in conjunction with the function being considered. 在文档中,还See Also注意“ See Also部分,该部分通常列出与所考虑的功能结合使用的功能。 Also, work the examples. 另外,请工作示例。 You can also use 您也可以使用

example(function.name)

for a demonstration of the function's use and common idioms using it. 演示该功能的用法和使用它的常见用法。

Lastly, if you are lucky, the package author may have written a vignette for the package. 最后,如果幸运的话,包裹的作者可能已经为包裹写了一个vignette You can search for all vignettes in a package like this: 您可以像这样在包中搜索所有小插图:

vignette(package="package.name")

Hopefully, this will get you started with the rminer and nnet packages. 希望这将使您开始使用rminernnet软件包。

It's maybe too late, but I found this Q while I was looking for an answer to my Q. You can use something like this 可能为时已晚,但我在寻找问题的答案时发现了这个问题。您可以使用类似这样的内容

    # Splitting in training, Cross-Validation and test datasets
        #The entire dataset has 100% of the observations. The training dataset will have 60%, the Cross-Validation (CV) will have 20% and the testing dataset will have 20%.                                                                                                                                
        train_ind <- sample(seq_len(nrow(DF.mergedPredModels)), size = floor(0.6 * nrow(DF.mergedPredModels)))
        trainDF.mergedPredModels <- DF.mergedPredModels[train_ind, ]

        # The CV and testing datasets' observations will be built from the observations from the initial dataset excepting the ones from the training dataset
        # Cross-Validation dataset
        # The CV's number of observations can be changed simply by changing "0.5" to a fraction of your choice but the CV and testing dataset's fractions must add up to 1.
        cvDF.mergedPredModels <- DF.mergedPredModels[-train_ind, ][sample(seq_len(nrow(DF.mergedPredModels[-train_ind, ])), size = floor(0.5 * nrow(DF.mergedPredModels[-train_ind, ]))),]

        # Testing dataset
        testDF.mergedPredModels <- DF.mergedPredModels[-train_ind, ][-sample(seq_len(nrow(DF.mergedPredModels[-train_ind, ])), size = floor(0.5 * nrow(DF.mergedPredModels[-train_ind, ]))),]

        #temporal data and other will be added after the predictions are made because I don't need the models to be built on the dates. Additionally, you can add these columns to the training, CV and testing datasets and plot the real values of your predicted parameter and the respective predicitons over your time variables (half-hour, hour, day, week, month, quarter, season, year, etc.).
        # aa = Explicitly specify the columns to be used in the temporal datasets
        aa <- c("date", "period", "publish_date", "quarter", "month", "Season")
        temporaltrainDF.mergedPredModels <- trainDF.mergedPredModels[, c(aa)]
        temporalcvDF.mergedPredModels <- cvDF.mergedPredModels[, c(aa)]
        temporaltestDF.mergedPredModels <- testDF.mergedPredModels[, c(aa)]

        # bb = Explicitly specify the columns to be used in the training, CV and testing datasets
        bb <- c("quarter", "month", "Season", "period", "temp.mean", "wind_speed.mean", "solar_radiation", "realValue")
        trainDF.mergedPredModels.Orig <- trainDF.mergedPredModels[, c(bb)]
        trainDF.mergedPredModels <- trainDF.mergedPredModels[, c(bb)]
        smalltrainDF.mergedPredModels.Orig <- trainDF.mergedPredModels.Orig[1:10,] #see if the models converge without errors
        cvDF.mergedPredModels <- cvDF.mergedPredModels[, c(bb)]
        testDF.mergedPredModels <- testDF.mergedPredModels[, c(bb)]
# /Splitting in training, Cross-Validation and test datasets

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM