Skip to content

Instantly share code, notes, and snippets.

View pjankiewicz's full-sized avatar

Paweł Jankiewicz pjankiewicz

View GitHub Profile
@pjankiewicz
pjankiewicz / struct_symbols.rs
Created September 27, 2020 09:10
Using symbols to refer to structs
#![allow(dead_code)]
use std::collections::HashMap;
#[derive(PartialEq)]
struct Click {
item_id: String,
}
#[derive(PartialEq)]
@pjankiewicz
pjankiewicz / mercari.py
Created March 1, 2019 20:04
Ludwig model
import numpy as np
import pandas as pd
from ludwig import LudwigModel
from sklearn.model_selection import train_test_split
df = pd.read_csv("input/train.tsv", sep="\t")
df["log_price"] = np.log1p(df["price"])
model = LudwigModel({
"input_features": [
@pjankiewicz
pjankiewicz / mercari.py
Created March 1, 2019 20:03
Mercari code golf
import os;
os.environ['OMP_NUM_THREADS'] = '1'
from contextlib import contextmanager
from functools import partial
from operator import itemgetter
from multiprocessing.pool import ThreadPool
import time
from typing import List, Dict
@pjankiewicz
pjankiewicz / flow-field-step-1.markdown
Created November 2, 2018 11:55
Flow Field, Step 1
import gzip
import base64
import os
import sys
sys.path.append('/kaggle/working')
# this is base64 encoded source code
file_data = {...}
os.system('mkdir mercari')
@pjankiewicz
pjankiewicz / hclassifier.py
Created January 11, 2017 14:45
Hierarchical Classifier
import numpy as np
from sklearn.base import BaseEstimator, ClassifierMixin, clone
from collections import defaultdict
class HClassifier(BaseEstimator, ClassifierMixin):
ROOT = object()
def __init__(self, base_estimator, min_obs=None, max_level=None):
self.base_estimator = base_estimator
@pjankiewicz
pjankiewicz / 0_reuse_code.js
Created October 14, 2016 13:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
package main
import (
"fmt"
"net/http"
)
type storageData struct {
data string
}
#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])
@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})