Skip to content

Instantly share code, notes, and snippets.

View spolu's full-sized avatar

Stanislas Polu spolu

View GitHub Profile
@spolu
spolu / draw.js
Last active August 29, 2015 14:08
Christmas Draw
var async = require('async');
var send = function(html, email, cb_) {
var sg = new (require('sendgrid').SendGrid)('teleportd',
'<PASSWORD>');
sg.send({
to: email,
from: '[email protected]',
fromname: 'Christmas Bot',
subject: 'Noyel 2014 - Cadeaux de cousins - FINAL!',
@spolu
spolu / post_detection_results
Last active August 29, 2015 14:08
Post Detection Results
algorithm , avg.time, false_positive, false_negative, correct
----------------------------------------------------------------------
phash[10] , 254ms, 0, 8, 1092
phash[20] , 253ms, 0, 2, 1098
phash[30] , 253ms, 254, 0, 846
puzzle[0.4] , 44ms, 0, 6, 1094
puzzle[0.5] , 44ms, 3, 2, 1095
puzzle[0.6] , 42ms, 21, 1, 1078
phash-pp[20, 240] , 104ms, 0, 1, 1099
phash-pp[20, 120] , 80ms, 0, 2, 1098
@spolu
spolu / hash_distance.js
Last active August 29, 2015 14:07
Hash Distance
var LIBRARY = ...;
var THRESHOLD = ...;
function compare(image_1, image_2) {
/* h1 and/or h2 can be stored in database. */
var h1 = LIBRARY.hash(image_1);
var h2 = LIBRARY.hash(image_2);
var d = LIBRARY.distance(h1, h2);
@spolu
spolu / nn_initial.log
Last active August 29, 2015 14:06
NN Initial Results
Type, L1, L2, L3, Cov, Err, Train, It, Res
--------------------------------------------------------
hashtags, 1000, 10, 2, -, 0.05, 2000, -, 0.73
hashtags, 1000, -, 2, -, 0.05, 2000, -, 0.73
hashtags, 1000, 50, 2, -, 0.05, 10000, -, 0.75
hashtags, 2000, 50, 2, -, 0.03, 10000, -, 0.78
hashtags, 1000, 50, 2, -, 0.03, 10000, -, 0.76
hashtags, 4000, -, 2, 47.44, 0.05, 10000, 4, 0.78
words, 4000, -, 2, 34.82, 0.03, 4000, 2, 0.75
words, 2000, 50, 2, 27.66, 0.03, 10000, 135, 0.75
@spolu
spolu / nn_train.cc
Created September 23, 2014 00:24
NN train
do {
err = 0;
for(unsigned int i = 0; i < train_in_.size(); i++) {
vector<double> res = this->learn(train_in_[i], train_out_[i]);
/* error calculation */
double e = 0;
for(unsigned int j = 0; j < res.size(); j++) {
e += pow(res[j] - train_out_[i][j], 2);
}
err += e / res.size();
@spolu
spolu / nn_activation.cc
Created September 22, 2014 23:41
NN activation function
for(int j = 0; j < layers_[l-1]; j++) {
sum_[l][i] += W_[l][i][j] * val_[l-1][j];
}
/* Activation function */
val_[l][i] = 1 / (1 + exp(-sum_[l][i]));
@spolu
spolu / nn_def.hh
Created September 22, 2014 23:25
Neural Network Definition
//
// ## NN Class
//
class NN : public ObjectWrap {
/* ... */
vector<int> layers_; /* layers structure */
vector< vector< vector<double> > > W_; /* weights */
/* ... */
};
@spolu
spolu / top_male_cond
Last active August 29, 2015 14:06
Top Male Terms
TOP MENs WORDS [P(M|feat)]
┌───────────────────┬────────────────────────┬─────────────────────┬─────────────────────┬─────────┐
│ feat │ MI │ P(F|feat) │ P(M|feat) │ count │
├───────────────────┼────────────────────────┼─────────────────────┼─────────────────────┼─────────┤
│ instagay │ 0.00022357298801020352 │ 0.08653846153846154 │ 0.9134615384615384 │ 4576 │
│ instaboy │ 0.00028438645833364835 │ 0.11872780608306316 │ 0.8812721939169369 │ 6477 │
│ beard │ 0.00023996501077783796 │ 0.13137099960489926 │ 0.8686290003951008 │ 5062 │
│ bmw │ 0.00023463541132113985 │ 0.17349643221202854 │ 0.8265035677879714 │ 4905 │
│ ps3 │ 0.00024576041454740495 │ 0.17954588818927686 │ 0.8204541118107231 │ 5241 │
│ legend │ 0.000242332533506523 │ 0.2024133904242896 │ 0.7975866095757104 │ 5138 │
@spolu
spolu / top_female_cond.log
Last active August 29, 2015 14:06
Top Female Terms
TOP WOMENs WORDS [P(F|feat)]
┌─────────────────┬────────────────────────┬────────────────────┬─────────────────────┬────────┐
│ feat │ MI │ P(F|feat) │ P(M|feat) │ count │
├─────────────────┼────────────────────────┼────────────────────┼─────────────────────┼────────┤
│ obrigada │ 0.00027892588535643266 │ 0.9685880320402072 │ 0.03141196795979268 │ 6367 │
│ nails │ 0.0005797362527263134 │ 0.9323099021456146 │ 0.0676900978543855 │ 22278 │
│ nail │ 0.0003044173746727099 │ 0.9318902523093892 │ 0.06810974769061078 │ 7253 │
│ lipstick │ 0.00027485524057785637 │ 0.9307852898667095 │ 0.0692147101332905 │ 6227 │
│ nomakeup │ 0.00027682050785528235 │ 0.9210108073744437 │ 0.07898919262555626 │ 6292 │
│ girly │ 0.00027218400694593495 │ 0.9180381293791755 │ 0.08196187062082451 │ 6137 │
@spolu
spolu / top_mi.log
Created September 22, 2014 21:46
Top Mutually dependent Terms
┌───────────────────┬────────────────────────┬─────────────────────┬─────────────────────┬────────┐
│ feat │ MI │ P(F|feat) │ P(M|feat) │ count │
├───────────────────┼────────────────────────┼─────────────────────┼─────────────────────┼────────┤
│ 2013 │ 0.0007369516096940501 │ 0.4390515775552617 │ 0.5609484224447384 │ 52930 │
│ some │ 0.000736858500749544 │ 0.445240713107673 │ 0.5547592868923271 │ 50932 │
│ old │ 0.0007365194018360236 │ 0.4566446562018109 │ 0.5433553437981891 │ 50582 │
│ followme │ 0.0007364834465793508 │ 0.4685242121445043 │ 0.5314757878554958 │ 52040 │
│ em │ 0.0007364028645929781 │ 0.47138620491724864 │ 0.5286137950827514 │ 52265 │
│ 1 │ 0.0007363022436669361 │ 0.47312624679395837 │ 0.5268737532060416 │ 52635 │
│ picoftheday │ 0.000736169463191504 │ 0.41519248894366706 │ 0.5848075110563329 │ 55172 │