首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何使用Rminer和nnet

如何使用Rminer和nnet
EN

Stack Overflow用户
提问于 2013-06-21 19:03:45
回答 2查看 1.1K关注 0票数 0

我是R的新程序员,我正在写一篇关于训练神经网络的论文。首先,我使用rminer进行数据挖掘,然后使用nnet进行训练。现在我不知道哪个函数用于划分训练集和验证集的数据集,因此k折交叉验证,并在使用set后对每个数据集进行交叉验证。对不起,我的英语不好。提前感谢

EN

回答 2

Stack Overflow用户

发布于 2013-06-21 19:17:47

当你不知道如何去做时,这里有一种方法可以在R中获得关于新主题/包的帮助:

代码语言:javascript
复制
library(help=package.name)

这将为您提供在该语言中定义的所有函数和数据集的概述,并给出每个函数和数据集的简短标题。在确定了所需的函数之后,您可以像这样查阅感兴趣的函数的文档:

代码语言:javascript
复制
?function.name

在文档中,还要注意See Also部分,该部分通常列出了与所考虑的函数结合使用的有用函数。此外,还可以使用示例。您还可以使用

代码语言:javascript
复制
example(function.name)

以演示该函数的用法和使用它的常见习惯用法。

最后,如果您幸运的话,包的作者可能已经为包编写了一个vignette。您可以搜索包中的所有小插图,如下所示:

代码语言:javascript
复制
vignette(package="package.name")

希望这能让您开始使用rminernnet包。

票数 1
EN

Stack Overflow用户

发布于 2016-01-15 18:14:34

也许太晚了,但我在寻找我的问题的答案时发现了这个问题。

代码语言:javascript
复制
    # 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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17233673

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档