Skip to content

Instantly share code, notes, and snippets.

@brooksandrew
brooksandrew / shiny_arules.R
Last active May 19, 2022 08:14
Launches a Shiny App that provides an interactive interface to the arules and arulesViz package which train and visualize association rules
#' @title Assocation Rules Visualization Shiny App
#' @description Launches a Shiny App that provides an interactive interface to the visualizations of the \code{arulesViz} package.
#' The app allows users to mine rules based on all or just subsets of features, sort by criteria (lift, support, confidence) and visualize
#' using network graph, grouped bubble and scatter plots. \cr
#' Users filter rules to target only those with a certain variable on the RHS or LHS of the rule.
#' Rule mining is computed using the \link{apriori} algorithm from \code{arules}.
#'
#' @param dataset data.frame, this is the dataset that association rules will be mined from. Each row is treated as a transaction. Seems to work
#' OK when a the S4 transactions class from \code{arules} is used, however this is not thoroughly tested.
#' @param bin logical, \code{TRUE} will automatically discretize/bin numerical data into categorical features that can be used for association analysis.
setwd('/home/rauf/Programs/DM_Labs/day_4')
require(igraph)
path <- "vk_data/adj/egonet_755.txt"
a<-read.table(path, sep=' ', dec = ' ', header = T)
#directed - T or F - в зависимости от значения,
#при Т - создает направленный граф, при F - ненаправленный
a.network <- graph.data.frame(a, directed = F)
a.network <- simplify(a.network)
@alexkutsan
alexkutsan / Wallget.py
Created July 17, 2013 21:34
Python API. Wall get all, step 1.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import vk_auth
import vkontakte
import os
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-e", "--email", dest="email",
help=" user email", metavar="EMAIL")
@embr
embr / gist:4707996
Created February 4, 2013 17:03
RescueTime Python API Example
# coding: utf-8
import pprint
import pandas as pd
from rescuetime.api.service import Service
from rescuetime.api.access import AnalyticApiKey
s = Service.Service()
k = AnalyticApiKey.AnalyticApiKey(open('rt_key').read(), s)
p = {}
@stevenworthington
stevenworthington / ipak.R
Created July 25, 2012 19:44
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
@adamloving
adamloving / fb-fan-export.js
Created January 18, 2011 01:02
Export Facebook Page Fans
/*
For more detailed instructions on how to use this script, sign up with your email here:
http://adamloving.com/internet-programming/how-toexport-facebook-page-fans
DISCLOSURE: This javascript runs in your browser pretending to be you
looking through your page fans. Facebook should have no problem with this,
but who knows if they will think it is strange to see you looking through
all your fans so quickly (the script waits 3s before requesting each page).
I've had no problem running this so far for 1000s of page fans, but I