Posts

Showing posts from January 25, 2019

Vectorizing a for-loop for cross-validation in R

Image
0 I'm trying to speed up a script that otherwise takes days to handle larger data sets. So, is there a way to completely vectorize the following script: # k-fold cross validation df <- trees # a data frame 'trees' from R. df <- df[sample(nrow(df)), ] # randomly shuffles the data. k <- 10 # Number of folds. Note k=nrow(df) in the leave-one-out cross validation. folds <- cut(seq(from=1, to=nrow(df)), breaks=k, labels=FALSE) # creates unique numbers for k equally size folds. df$ID <- folds # adds fold IDs. df[paste("pred", 1:10, sep="")] <- NA # adds multiple columns "pred1"..."pred10" to speed up the following loop. library(mgcv) for(i in 1:k) { # looping for different models:

Factio Communistica Unionis Sovieticae

Image
Factio Communistica Unionis Sovieticae Коммунистическая партия Советского Союза Factio condita 1898 ut Russica Social-Democratica Operaria Factio Factio soluta 1991 Ideologia Communismus Civitas URSS Factio Communistica Unionis Sovieticae (Russice: Коммунистическая партия Советского Союза, tr. Kommunističeskaja partija Sovetskogo Sojuza ) vel breve FCUS (Russice: КПСС, tr. KPSS ) erat sola et regnatrix factio politica Unionis Sovieticae. Historia | Hac in domo erat prima sessio Factionis Russicae Social-Democraticae Operariae, anno 1898. Anno 1898 condita est "Russica Social-Democratica Operaria Factio" (Российская социал-демократическая рабочая партия, Rossijskaja social-demokratičeskaja rabočaja partija , breve РСДРП, RSDRP ), quae anno 1903, in congressu suo secundo, divisa est in "bolsevicos" (большевики, bol'ševiki ), a Vladimiro Lenin ductos, et "mensevicos" (меньшевики, men'še

Why can't i modify the year variable in following javascript program?

Image
-5 0 why the year variable is not modified ? For example i subtract 1 from year variable but it is not reflected in the global variable why ? This is a program to check your age but it is giving the output age + 1. My Javascript code is as follows: var currentAge = function(birthDay, birthMonth, birthYear) { var birthDay, birthYear, birthMonth; var yearDiff, lst, day, year, month; var date = new Date(); day = (date.getDate()); year = (date.getFullYear()); month = ([date.getMonth()] + 1); var daysPresent = function(birthDay) { if (day >= birthDay) { return (day - birthDay); } else if (day < birthDay) { day += 31; month -= 1; return (day - birthDay); } }; var monthsPresent = function(birthMonth) { if (mont