Code Monkey home page Code Monkey logo

dsam's Introduction

DSAM

This package can be used to split rainfall-runoff data into three data subsets(Train, Test, Validation) with similar data distribution characteristics.

Installation

There are several ways to install this package:

Way 1:
Download and install directly from CRAN:

install.packages("DSAM")

Way 2:
Download and install from github: Firstly ensure that you have installed the package devtools:

install.packages("devtools")

Then you can install the package like so:

devtools::install_github("lark-max/DSAM")

Way 3:
You can download the zip package provided in the release page, and install the package by hand:

install.packages("DSAM_1.0.x.tar.gz",repos = NULL,type = "source")

After installation, You can then load the package by:

library(DSAM)

Instruction

The package has several built-in data splitting algorithms, such as SOMPLEX, MDUPLEX, SBSS.P, etc. These algorithms are encapsulated and used by the user only by calling the function dataSplit.
Specific call formats such as:

result = dataSplit(data,list(sel.alg = "SOMPLEX", writeFile = TRUE))

The parameters of the function are composed of two parts. The first parameter data is usually the rainfall runoff data in data.frame or matrix format, and set the first column as the subscript column. For the specific format requirements, please refer to the documentation of the built-in dataset(DSAM_test_smallData).

The second parameter control is a list of customized information, such as the selected data splitting algorithm, the proportion of subsets, whether the output file is required and the output file name, etc. These information have default defaults, you can refer to the par.default() provided in the package, which is shown as below:

`include.inp`   
Boolean variable that determines whether the input vectors should be included during the Euclidean distance calculation. The default is TRUE.

`seed`  
Random number seed. The default is 1000.

`sel.alg`   
A string variable that represents the available data splitting algorithms including "SOMPLEX", "MDUPLEX", "DUPLEX", "SBSS.P", "SS" and "TIMECON". The default is "MDUPLEX".

`prop.Tr`   
The proportion of data allocated to the training subset, where the default is 0.6.

`prop.Ts`   
The proportion of data allocated to the test subset, where the default is 0.2.

`Train` 
A string variable representing the output file name for the training data subset. The default is "Train.txt".

`Test`  
A string variable representing the output file name for the test data subset. The default is "Test.txt".

`Validation`    
A string variable representing the output file name for the validation data subset. The default is "Valid.txt".

`loc.calib` 
Vector type: When sel.alg = "TIMECON", the program will select a continuous time-series data subset from the original data set, where the start and end positions are determined by this vector, with the first and the second value representing the start and end position in percentage of the original dataset. The default is c(0,0.6), implying that the algorithm selects the first 60% of the data from the original dataset.

`writeFile` 
Boolean variable that determines whether the data subsets need to be output or not. The default is FALSE.

`showTrace` 
Boolean variable that determines the level of user feedback. The default is FALSE.

Example

The following example can be run directly from the user’s Rstudio client.

library(DSAM)
## basic example code
data("DSAM_test_smallData")
res.sml = dataSplit(DSAM_test_smallData)

data("DSAM_test_modData")
res.mod = dataSplit(DSAM_test_modData, list(sel.alg = "SBSS.P"))

data("DSAM_test_largeData")
res.lag = dataSplit(DSAM_test_largeData, list(sel.alg = "SOMPLEX"))

Details

The package also integrates the function of adjunct validation. The metric AUC is used to analyze the similarity of data distribution features among the sample subsets obtained by various data segmentation algorithms, which can be calculated by invoking the function getAUC.
For example:

data("DSAM_test_largeData")
res.split = dataSplit(DSAM_test_largeData,list(sel.alg = "TIMECON"))
runoff.calib <- res.split$Calibration$O
runoff.valid <- res.split$Validation$O
res.auc = getAUC(runoff.calib,runoff.valid)

In the above example, the value range of res.auc is [0,1], and the closer the value is to 0.5, the more similar the data distribution characteristics between the two sample subsets are.

References

Chen, J., Zheng F., May R., Guo D., Gupta H., and Maier H. R.(2022). Improved data splitting methods for data-driven hydrological model development based on a large number of catchment samples, Journal of Hydrology, 613.

Zheng, F., Chen J., Maier H. R., and Gupta H.(2022). Achieving Robust and Transferable Performance for Conservation‐Based Models of Dynamical Physical Systems, Water Resources Research, 58(5).

Zheng, F., Chen, J., Ma, Y., Chen Q., Maier H. R., and Gupta H.(2023). A Robust Strategy to Account for Data Sampling Variability in the Development of Hydrological Models, Water Resources Research, 59(3).

dsam's People

Contributors

lark-max avatar

Stargazers

Xiaobing Han avatar Ming Hao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.