Skip to content

Instantly share code, notes, and snippets.

View DeanLa's full-sized avatar
💭
🐼

Dean Langsam DeanLa

💭
🐼
View GitHub Profile
@galbraun
galbraun / xgboost_leaf_paths_extractor.py
Created August 9, 2020 13:06
Functions to extract for a xgboost forest for each tree and each leaf - the middle nodes that create the path to reach it.
def _root_to_leaf_route(df, stack, routes):
current_node = df.loc[df.Node == stack[-1]]
if current_node.Feature.values[0] == 'Leaf':
routes[current_node.Node.values[0]] = list(stack)
stack.pop()
return
stack.append(int(current_node.Yes.values[0].split('-')[1]))
_root_to_leaf_route(df, stack, routes)
stack.append(int(current_node.No.values[0].split('-')[1]))
_root_to_leaf_route(df, stack, routes)
@yoavram
yoavram / build_tf.sh
Created April 11, 2018 08:21
Build TensorFlow on MacOS as of Dec 21 2017
# https://www.tensorflow.org/install/install_sources
brew install bazel
conda create -n tensorflow python six numpy wheel -y
source activate tensorflow
git clone https://github.com/tensorflow/tensorflow
cd tensorflow
./configure
@schledererj
schledererj / fetchall_athena.py
Created February 19, 2018 19:09
Using boto3 and paginators to query an AWS Athena table and return the results as a list of tuples as specified by .fetchall in PEP 249
# Does NOT implement the PEP 249 spec, but the return type is suggested by the .fetchall function as specified here: https://www.python.org/dev/peps/pep-0249/#fetchall
import time
import boto3
# query_string: a SQL-like query that Athena will execute
# client: an Athena client created with boto3
def fetchall_athena(query_string, client):
query_id = client.start_query_execution(
QueryString=query_string,