Skip to content

Instantly share code, notes, and snippets.

View pjankiewicz's full-sized avatar

Paweł Jankiewicz pjankiewicz

View GitHub Profile
@pjankiewicz
pjankiewicz / gist:8075167
Created December 21, 2013 21:13
Install R 2.15 - linux mint
cd /tmp
wget http://cran.r-project.org/src/base/R-2/R-2.15.2.tar.gz
# You can download latest R version from CRAN
# Go to http://cran.r-project.org/
# or Go & choose what u want:- http://cran.r-project.org/src/base/
# Untar
tar -xzf R-2.15.2.tar.gz
cd R-2.15.2
@pjankiewicz
pjankiewicz / gist:8087446
Last active January 1, 2016 03:48
python pandas left join function
def left_join(df1, df2, key, cols, lsuffix="", rsuffix="", default_value=None):
if type(key) != list:
key_left, key_right = key, key
else:
key_left, key_right = key[0], key[1]
if type(cols) != list:
cols = [cols,]
ind = pd.match(df1[key], df2[key])
@pjankiewicz
pjankiewicz / mp.py
Created June 26, 2014 16:56
multiprocessing shared array
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 26 13:00:02 2014
@author: pawel
"""
import multiprocessing as mp
import numpy as np
import logging
from textblob import TextBlob, Word
from features.skipgrams import EssaySkipgram
from features.essay_feature import EssayFeature, FunctionalTextEssayFeature, EssayTextConversion
from features.text_features import *
from features.word2vec_word_clusters import EssayTextToW2VClusters
from features.wiki_ngram_coverage import check_1gram_coverage, check_2gram_coverage, check_3gram_coverage
from features.convert_text_to_definitions import convert_text_to_definitions
#from features.word2vec_features import EssayWord2Vec, EssayWord2VecFirstWords
@pjankiewicz
pjankiewicz / gist:85a9fd1f1cb240e3519b
Created October 11, 2014 20:24
generic function (liberty fire)
def model_generic(data, model_f, n_folds=10, feature_selection_f=None, feature_transform_f=None, save_as=None, make_predictions=False, standard_model=False):
# save as
if os.path.exists(save_as):
print("Skipping",save_as)
return None
else:
touch(save_as)
nobs_tr = data["train"]["X"].shape[0]
@pjankiewicz
pjankiewicz / gist:09fed5b892c00a5efe02
Created October 26, 2014 06:16
Useful linux commands
// adds ssh key to a server
cat ~/.ssh/id_rsa.pub | ssh -l root 1.1.1.1 'cat >> .ssh/authorized_keys'
@pjankiewicz
pjankiewicz / gist:e7b6a6d1d6a76ad74a1c
Created October 26, 2014 09:41
Useful git commands
// discards all changes to the code (without commiting)
git checkout -- .
@pjankiewicz
pjankiewicz / gist:8ab7094d263bf0d4cfb8
Last active September 9, 2016 03:04
kaggle vazu
'''
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
@pjankiewicz
pjankiewicz / gist:8f4898034f2f4d7eb3d7
Last active May 8, 2020 02:51
clojure cheat sheet
; this is a comment
; this is a double function
(defn doublen [x] (* x 2))
; basic collections (lists, vectors, maps)
(def a-list '(1 2 3))
(def a-vector [1 2 3])
(def a-map {:key1 val1 :key2 val2})
#dataX - variables
#datay - labels
rows = dataX.shape[0]
out_of_fold_predictions = zeros(rows) # this is our out of fold prediction vector
for tr, te in cross_validation(10):
model = fit(dataX[tr,], datay[tr])