2013-06-21 25 views
0

我是R中的新程序員,我正在寫我的論文來訓練神經網絡。 首先,我使用rminer進行數據挖掘,之後使用nnet進行培訓。 現在我不知道哪個函數用於在訓練集和驗證集中劃分數據集,因此使用k-fold交叉驗證,並且在使用nnet之後分別使用這些函數。 對不起,我的英語。 在此先感謝如何使用Rminer和nnet

回答

1

這是一種方式來獲得一個新的話題/包R中的幫助,當你不知道如何去了解它:

library(help=package.name) 

這會給你所有的概述在語言中定義的功能和數據集,每個都有一個簡短的標題。你已經確定你所需要的功能後,您可以諮詢的感興趣的功能的文檔,像這樣:

?function.name 

在本文檔中,還注重See Also部分通常列出了一起有用的功能正在考慮功能。另外,工作的例子。您也可以使用

example(function.name) 

用於演示函數的使用和使用它的常見習語。

最後,如果幸運的話,包裝作者可能已經爲包裝寫了vignette。您可以搜索這樣的包中的所有插曲:

vignette(package="package.name") 

我們希望,這將讓你開始與rminernnet包。

0

這也許爲時已晚,但我發現這個問答,而我一直在尋找的答案,我的Q ... 您可以使用類似這樣

# 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