Skip to content

Instantly share code, notes, and snippets.

@olinguyen
olinguyen / autoexec.cfg
Created April 13, 2017 04:38
CS:GO Config
// Keybad gun bindings
bind "KP_INS" "buy defuser"
bind "KP_END" "buy ak47; buy m4a1;"
bind "KP_DOWNARROW" "buy galil; buy famas"
bind "KP_PGDN" "buy awp"
bind "KP_LEFTARROW" "buy p250"
bind "KP_5" "buy p90"
bind "KP_RIGHTARROW" "buy mp7"
bind "KP_HOME" "buy deagle"
bind "KP_UPARROW" "buy vest"
@olinguyen
olinguyen / shogun_cv_error.py
Last active May 31, 2017 18:30
Shogun Crossvalidation Error
"""
The following code crashes with this error message:
---> 15 result = cv.evaluate()
SystemError: [ERROR] In file /build/shogun-v9ad6W/shogun-6.0.0+1SNAPSHOT201704270057/src/shogun/labels/Labels.cpp
line 67: assertion m_current_values.vector && idx < get_num_labels() failed in
virtual float64_t shogun::CLabels::get_value(int32_t)
file /build/shogun-v9ad6W/shogun-6.0.0+1SNAPSHOT201704270057/src/shogun/labels/Labels.cpp line 67
"""
import numpy as np
from modshogun import *
roc = ROCEvaluation()
roc.evaluate(y_pred, y_test)
auc = roc.get_auROC()
print(auc) # 0.845606993532
roc = ROCEvaluation()
import numpy as np
from modshogun import *
features_train = RealFeatures(np.random.random_sample((10, 5)))
features_test = RealFeatures(np.random.random_sample((10, 5)))
labels_train = MulticlassLabels(np.array([np.random.randint(3) for i in range(5)]).astype(np.float))
labels_test = MulticlassLabels(np.array([np.random.randint(3) for i in range(5)]).astype(np.float))
m_vote = MajorityVote()
@olinguyen
olinguyen / shogun-multiclasslabels-integer-init.py
Created July 24, 2017 22:28
Can't initialize MulticlassLabels with an integer array
import numpy as np
from modshogun import MulticlassLabels
int_labels = np.array([0, 1, 2], dtype=np.int)
MulticlassLabels(int_labels)
MulticlassLabels(int_labels.astype(np.int32))
@olinguyen
olinguyen / shogun-multiclass-svc.py
Created July 24, 2017 23:06
sklearn and shogun's multiclass SVC produce different results (predictions and confidence values)
import numpy as np
import matplotlib.pyplot as plt
from sklearn import svm, datasets
# import some data to play with
iris = datasets.load_iris()
num_samples = len(iris.data)
np.random.seed(seed=42)
@olinguyen
olinguyen / rf-output-sklearn.py
Created July 26, 2017 19:34
RandomForest doesn't give the same outputs when comparing shogun & sklearn
import numpy as np
import matplotlib.pyplot as plt
from sklearn import svm, datasets
from sklearn.ensemble import RandomForestClassifier
from modshogun import *
#np.random.seed(42)
X = np.array([[-1.0, -1.0], [-1.2, -1.4], [-3.4, -2.2], [1.1, 1.2]])
y = np.array([0, 0, 1, 1]).astype(np.float)
@olinguyen
olinguyen / shogun-randomforest-toydata.py
Last active August 4, 2017 17:53
Shogun unit test toy data generation for random forest
# Generates data for y = (x1 v x2) > 5
import numpy as np
from sklearn.ensemble import RandomForestClassifier
X1 = np.random.randint(5, 10, size=(5, 2))
X2 = np.random.randint(0, 5, size=(5, 2))
X = np.concatenate((X1, X2))
y = [1.0 if i > 5 else 0.0 for i in range(10)]
@olinguyen
olinguyen / gsoc-summary.md
Last active December 9, 2018 12:08
GSoC 2017 Shogun Data Project

GSoC 2017 Final Report: Data Project - Patient Monitoring and Decision Support using Health Data

Name: Olivier Nguyen

Mentors: Lea Goetz, Heiko Strathmann

Organization: Shogun Machine Learning Toolbox

Abstract