Skip to content

Instantly share code, notes, and snippets.

View mikaelbr's full-sized avatar

Mikael Brevik mikaelbr

View GitHub Profile
@mikaelbr
mikaelbr / jsmodule.js
Created October 5, 2012 15:37
JS Module Template
;(function () {
var moduleName = 'someName',
methods = {},
root = this;
// Private methods
var _foo = function () {
};
@mikaelbr
mikaelbr / .priv_config.sh
Created November 6, 2012 09:27
zsh/bash config.
# Include passwords/API keys etc, stored as env. (if exists)
if [ -f ~/.priv/env_config.sh ];
then
source ~/.priv/env_config.sh
fi
@mikaelbr
mikaelbr / mnb_gridsearch_test.py
Created February 26, 2013 09:53
A rudimentary experiment file for gridsearching on multinominal naive bayes classification.
#!/usr/bin/python
import sys
import numpy as np
import logging
from os import path
from sklearn import decomposition, linear_model
from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer
from sklearn.naive_bayes import MultinomialNB
from sklearn.pipeline import Pipeline
## Done training
# Stats for LogisticRegression
## Best params: {'vect__ngram_range': (1, 1), 'tfidf__smooth_idf': False, 'tfidf__sublinear_tf': True, 'vect__preprocessor': <function no_usernames at 0xa1540d4>, 'tfidf__use_idf': True, 'vect__stop_words': None, 'clf__penalty': 'l1', 'clf__C': 2.0}
## Best Score: 0.68442947358
precision recall f1-score support
"negative" 0.51 0.24 0.33 384
"objective" 0.67 0.84 0.75 1326
"positive" 0.73 0.62 0.67 968
@mikaelbr
mikaelbr / SA_output.log
Created March 11, 2013 18:15
Sentiment Analysis Grid Search Output log
######################################################################
# Showing for <methods.boost.Boosting object at 0x916aa6c>
# Total Score: 0.638452237001
precision recall f1-score support
negative 0.74 0.21 0.32 340
neutral 0.61 0.85 0.71 739
positive 0.67 0.62 0.65 575
avg / total 0.66 0.64 0.61 1654
@mikaelbr
mikaelbr / score.out
Created March 13, 2013 09:56
Score output for predictions
TASK B
Comparing predictions demo.pred to gold standard twitter-dev-gold-B.tsv.
File: demo.pred -- no errors found
Prediction file: 1654 lines
1654 unique
Breakdown by class:
positive 580
neutral 891
negative 183
File: twitter-dev-gold-B.tsv -- no errors found
######################################################################
# Showing for <models.svm.SVM object at 0x1052c9f90>
Best params: {'steps': [('vect', TfidfVectorizer(analyzer='word', binary=False, charset='utf-8',
charset_error='ignore', dtype=<type 'long'>, input='content',
lowercase=True, max_df=1.0, max_features=None, max_n=None,
min_df=2, min_n=None, ngram_range=(1, 1), norm='l2',
preprocessor=<function remove_noise at 0x104787410>,
smooth_idf=True, stop_words=None, strip_accents=None,
sublinear_tf=True, token_pattern=u'(?u)\\b\\w\\w+\\b',
tokenizer=<function tokenize at 0x104787848>, use_idf=False,
@mikaelbr
mikaelbr / index.html
Created September 15, 2013 11:18
A simple piano-key to sound script based on michaelmp/js-piano. Index.html shows how the actual sounds are included.
<!DOCTYPE html>
<html>
<head>
<title>FRP Piano</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<audio id="sound-A2" src="samples/A2.ogg" preload="auto"></audio>
<audio id="sound-B2" src="samples/B2.ogg" preload="auto"></audio>
# An example of Functional Reactive Programming, by implementing a
# simple collaborative piano.
# By Mikael Brevik <@mikaelbr>
socket = io.connect()
scale = [
'A2', 'Bb2', 'B2', 'C3', 'Db3', 'D3', 'Eb3', 'E3', 'F3', 'Gb3', 'G3', 'Ab3',
'A3', 'Bb3', 'B3', 'C4', 'Db4', 'D4', 'Eb4', 'E4', 'F4', 'Gb4', 'G4', 'Ab4',
'A4', 'Bb4', 'B4', 'C5'
<div id="p-wrapper">
<ul id="piano">
<li><div class="anchor clickable" data-note="A2"></div></li>
<li><div class="anchor clickable" data-note="B2"></div><span></span></li>
<li><div class="anchor clickable" data-note="C3"></div></li>
<li><div class="anchor clickable" data-note="D3"></div><span></span></li>
<li><div class="anchor clickable" data-note="E3"></div><span></span></li>
<li><div class="anchor clickable" data-note="F3"></div></li>
<li><div class="anchor clickable" data-note="G3"></div><span></span></li>
<li><div class="anchor clickable" data-note="A3"></div><span></span></li>