Skip to content

Instantly share code, notes, and snippets.

View talegari's full-sized avatar

Srikanth K S talegari

View GitHub Profile
@talegari
talegari / duckplyr_exploration.R
Created November 12, 2023 08:13
Exploring duckplyr
# dataset: https://zenodo.org/records/2594012
df = arrow::read_parquet("personal/Avazu/test.parquet") |>
tibble::as_tibble()
dim(df) # 4,218,938 X 24
res =
bench::mark(
# using `duckplyr`
duckplyr = {
@talegari
talegari / executable_R_script
Last active March 19, 2019 00:34
Instructions to make a R script/program executable on *nix machines
-------------------------------------------------------------------
Instructions to make a R script/program executable on *nix machines
-------------------------------------------------------------------
Author: Srikanth KS
Date : 12th February 2018
- We assume that R, Rscript and required R packages are installed.
- 'Rscript' is a program to execute scripts/programs written in R language.
- Add this shebang(without quotes) as the first line of the script: '#!/usr/bin/env Rscript'.
@talegari
talegari / read_20newsgroups.R
Last active September 12, 2017 05:43
Read 20 Newsgroups data in R as a datatable (dataframe)
# Read 20newsgroups data as a datatable (dataframe)
# Author: Srikanth KS
# license: GPL-3
#
# download data from here:
# https://archive.ics.uci.edu/ml/machine-learning-databases/20newsgroups-mld/20_newsgroups.tar.gz
# extract it and provide its location to `baseDir` on line 9
baseDir = "Downloads/20_newsgroups"
newsGroupNames = list.files(baseDir, full.names = TRUE)
@talegari
talegari / cutq.R
Last active June 28, 2017 12:05
Discretize a numeric vector along quantiles
#' @title cutq
#' @description Discretize a numeric vector along quantiles
#' @param vec numeric/integer vector
#' @param n number of buckets (atleast two)
#' @param ... extra named arguments passed to `cut`
#' @return A factor
#' @details By passing extra arguments to `cut`, output can be styled
cutq = function(vec, n = 10, ...){
stopifnot(inherits(vec, "numeric") || inherits(vec, "integer"))
@talegari
talegari / cor2.R
Last active August 9, 2021 04:48
Find correlation matrix for a dataframe with mixed column types
###############################################################################
#
# cor2
# -- Compute correlations of columns of a dataframe of mixed types
#
###############################################################################
#
# author : Srikanth KS (talegari)
# license : GNU AGPLv3 (http://choosealicense.com/licenses/agpl-3.0/)
#
@talegari
talegari / dlib_ubuntu_install_instructions.md
Last active May 4, 2018 15:02
Installing `dlib` with python/R bindings on Ubuntu 16.04

Installing dlib to access via python and R

Author: Srikanth KS

You might need minor modifications

For ubuntu 16.04:

sudo apt-get install build-essential cmake
sudo apt-get install libgtk-3-dev
@talegari
talegari / require2.R
Last active April 18, 2017 12:19
case-insensitive `require` function replacement with similar package names suggestions
#' @title require2
#'
#' @author Srikanth KS (talegari), gmail at sri dot teach GNU AGPLv3
#' (http://choosealicense.com/licenses/agpl-3.0/)
#'
#' @param pkgname a string (character vector of length 1)
#' @param similar an positive integer indicating the number of similar package
#' names to be suggested, if the match is not found
#'
#' @description The function attaches and loads a R library, if present and
@talegari
talegari / rccpmlpack2_notes.md
Last active January 4, 2017 09:37
guide to install rcppmlpack2 on ubuntu trusty

Guide to install rcppmlpack2 on ubuntu trusty

until its released on CRAN

  • sudo add-apt-repository ppa:edd/misc
  • sudo apt-get update
  • sudo apt-get install libmlpack-dev libboost-all-dev libboost-program-options-dev libboost-serialization-dev libarmadillo-dev r-cran-rcpp r-cran-rcpparmadillo

in R: devtools::install_github("eddelbuettel/rcppmlpack2")

@talegari
talegari / recsysr.md
Last active August 5, 2022 01:59
R libraries for recommender systems

R libraries for recommender systems

A list of R libraries for Recommender systems. Most of the libraries are good for quick prototyping.

Maintainer: Srikanth KS(talegari) Email: gmail me at sri dot teach (do write to me about packages ommited)

Package Dev page Description
recommenderlab github Provides a research infrastructure to test and develop recommender algorithms including UBCF, IBCF, FunkSVD and association rule-based algorithms
rrecsys github Implementations of several popular recommendation systems like Global/Item/User-Average baselines, Item-Based KNN, FunkSVD, BPR and weighted ALS for rapid prototyping
@talegari
talegari / rmetatools.R
Last active December 29, 2016 07:56
Functions to help with code execution analysis in R
# how much memory did an execution use in MBs
mem_usage <- function(...){
exprs <- as.list(match.call(expand.dots = FALSE)$...)
invisible(gc(reset = TRUE))
start_mem <- sum(gc()[,2])
lapply(exprs, eval, parent.frame())
max_mem <- sum(gc()[,6])