Skip to content

Instantly share code, notes, and snippets.

View egpbos's full-sized avatar

Patrick Bos egpbos

View GitHub Profile
#!/usr/bin/env python
# coding: utf-8
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
import collections
import networkx as nx
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
def remove_text(figure):
figure.suptitle("")
for ax in figure.get_axes():
ax.set_title("")
ax.xaxis.set_major_formatter(mpl.ticker.NullFormatter())
ax.xaxis.set_minor_formatter(mpl.ticker.NullFormatter())
#include <complex>
#include <iostream>
template <typename T> using real_t = T;
template < typename precision, template <typename> class input_t, template <typename> class output_t >
void do_stuff(input_t<precision> a, output_t<precision> b) {
std::cout << a + b << std::endl;
}
@egpbos
egpbos / xtensor-io.md
Created January 17, 2018 05:56
Installing xtensor-io on macOS

Installing xtensor-io on macOS high sierra

Do all of this in a conda env

conda create -n this_env
source activate this_env
struct plan_pkg {
unsigned N1, N2, N3;
ULONG N;
ULONG Nhalf;
complex_prec *C;
real_prec *R;
#ifdef SINGLE_PREC
fftwf_plan plan;
#endif
#ifdef DOUBLE_PREC
@egpbos
egpbos / pandas_loading_benchmarks.ipynb
Created September 3, 2018 15:16
benchmarks of loading key-list text file into Pandas
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@egpbos
egpbos / Python, King of data science.ipynb
Created August 29, 2018 07:40
Python, King of data science
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@egpbos
egpbos / laughter_labels_tfidf.py
Last active January 12, 2022 13:45
Use tf-idf to give weights to Google API video labels
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
data = pd.read_csv('google_api_frame_dec6.csv')
# We can look at unique labels for each video, or take into account that
# labels may occur multiple times in a single video (in different frames
# for instance). In this dataset, there are no separate frames, the labels
# are already unique, so this will work. In case there is per frame data
# for each video, groupby+unique should be replaced by something like
@egpbos
egpbos / demo.cpp
Last active April 10, 2024 21:38
RooFit::MultiProcess demo - RooFit Users Workshop 2024
// run on ROOT 6.28+ built with -Droofit_multiprocess=ON
// root -l demo.cpp
// or call `demo(YOUR FAVORITE NUMBER OF CPUS)` inside root
#include "RooWorkspace.h"
#include "RooAbsPdf.h"
#include "RooDataSet.h"
#include "RooMinimizer.h"
void demo(int number_of_workers = 2)