Skip to content

Instantly share code, notes, and snippets.

View IronistM's full-sized avatar
🏗️
Under construction

Manos Parzakonis IronistM

🏗️
Under construction
View GitHub Profile
@rpietro
rpietro / r_sqldf_tutorial.r
Created December 18, 2012 07:10
sqldf tutorial from http://goo.gl/dSuj8 - i just moved the data into the script (using dput) to make it self-contained
#Load sqldf package, which will load all others necessary
#By default, SQLite runs in background to do processing, could use others DB engines if you wanted
library("sqldf")
#Import employees data
employees <- structure(list(id = 1:20, lastname = structure(c(5L, 14L, 13L, 15L, 6L, 16L, 9L, 1L, 3L, 12L, 10L, 8L, 12L, 3L, 11L, 13L, 10L, 7L, 2L, 4L), .Label = c("a", "b", "c", "f", "g", "h", "i", "j", "n", "o", "p", "r", "s", "t", "w", "z"), class = "factor"), firstname = structure(c(12L, 6L, 5L, 12L, 11L, 15L, 9L, 18L, 17L, 7L, 8L, 10L, 4L, 14L, 19L, 16L, 1L, 13L, 2L, 3L), .Label = c("chris", "dima", "drew", "eric", "hila", "jason", "jeremy", "joe", "jon", "jowanza", "lashanda", "matt", "michael", "michelle", "randy", "rudi", "solon", "stewart", "tim"), class = "factor"), gender = structure(c(2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("f", "m"), class = "factor")), .Names = c("id", "lastname", "firstname", "gender"), class = "data.frame", row.names = c(NA, -20
@shanebutler
shanebutler / sql.export.gbm.R
Last active July 4, 2023 08:10
Deploy your GBM models in SQL! This tool enables in-database scoring of GBM models built using R. To use it, you simply call the function with the GBM model, output filename, SQL input data table and the name of the unique key on that table. For example:sql.export.gbm(gbm1, file="model_output.SQL", input.table="source_table", id="id") Please let…
# sql.export.gbm(): save a GBM model as SQL
# v0.11
# Copyright (c) 2013-2014 Shane Butler <shane dot butler at gmail dot com>
#
# sql.export.gbm is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# sql.export.gbm is distributed in the hope that it will be useful, but
from pylab import *
from numpy import *
from numpy.linalg import solve
from scipy.integrate import odeint
from scipy.stats import norm, uniform, beta
from scipy.special import jacobi
a = 0.0
@stefanwalther
stefanwalther / QlikView_SaveTables_ToQVDs.qvs
Last active September 10, 2019 17:32
QlikView Script: Save all tables to QVD files.
// '.\' is the current path
// Define the path here, if required ...
SET basePath = '.\';
TRACE ---------------------------------------------------------------;
TRACE Saving tables ... ;
TRACE ~~;
For i = 0 To NoOfTables() -1
@coppeliaMLA
coppeliaMLA / finSim.R
Last active September 22, 2016 09:07
Uncertainty in a financial model
#First we are going to set up probaility distributions for our beliefs about the inputs
#We've been told ARPU is about £7 and it's very unlikely to be higher than £10 or lower than £4
#So we'll go for a normal distribution centred at 7 with 5% and 95% quantiles at 4 and 10
#Show how we get the variance
arpu.sd<-3/1.96
x<-seq(0, 15,by=0.5)
d<-dnorm(x, 7, arpu.sd)
plot(x, d, type='l')
@stucchio
stucchio / bayesian_ab_test.py
Last active April 2, 2023 03:17
Bayesian A/B test code
from matplotlib import use
from pylab import *
from scipy.stats import beta, norm, uniform
from random import random
from numpy import *
import numpy as np
import os
# Input data
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@shanebutler
shanebutler / sql.export.randomForest.R
Last active September 14, 2020 14:04
Deploy your RandomForest models in SQL! This tool enables in-database scoring of Random Forest models built using R. To use it, you simply call the function with the Random Forest model, output filename, SQL input data table and the name of the unique key on that table. For example:sql.export.rf(rf.mdl, file="model_output.SQL", input.table="sour…
# sql.export.rf(): save a randomForest model as SQL
# v0.04
# Copyright (c) 2013-2014 Shane Butler <shane dot butler at gmail dot com>
#
# sql.export.rf is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# sql.export.rf is distributed in the hope that it will be useful, but
@pengelbrecht
pengelbrecht / cohort_analysis.R
Created September 30, 2014 15:58
R Cohort Analysis Example
require(RMySQL)
require(ggplot2)
require(scales)
myusername = "peter"
mypassword = "sekret"
system('ssh -f pe@192.168.0.10 -L 3306:localhost:3306 -N -o ExitOnForwardFailure=yes')
con <- dbConnect(MySQL(),
user=myusername, password=mypassword,
@aronatkins
aronatkins / install-rstudio-daily.sh
Last active February 10, 2022 08:54
Install RStudio daily build on OSX/macOS or Ubuntu Linux
#!/bin/bash
#
# Installs the latest RStudio daily desktop build for OSX/macOS and Ubuntu(amd64)
#
# https://support.rstudio.com/hc/en-us/articles/203842428-Getting-the-newest-RStudio-builds
set -e
install_macos_daily() {
REDIRECT_URL="https://www.rstudio.org/download/latest/daily/desktop/mac/RStudio-latest.dmg"