This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thisField.setValue(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
pd.set_option('display.mpl_style', 'default') | |
pd.set_option('display.width', 200) | |
pd.set_option('display.max_columns', 20) | |
pd.set_option('display.max_rows', 50) | |
pd.set_option('precision', 5) | |
import matplotlib.pyplot as plt | |
import seaborn as sns |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fscore = [ (v,k) for k,v in clf.get_fscore().iteritems() ] | |
fscore.sort(reverse=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### for brand-new only | |
sudo apt-get update | |
sudo apt-get install htop | |
sudo apt-get install build-essential | |
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh | |
bash Miniconda3-latest-Linux-x86_64.sh | |
rm Miniconda3-latest-Linux-x86_64.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
sns.set() | |
scores = pd.read_csv('liberty-mutual-group-property-inspection-prediction_public_leaderboard.csv') | |
scores['SubmissionDate'] = [time.date() for time in scores['SubmissionDate'].astype('datetime64[ns]')] | |
scores['SubmissionDate'] = [time for time in scores['SubmissionDate'].astype(str)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plt.style.use('bmh') | |
colors = ['#348ABD', '#A60628', '#7A68A6', '#467821', '#D55E00', | |
'#CC79A7', '#56B4E9', '#009E73', '#F0E442', '#0072B2'] | |
https://github.com/rasbt/matplotlib-gallery |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install make | |
sudo apt-get update | |
sudo apt-get install gcc | |
sudo apt-get install g++ | |
sudo apt-get install git | |
sudo git clone https://github.com/dmlc/xgboost | |
cd xgboost | |
./build.sh | |
cd python-package | |
python setup.py install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.dataiku.com/blog/2015/08/24/xgboost_and_dss.html | |
from pandas.core.categorical import Categorical | |
from scipy.sparse import csr_matrix | |
import numpy as np | |
def sparse_dummies(categorical_values): | |
categories = Categorical.from_array(categorical_values) | |
N = len(categorical_values) | |
row_numbers = np.arange(N, dtype=np.int) | |
ones = np.ones((N,)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.dataiku.com/blog/2015/08/24/xgboost_and_dss.html | |
import dataiku | |
import pandas as pd, numpy as np | |
from dataiku import pandasutils as pdu | |
from sklearn.metrics import roc_auc_score | |
import xgboost as xgb | |
from hyperopt import hp, fmin, tpe, STATUS_OK, Trials | |
train = dataiku.Dataset("train").get_dataframe() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy import exp, log | |
from scipy.special import gammaln | |
def prob_unique(N, r): | |
""" If you have a set of N things to choose from, and take r samples, | |
the probability that all r samples are unique. | |
http://www.johndcook.com/blog/2016/01/30/general-birthday-problem | |
""" | |
return exp( gammaln(N+1) - gammaln(N-r+1) - r*log(N) ) |
OlderNewer