Skip to content

Instantly share code, notes, and snippets.

import networkx as nx
import numpy as np
import itertools
## We define each S* motif as a directed graph in networkx
motifs = {
'S1': nx.DiGraph([(1,2),(2,3)]),
'S2': nx.DiGraph([(1,2),(1,3),(2,3)]),
'S3': nx.DiGraph([(1,2),(2,3),(3,1)]),
'S4': nx.DiGraph([(1,2),(3,2)]),
@aronwc
aronwc / lda.py
Last active April 30, 2024 06:54
Example using GenSim's LDA and sklearn
""" Example using GenSim's LDA and sklearn. """
import numpy as np
from gensim import matutils
from gensim.models.ldamodel import LdaModel
from sklearn import linear_model
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import CountVectorizer
@rpietro
rpietro / lsa_hack.r
Created September 3, 2013 23:03
playing with lsa based on post from http://goo.gl/ds2c4p
# script stolen from http://goo.gl/YbQyAQ
# install.packages("tm")
# install.packages("ggplot2")
# install.packages("lsa")
# install.packages("scatterplot3d")
#install.packages("SnowballC")
#if !(require('SnowballC')) then install.packages("SnowballC")
library(tm)
library(ggplot2)
# coding=UTF-8
import nltk
from nltk.corpus import brown
# This is a fast and simple noun phrase extractor (based on NLTK)
# Feel free to use it, just keep a link back to this post
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/
# Create by Shlomi Babluki
# May, 2013
@meefen
meefen / lsa_mds.R
Last active September 30, 2019 20:17
Analyze Text Similarity in R: Latent Semantic Analysis and Multidimentional Scaling
# load required libraries
library(tm)
library(ggplot2)
library(lsa)
# 1. Prepare mock data
text <- c("transporting food by cars will cause global warming. so we should go local.",
"we should try to convince our parents to stop using cars because it will cause global warming.",
"some food, such as mongo, requires a warm weather to grow. so they have to be transported to canada.",
"a typical electronic circuit can be built with a battery, a bulb, and a switch.",
@z-m-k
z-m-k / LICENSE
Last active October 30, 2016 22:37
A Python class that allows to incorporate d3js and Python (IPython notebook mainly). See at: http://nbviewer.ipython.org/4484816/ipyD3sample.ipynb
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. {http://fsf.org/}
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
@dahu
dahu / gist:3986511
Last active April 22, 2024 13:02
Vim Motions
Large Object Motions:
(
)
{
}
[[
[]
][
]]
[m
@ibeex
ibeex / foo.log
Created August 4, 2012 13:46
Flask logging example
A warning occurred (42 apples)
An error occurred
@jzempel
jzempel / application:__init__.py
Created July 29, 2012 20:37
Flask with Celery 3.0
from blueprint import example
from extensions import mail
from flask import Flask
import settings
def create_app(settings=settings):
ret_val = Flask(__name__)
ret_val.config.from_object(settings)
# initialize extensions...
@wickman
wickman / README.md
Created April 12, 2012 22:55
Python development in Pants (tutorial)

Python development using Pants

brian wickman - @wickman

[TOC]

Why use Pants for Python development?

Pants makes the manipulation and distribution of hermetically sealed Python environments