Skip to content

Instantly share code, notes, and snippets.

Avatar

Ramnath Vaidyanathan ramnathv

View GitHub Profile
@ramnathv
ramnathv / bm25.py
Created Sep 8, 2020 — forked from koreyou/bm25.py
Implementation of OKapi BM25 with sklearn's TfidfVectorizer
View bm25.py
""" Implementation of OKapi BM25 with sklearn's TfidfVectorizer
Distributed as CC-0 (https://creativecommons.org/publicdomain/zero/1.0/)
"""
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from scipy import sparse
class BM25(object):
View group_mean.R
#' Group Mean
#'
#' @examples
#' iris %>%
#' group_mean(Species, Petal.Length)
group_mean <- function(tbl, group_var, summary_var){
tbl %>%
group_by({{ group_var }}) %>%
summarize(
{{ summary_var }} := mean({{ summary_var }})
@ramnathv
ramnathv / tweet_reply.md
Created Jul 27, 2018 — forked from arunsrinivasan/tweet_reply.md
automatic indexing vs between() on integer ranges
View tweet_reply.md

Updated June 16 with latest devel

data.table's automatic indexing:

Generating some data first:

# R version 3.3.0
require(data.table) ## 1.9.7, commit 2433, github
require(dplyr)      ## devel, commit 3189, github
View Effective_Engineer.md

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

View datasaurus.R
library(ggplot2)
library(datasauRus)
library(gganimate)
p <- ggplot(datasaurus_dozen, aes(x = x, y = y, frame = dataset)) +
geom_point() +
theme(legend.position = "none")
gganimate(p, title_frame = FALSE)
@ramnathv
ramnathv / concaveman.R
Created May 2, 2017
Using Concaveman in R using V8
View concaveman.R
# Using concaveman in R using V8
concaveman <- function(d){
library(V8)
ctx <- v8()
ctx$source('https://www.mapbox.com/bites/00222/concaveman-bundle.js')
jscode <- sprintf(
"var points = %s;var polygon = concaveman(points);",
jsonlite::toJSON(d, dataframe = 'values')
)
ctx$eval(jscode)
View d3-bar-chart.markdown
@ramnathv
ramnathv / .block
Last active Sep 5, 2016
fresh block
View .block
license: mit
@ramnathv
ramnathv / index.js
Created Jul 5, 2016 — forked from jimthedev/index.js
requirebin sketch
View index.js
var mobx = require('mobx');
var _ = require('lodash');
/*
MOBX in VANILLA ES5
Notes are based on Matt Ruby's Open Source North Talk:
Practical React with MobX
https://www.youtube.com/watch?v=XGwuM_u7UeQ
You can’t perform that action at this time.