This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| """ | |
| File: stratified.py | |
| Author: SpaceLis | |
| Email: Wen.Li@tudelft.nl | |
| Github: http://github.com/spacelis | |
| Description: | |
| Sampling in a stratified way. That is sampling from each subpopulation to | |
| make the sample set more representative than simple random sampling. For |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stratified <- function(df, group, size, select = NULL, | |
| replace = FALSE, bothSets = FALSE) { | |
| if (is.null(select)) { | |
| df <- df | |
| } else { | |
| if (is.null(names(select))) stop("'select' must be a named list") | |
| if (!all(names(select) %in% names(df))) | |
| stop("Please verify your 'select' argument") | |
| temp <- sapply(names(select), | |
| function(x) df[[x]] %in% select[[x]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stratified <- function(df, group, size, select = NULL, | |
| replace = FALSE, bothSets = FALSE) { | |
| if (is.null(select)) { | |
| df <- df | |
| } else { | |
| if (is.null(names(select))) stop("'select' must be a named list") | |
| if (!all(names(select) %in% names(df))) | |
| stop("Please verify your 'select' argument") | |
| temp <- sapply(names(select), | |
| function(x) df[[x]] %in% select[[x]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "flare", | |
| "children": [ | |
| { | |
| "name": "analytics", | |
| "children": [ | |
| { | |
| "name": "cluster", | |
| "children": [ | |
| {"name": "AgglomerativeCluster", "size": 3938}, |
NewerOlder