<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <h1 class="title">Example-Dependent Cost-Sensitive Fraud Detection using CostCla</h1>
<center>
<h2>Alejandro Correa Bahnsen, PhD</h2>
<p>
<h2>Data Scientist</h2>
<p>
<div>
<img img class="logo" src="https
Step1:  Data file
Step2:  Class Label
Step3:  Features
Step4:  Features
Step5:  Aggregated Features
Step6:  Fraud Detection as a  classification problem
Split in training and testing
Step7:  Fraud Detection as a classification problem
Fit models
Step8:  Models performance
Evaluate metrics and plot results
Step9:  Models performance
Step10:  Models performance
Step11:  Models performance
None of these measures takes into account the business and economical realities that take place in fraud detection. 
Losses due to fraud or customer satisfaction costs, are not considered in the evaluation of the different models. 
<h1 class="bigtitle">Financial Evaluation of a Fraud Detection Model</h1>
Motivation
Typically, a fraud model is evaluated using standard cost-insensitive measures.
However, in practice, the cost associated with approving a fraudulent transaction (False Negative) is quite   different from the cost associated with declining a legitimate transaction (False Positive).
Furthermore, the costs are not constant among transactions. 
Cost Matrix
|   | Actual Positive ($y_i=1$)     |  Actual Negative  ($y_i=0$)|
|---    |
Step12:  Financial savings
The financial cost of using a classifier $f$ on $\mathcal{S}$ is calculated by
$$   Cost(f(\mathcal{S})) = \sum_{i=1}^N  y_i(1-c_i)C_{FN_i} + (1-y_i)c_i C_{FP_i}.$$
Then the financial savings are defined as the cost of the algorithm versus the cost of using no algorithm at all.
$$    Savings(f(\mathcal{S})) = \frac{ Cost_l(\mathcal{S}) - Cost(f(\mathcal{S}))}   {Cost_l(\mathcal{S})},$$
where $Cost_l(\mathcal{S})$ is the cost of the costless class
Models Savings
costcla.metrics.savings_score(y_true, y_pred, cost_mat)
Step13:  Models Savings
Step14:  Threshold Optimization
Convert a classifier cost-sensitive by selecting a proper threshold
from training instances according to the savings
$$ t  \quad = \quad argmax_t \
Step15:  Threshold Optimization
Step16:  Models Savings
There are significant differences in the results when evaluating a model using a  traditional cost-insensitive measures
Train models that take into account the different financial costs
<h1 class="bigtitle">Example-Dependent Cost-Sensitive Classification</h1>
*Why "Example-Dependent"
Cost-sensitive classification ussualy refers to class-dependent costs, where the cost dependends on the class but is assumed constant accross examples.
In fraud detection, different transactions have different amounts, which implies that the costs are not constant
Bayes Minimum Risk (BMR)
The BMR classifier is a decision model based on quantifying tradeoffs between various decisions using probabilities and the costs that accompany such decisions. 
In particular
Step17:  BMR Results
Step18:  BMR Results
Why so important focusing on the Recall
Average cost of a False Negative
Step19:  Average cost of a False Positive
Step20:  BMR Results
Bayes Minimum Risk increases the savings by using a cost-insensitive method and then introducing the costs
Why not introduce the costs during the estimation of the methods?
Cost-Sensitive Decision Trees (CSDT)
A a new cost-based impurity measure taking into account the costs when all the examples in a leaf
costcla.models.CostSensitiveDecisionTreeClassifier(criterion='direct_cost', criterion_weight=False, pruned=True)
Cost-Sensitive Random Forest (CSRF)
Ensemble of CSDT
costcla.models.CostSensitiveRandomForestClassifier(n_estimators=10, max_samples=0.5, max_features=0.5,combination='majority_voting)
CSDT & CSRF Code
Step21:  CSDT & CSRF Results
Step23:  Lessons Learned (so far ...)
Selecting models based on traditional statistics does not give the best results in terms of cost
Models should be evaluated taking into account real financial costs of the application
Algorithms should be developed to incorporate those financial costs
<center>
<img src="https
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from costcla import datasets
from costcla.datasets.base import Bunch
def load_fraud(cost_mat_parameters=dict(Ca=10)):
#     data_ = pd.read_pickle("trx_fraud_data.pk")
    data_ = pd.read_pickle("/home/al/DriveAl/EasySol/Projects/DetectTA/Tests/trx_fraud_data_v3_agg.pk")
    target = data_['fraud'].values
    data = data_.drop('fraud', 1)
    n_samples = data.shape[0]
    cost_mat = np.zeros((n_samples, 4))
    cost_mat[:, 0] = cost_mat_parameters['Ca']
    cost_mat[:, 1] = data['amount']
    cost_mat[:, 2] = cost_mat_parameters['Ca']
    cost_mat[:, 3] = 0.0
    return Bunch(data=data.values, target=target, cost_mat=cost_mat,
                 target_names=['Legitimate Trx', 'Fraudulent Trx'], DESCR='',
                 feature_names=data.columns.values, name='FraudDetection')
datasets.load_fraud = load_fraud
data = datasets.load_fraud()
Explanation: <h1 class="title">Example-Dependent Cost-Sensitive Fraud Detection using CostCla</h1>
<center>
<h2>Alejandro Correa Bahnsen, PhD</h2>
<p>
<h2>Data Scientist</h2>
<p>
<div>
<img img class="logo" src="https://raw.githubusercontent.com/albahnsen/CostSensitiveClassification/master/doc/tutorials/files/logo_easysol.jpg" style="width: 400px;">
</div>
<h3>PyCaribbean, Santo Domingo, Dominican Republic, Feb 2016</h3>
</center>
<h1 class="bigtitle">About Me</h1>
%%html
<style>
table,td,tr,th {border:none!important}
</style>
### A brief bio:
* PhD in **Machine Learning** at Luxembourg University
* Data Scientist at Easy Solutions
* Worked for +8 years as a data scientist at GE Money, Scotiabank and SIX Financial Services
* Bachelor in Industrial Engineering and Master in Financial Engineering
* Organizer of Big Data & Data Science Bogota Meetup
* Sport addict, love to swim, play tennis, squash, and volleyball, among others.
<p>
<table style="border-collapse: collapse; border-top-color: rgb(255, 255, 255); border-right-color: rgb(255, 255, 255); border-bottom-color: rgb(255, 255, 255); border-left-color: rgb(255, 255, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; " border="0" bordercolor="#888" cellspacing="0" align="left">
  <tr>
    <td>
<a href="mailto: al.bahnsen@gmail.com"><svg width="40px" height="40px" viewBox="0 0 60 60" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
    <path d="M0.224580688,30 C0.224580688,13.4314567 13.454941,0 29.7754193,0 C46.0958976,0 59.3262579,13.4314567 59.3262579,30 C59.3262579,46.5685433 46.0958976,60 29.7754193,60 C13.454941,60 0.224580688,46.5685433 0.224580688,30 Z M0.224580688,30" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
    <path d="M35.0384324,31.6384006 L47.2131148,40.5764264 L47.2131148,20 L35.0384324,31.6384006 Z M13.7704918,20 L13.7704918,40.5764264 L25.9449129,31.6371491 L13.7704918,20 Z M30.4918033,35.9844891 L27.5851037,33.2065217 L13.7704918,42 L47.2131148,42 L33.3981762,33.2065217 L30.4918033,35.9844891 Z M46.2098361,20 L14.7737705,20 L30.4918033,32.4549304 L46.2098361,20 Z M46.2098361,20" id="Shape" fill="#333333" sketch:type="MSShapeGroup"></path>
    <path d="M59.3262579,30 C59.3262579,46.5685433 46.0958976,60 29.7754193,60 C23.7225405,60 18.0947051,58.1525134 13.4093244,54.9827754 L47.2695458,5.81941103 C54.5814438,11.2806503 59.3262579,20.0777973 59.3262579,30 Z M59.3262579,30" id="reflec" fill-opacity="0.08" fill="#000000" sketch:type="MSShapeGroup"></path>
</svg></a> 
</td> 
<td>
<a href="mailto: al.bahnsen@gmail.com" target="_blank">al.bahnsen@gmail.com</a>  
</td> </tr><tr> <td>
<a href="http://github.com/albahnsen"><svg width="40px" height="40px" viewBox="0 0 60 60" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
    <path d="M0.336871032,30 C0.336871032,13.4314567 13.5672313,0 29.8877097,0 C46.208188,0 59.4385483,13.4314567 59.4385483,30 C59.4385483,46.5685433 46.208188,60 29.8877097,60 C13.5672313,60 0.336871032,46.5685433 0.336871032,30 Z M0.336871032,30" id="Github" fill="#333333" sketch:type="MSShapeGroup"></path>
    <path d="M18.2184245,31.9355566 C19.6068506,34.4507902 22.2845295,36.0156764 26.8007287,36.4485173 C26.1561023,36.9365335 25.3817877,37.8630984 25.2749857,38.9342607 C24.4644348,39.4574749 22.8347506,39.62966 21.5674303,39.2310659 C19.7918469,38.6717023 19.1119377,35.1642642 16.4533306,35.6636959 C15.8773626,35.772144 15.9917933,36.1507609 16.489567,36.4722998 C17.3001179,36.9955141 18.0629894,37.6500075 18.6513541,39.04366 C19.1033554,40.113871 20.0531304,42.0259813 23.0569369,42.0259813 C24.2489236,42.0259813 25.0842679,41.8832865 25.0842679,41.8832865 C25.0842679,41.8832865 25.107154,44.6144649 25.107154,45.6761142 C25.107154,46.9004355 23.4507693,47.2457569 23.4507693,47.8346108 C23.4507693,48.067679 23.9990832,48.0895588 24.4396415,48.0895588 C25.3102685,48.0895588 27.1220883,47.3646693 27.1220883,46.0918317 C27.1220883,45.0806012 27.1382993,41.6806599 27.1382993,41.0860982 C27.1382993,39.785673 27.8372803,39.3737607 27.8372803,39.3737607 C27.8372803,39.3737607 27.924057,46.3153869 27.6704022,47.2457569 C27.3728823,48.3397504 26.8360115,48.1846887 26.8360115,48.6727049 C26.8360115,49.3985458 29.0168704,48.8505978 29.7396911,47.2571725 C30.2984945,46.0166791 30.0543756,39.2072834 30.0543756,39.2072834 L30.650369,39.1949165 C30.650369,39.1949165 30.6837446,42.3123222 30.6637192,43.7373675 C30.6427402,45.2128317 30.5426134,47.0792797 31.4208692,47.9592309 C31.9977907,48.5376205 33.868733,49.5526562 33.868733,48.62514 C33.868733,48.0857536 32.8436245,47.6424485 32.8436245,46.1831564 L32.8436245,39.4688905 C33.6618042,39.4688905 33.5387911,41.6768547 33.5387911,41.6768547 L33.5988673,45.7788544 C33.5988673,45.7788544 33.4186389,47.2733446 35.2190156,47.8992991 C35.8541061,48.1209517 37.2139245,48.1808835 37.277815,47.8089257 C37.3417055,47.4360167 35.6405021,46.8814096 35.6252446,45.7236791 C35.6157088,45.0178155 35.6567131,44.6059032 35.6567131,41.5379651 C35.6567131,38.470027 35.2438089,37.336079 33.8048426,36.4323453 C38.2457082,35.9766732 40.9939527,34.880682 42.3337458,31.9450695 C42.4383619,31.9484966 42.8791491,30.5737742 42.8219835,30.5742482 C43.1223642,29.4659853 43.2844744,28.1550957 43.3168964,26.6025764 C43.3092677,22.3930799 41.2895654,20.9042975 40.9014546,20.205093 C41.4736082,17.0182425 40.8060956,15.5675121 40.4961791,15.0699829 C39.3518719,14.6637784 36.5149435,16.1145088 34.9653608,17.1371548 C32.438349,16.3998984 27.0982486,16.4712458 25.0957109,17.3274146 C21.4005522,14.6875608 19.445694,15.0918628 19.445694,15.0918628 C19.445694,15.0918628 18.1821881,17.351197 19.1119377,20.6569598 C17.8961113,22.2028201 16.9902014,23.2968136 16.9902014,26.1963718 C16.9902014,27.8297516 17.1828264,29.2918976 17.6176632,30.5685404 C17.5643577,30.5684093 18.2008493,31.9359777 18.2184245,31.9355566 Z M18.2184245,31.9355566" id="Path" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
    <path d="M59.4385483,30 C59.4385483,46.5685433 46.208188,60 29.8877097,60 C23.8348308,60 18.2069954,58.1525134 13.5216148,54.9827754 L47.3818361,5.81941103 C54.6937341,11.2806503 59.4385483,20.0777973 59.4385483,30 Z M59.4385483,30" id="reflec" fill-opacity="0.08" fill="#000000" sketch:type="MSShapeGroup"></path>
</svg></a>
</td><td>
<a href="http://github.com/albahnsen" target="_blank">http://github.com/albahnsen</a>  
</td> </tr><tr> <td>
<a href="http://linkedin.com/in/albahnsen"><svg width="40px" height="40px" viewBox="0 0 60 60" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
    <path d="M0.449161376,30 C0.449161376,13.4314567 13.6795217,0 30,0 C46.3204783,0 59.5508386,13.4314567 59.5508386,30 C59.5508386,46.5685433 46.3204783,60 30,60 C13.6795217,60 0.449161376,46.5685433 0.449161376,30 Z M0.449161376,30" fill="#007BB6" sketch:type="MSShapeGroup"></path>
    <path d="M22.4680392,23.7098144 L15.7808366,23.7098144 L15.7808366,44.1369537 L22.4680392,44.1369537 L22.4680392,23.7098144 Z M22.4680392,23.7098144" id="Path" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
    <path d="M22.9084753,17.3908761 C22.8650727,15.3880081 21.4562917,13.862504 19.1686418,13.862504 C16.8809918,13.862504 15.3854057,15.3880081 15.3854057,17.3908761 C15.3854057,19.3522579 16.836788,20.9216886 19.0818366,20.9216886 L19.1245714,20.9216886 C21.4562917,20.9216886 22.9084753,19.3522579 22.9084753,17.3908761 Z M22.9084753,17.3908761" id="Path" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
    <path d="M46.5846502,32.4246563 C46.5846502,26.1503226 43.2856534,23.2301456 38.8851658,23.2301456 C35.3347011,23.2301456 33.7450983,25.2128128 32.8575489,26.6036896 L32.8575489,23.7103567 L26.1695449,23.7103567 C26.2576856,25.6271338 26.1695449,44.137496 26.1695449,44.137496 L32.8575489,44.137496 L32.8575489,32.7292961 C32.8575489,32.1187963 32.9009514,31.5097877 33.0777669,31.0726898 C33.5610713,29.8530458 34.6614937,28.5902885 36.5089747,28.5902885 C38.9297703,28.5902885 39.8974476,30.4634101 39.8974476,33.2084226 L39.8974476,44.1369537 L46.5843832,44.1369537 L46.5846502,32.4246563 Z M46.5846502,32.4246563" id="Path" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
    <path d="M59.5508386,30 C59.5508386,46.5685433 46.3204783,60 30,60 C23.9471212,60 18.3192858,58.1525134 13.6339051,54.9827754 L47.4941264,5.81941103 C54.8060245,11.2806503 59.5508386,20.0777973 59.5508386,30 Z M59.5508386,30" id="reflec" fill-opacity="0.08" fill="#000000" sketch:type="MSShapeGroup"></path>
</svg></a> 
</td> <td>
<a href="http://linkedin.com/in/albahnsen" target="_blank">http://linkedin.com/in/albahnsen</a>  
</td> </tr><tr> <td>
<a href="http://twitter.com/albahnsen"><svg width="40px" height="40px" viewBox="0 0 60 60" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
    <path d="M0,30 C0,13.4314567 13.4508663,0 30.0433526,0 C46.6358389,0 60.0867052,13.4314567 60.0867052,30 C60.0867052,46.5685433 46.6358389,60 30.0433526,60 C13.4508663,60 0,46.5685433 0,30 Z M0,30" fill="#4099FF" sketch:type="MSShapeGroup"></path>
    <path d="M29.2997675,23.8879776 L29.3627206,24.9260453 L28.3135016,24.798935 C24.4943445,24.3116787 21.1578281,22.6592444 18.3249368,19.8840023 L16.9399677,18.5069737 L16.5832333,19.5238563 C15.8277956,21.7906572 16.3104363,24.1845684 17.8842648,25.7946325 C18.72364,26.6844048 18.5347806,26.8115152 17.0868584,26.2818888 C16.5832333,26.1124083 16.1425613,25.985298 16.1005925,26.0488532 C15.9537019,26.1971486 16.457327,28.1249885 16.8560302,28.8876505 C17.4016241,29.9469033 18.5137962,30.9849709 19.7308902,31.5993375 L20.7591248,32.0865938 L19.5420308,32.1077788 C18.3669055,32.1077788 18.3249368,32.1289639 18.4508431,32.57385 C18.8705307,33.9508786 20.5282967,35.4126474 22.3749221,36.048199 L23.6759536,36.4930852 L22.5427971,37.1710069 C20.8640467,38.1455194 18.891515,38.6963309 16.9189833,38.738701 C15.9746862,38.759886 15.1982642,38.8446262 15.1982642,38.9081814 C15.1982642,39.1200319 17.7583585,40.306395 19.2482495,40.7724662 C23.7179224,42.1494948 29.0269705,41.5563132 33.0140027,39.2047722 C35.846894,37.5311528 38.6797853,34.2050993 40.0018012,30.9849709 C40.7152701,29.2689815 41.428739,26.1335934 41.428739,24.6294545 C41.428739,23.654942 41.4916922,23.5278317 42.6668174,22.3626537 C43.359302,21.6847319 44.0098178,20.943255 44.135724,20.7314044 C44.3455678,20.3288884 44.3245835,20.3288884 43.2543801,20.6890343 C41.4707078,21.324586 41.2188952,21.2398458 42.1002392,20.2865183 C42.750755,19.6085965 43.527177,18.3798634 43.527177,18.0197174 C43.527177,17.9561623 43.2124113,18.0620876 42.8556769,18.252753 C42.477958,18.4646036 41.6385828,18.7823794 41.0090514,18.9730449 L39.8758949,19.3331908 L38.8476603,18.634084 C38.281082,18.252753 37.4836756,17.829052 37.063988,17.7019416 C35.9937846,17.4053509 34.357003,17.447721 33.3917215,17.7866818 C30.768674,18.7400093 29.110908,21.1974757 29.2997675,23.8879776 Z M29.2997675,23.8879776" id="Path" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
    <path d="M60.0867052,30 C60.0867052,46.5685433 46.6358389,60 30.0433526,60 C23.8895925,60 18.1679598,58.1525134 13.4044895,54.9827754 L47.8290478,5.81941103 C55.2628108,11.2806503 60.0867052,20.0777973 60.0867052,30 Z M60.0867052,30" id="reflec" fill-opacity="0.08" fill="#000000" sketch:type="MSShapeGroup"></path>
</svg></a>
</td> <td>
<a href="http://twitter.com/albahnsen" target="_blank">@albahnsen</a>  
</td> </tr>
</table>
# Agenda
* Quick Intro to Fraud Detection
* Financial Evaluation of a Fraud Detection Model
* Example-Dependent Classification
* CostCla Library
* Conclusion and Future Work
# Fraud Detection
Estimate the **probability** of a transaction being **fraud** based on analyzing customer patterns and recent fraudulent behavior
<center>
<div>
<img img class="logo" src="https://raw.githubusercontent.com/albahnsen/CostSensitiveClassification/master/doc/tutorials/files/trx_flow.png" style="width: 800px;">
</div>
</center>
# Fraud Detection
Issues when constructing a fraud detection system:
* Skewness of the data
* **Cost-sensitivity**
* Short time response of the system
* Dimensionality of the search space
* Feature preprocessing
* Model selection
Different machine learning methods are used in practice, and in the
literature: logistic regression, neural networks, discriminant
analysis, genetic programing, decision trees, random forests among others
# Fraud Detection
Formally, a fraud detection is a statistical model that allows the estimation of the probability of transaction $i$ being a fraud ($y_i=1$)
  $$\hat p_i=P(y_i=1|\mathbf{x}_i)$$ 
<h1 class="bigtitle">Data!</h1>
<center>
<img img class="logo" src="http://www.sei-security.com/wp-content/uploads/2015/12/shutterstock_144683186.jpg" style="width: 400px;">
</center>
# Load dataset from CostCla package
End of explanation
print(data.keys())
print('Number of examples ', data.target.shape[0])
Explanation: Data file
End of explanation
target = pd.DataFrame(pd.Series(data.target).value_counts(), columns=('Frequency',))
target['Percentage'] = (target['Frequency'] / target['Frequency'].sum())  * 100
target.index = ['Negative (Legitimate Trx)', 'Positive (Fraud Trx)']
target.loc['Total Trx'] = [data.target.shape[0], 1.]
print(target)
Explanation: Class Label
End of explanation
pd.DataFrame(data.feature_names[:4], columns=('Features',))
Explanation: Features
End of explanation
df = pd.DataFrame(data.data[:, :4], columns=data.feature_names[:4])
df.head(10)
Explanation: Features
End of explanation
df = pd.DataFrame(data.data[:, 4:], columns=data.feature_names[4:])
df.head(10)
Explanation: Aggregated Features
End of explanation
from sklearn.cross_validation import train_test_split
X = data.data[:, [2, 3] + list(range(4, data.data.shape[1]))].astype(np.float)
X_train, X_test, y_train, y_test, cost_mat_train, cost_mat_test = \
train_test_split(X, data.target, data.cost_mat, test_size=0.33, random_state=10)
Explanation: Fraud Detection as a  classification problem
Split in training and testing
End of explanation
from sklearn.ensemble import RandomForestClassifier
from sklearn.tree import DecisionTreeClassifier
classifiers = {"RF": {"f": RandomForestClassifier()},
               "DT": {"f": DecisionTreeClassifier()}}
ci_models = ['DT', 'RF']
# Fit the classifiers using the training dataset
for model in classifiers.keys():
    classifiers[model]["f"].fit(X_train, y_train)
    classifiers[model]["c"] = classifiers[model]["f"].predict(X_test)
    classifiers[model]["p"] = classifiers[model]["f"].predict_proba(X_test)
    classifiers[model]["p_train"] = classifiers[model]["f"].predict_proba(X_train)
Explanation: Fraud Detection as a classification problem
Fit models
End of explanation
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline
import matplotlib.pyplot as plt
from IPython.core.pylabtools import figsize
import seaborn as sns
colors = sns.color_palette()
figsize(12, 8)
from sklearn.metrics import f1_score, precision_score, recall_score, accuracy_score
measures = {"F1Score": f1_score, "Precision": precision_score, 
            "Recall": recall_score, "Accuracy": accuracy_score}
results = pd.DataFrame(columns=measures.keys())
for model in ci_models:
    results.loc[model] = [measures[measure](y_test, classifiers[model]["c"]) for measure in measures.keys()]
Explanation: Models performance
Evaluate metrics and plot results
End of explanation
def fig_acc():
    plt.bar(np.arange(results.shape[0])-0.3, results['Accuracy'], 0.6, label='Accuracy', color=colors[0])
    plt.xticks(range(results.shape[0]), results.index) 
    plt.tick_params(labelsize=22); plt.title('Accuracy', size=30)
    plt.show()
fig_acc()
Explanation: Models performance
End of explanation
def fig_f1():
    plt.bar(np.arange(results.shape[0])-0.3, results['Precision'], 0.2, label='Precision', color=colors[0])
    plt.bar(np.arange(results.shape[0])-0.3+0.2, results['Recall'], 0.2, label='Recall', color=colors[1])
    plt.bar(np.arange(results.shape[0])-0.3+0.4, results['F1Score'], 0.2, label='F1Score', color=colors[2])
    plt.xticks(range(results.shape[0]), results.index) 
    plt.tick_params(labelsize=22)
    plt.ylim([0, 1])
    plt.legend(loc='center left', bbox_to_anchor=(1, 0.5),fontsize=22)
    plt.show()
fig_f1()
Explanation: Models performance
End of explanation
# The cost matrix is already calculated for the dataset
# cost_mat[C_FP,C_FN,C_TP,C_TN]
print(data.cost_mat[[10, 17, 50]])
Explanation: Models performance
None of these measures takes into account the business and economical realities that take place in fraud detection. 
Losses due to fraud or customer satisfaction costs, are not considered in the evaluation of the different models. 
<h1 class="bigtitle">Financial Evaluation of a Fraud Detection Model</h1>
Motivation
Typically, a fraud model is evaluated using standard cost-insensitive measures.
However, in practice, the cost associated with approving a fraudulent transaction (False Negative) is quite   different from the cost associated with declining a legitimate transaction (False Positive).
Furthermore, the costs are not constant among transactions. 
Cost Matrix
|   | Actual Positive ($y_i=1$)     |  Actual Negative  ($y_i=0$)|
|---    |:-:    |:-:    |
|   Pred. Positive ($c_i=1$)    |   $C_{TP_i}=C_a$  |  $C_{FP_i}=C_a$   |
|  Pred. Negative  ($c_i=0$)    |   $C_{FN_i}=Amt_i$    | $C_{TN_i}=0$  |
Where:
$C_{FN_i}$ = Amount of the transaction $i$
$C_a$ is the administrative cost of dealing with an alert
For more info see <a href="http://albahnsen.com/files/%20Improving%20Credit%20Card%20Fraud%20Detection%20by%20using%20Calibrated%20Probabilities%20-%20Publish.pdf" target="_blank">[Correa Bahnsen et al., 2014]</a>
End of explanation
# Calculation of the cost and savings
from costcla.metrics import savings_score, cost_loss
# Evaluate the savings for each model
results["Savings"] = np.zeros(results.shape[0])
for model in ci_models:
    results["Savings"].loc[model] = savings_score(y_test, classifiers[model]["c"], cost_mat_test)
# Plot the results
def fig_sav():
    plt.bar(np.arange(results.shape[0])-0.4, results['Precision'], 0.2, label='Precision', color=colors[0])
    plt.bar(np.arange(results.shape[0])-0.4+0.2, results['Recall'], 0.2, label='Recall', color=colors[1])
    plt.bar(np.arange(results.shape[0])-0.4+0.4, results['F1Score'], 0.2, label='F1Score', color=colors[2])
    plt.bar(np.arange(results.shape[0])-0.4+0.6, results['Savings'], 0.2, label='Savings', color=colors[3])
    plt.xticks(range(results.shape[0]), results.index) 
    plt.tick_params(labelsize=22)
    plt.ylim([0, 1])
    plt.xlim([-0.5, results.shape[0] -1 + .5])
    plt.legend(loc='center left', bbox_to_anchor=(1, 0.5),fontsize=22)
    plt.show()
Explanation: Financial savings
The financial cost of using a classifier $f$ on $\mathcal{S}$ is calculated by
$$   Cost(f(\mathcal{S})) = \sum_{i=1}^N  y_i(1-c_i)C_{FN_i} + (1-y_i)c_i C_{FP_i}.$$
Then the financial savings are defined as the cost of the algorithm versus the cost of using no algorithm at all.
$$    Savings(f(\mathcal{S})) = \frac{ Cost_l(\mathcal{S}) - Cost(f(\mathcal{S}))}   {Cost_l(\mathcal{S})},$$
where $Cost_l(\mathcal{S})$ is the cost of the costless class
Models Savings
costcla.metrics.savings_score(y_true, y_pred, cost_mat)
End of explanation
fig_sav()
Explanation: Models Savings
End of explanation
from costcla.models import ThresholdingOptimization
for model in ci_models:
    classifiers[model+"-TO"] = {"f": ThresholdingOptimization()}
    # Fit
    classifiers[model+"-TO"]["f"].fit(classifiers[model]["p_train"], cost_mat_train, y_train)
    # Predict
    classifiers[model+"-TO"]["c"] = classifiers[model+"-TO"]["f"].predict(classifiers[model]["p"])
print('New thresholds')
for model in ci_models:
    print(model + '-TO - ' + str(classifiers[model+'-TO']['f'].threshold_))
for model in ci_models:
    # Evaluate
    results.loc[model+"-TO"] = 0
    results.loc[model+"-TO", measures.keys()] = \
    [measures[measure](y_test, classifiers[model+"-TO"]["c"]) for measure in measures.keys()]
    results["Savings"].loc[model+"-TO"] = savings_score(y_test, classifiers[model+"-TO"]["c"], cost_mat_test) 
Explanation: Threshold Optimization
Convert a classifier cost-sensitive by selecting a proper threshold
from training instances according to the savings
$$ t  \quad = \quad argmax_t \: Savings(c(t), y) $$
Threshold Optimization - Code
costcla.models.ThresholdingOptimization(calibration=True)
fit(y_prob_train=None, cost_mat, y_true_train)
- Parameters
    - y_prob_train : Predicted probabilities of the training set
    - cost_mat : Cost matrix of the classification problem. 
    - y_true_cal : True class
predict(y_prob)
- Parameters
    - y_prob : Predicted probabilities
Returns
y_pred : Predicted class
Threshold Optimization
End of explanation
fig_sav()
Explanation: Threshold Optimization
End of explanation
from costcla.models import BayesMinimumRiskClassifier
for model in ci_models:
    classifiers[model+"-BMR"] = {"f": BayesMinimumRiskClassifier()}
    # Fit
    classifiers[model+"-BMR"]["f"].fit(y_test, classifiers[model]["p"])
    # Calibration must be made in a validation set
    # Predict
    classifiers[model+"-BMR"]["c"] = classifiers[model+"-BMR"]["f"].predict(classifiers[model]["p"], cost_mat_test)
for model in ci_models:
    # Evaluate
    results.loc[model+"-BMR"] = 0
    results.loc[model+"-BMR", measures.keys()] = \
    [measures[measure](y_test, classifiers[model+"-BMR"]["c"]) for measure in measures.keys()]
    results["Savings"].loc[model+"-BMR"] = savings_score(y_test, classifiers[model+"-BMR"]["c"], cost_mat_test) 
Explanation: Models Savings
There are significant differences in the results when evaluating a model using a  traditional cost-insensitive measures
Train models that take into account the different financial costs
<h1 class="bigtitle">Example-Dependent Cost-Sensitive Classification</h1>
*Why "Example-Dependent"
Cost-sensitive classification ussualy refers to class-dependent costs, where the cost dependends on the class but is assumed constant accross examples.
In fraud detection, different transactions have different amounts, which implies that the costs are not constant
Bayes Minimum Risk (BMR)
The BMR classifier is a decision model based on quantifying tradeoffs between various decisions using probabilities and the costs that accompany such decisions. 
In particular:
$$ R(c_i=0|\mathbf{x}i)=C{TN_i}(1-\hat p_i)+C_{FN_i} \cdot \hat p_i, $$
and
$$ R(c_i=1|\mathbf{x}i)=C{TP_i} \cdot \hat p_i + C_{FP_i}(1- \hat p_i), $$
BMR Code
costcla.models.BayesMinimumRiskClassifier(calibration=True)
fit(y_true_cal=None, y_prob_cal=None)
- Parameters
    - y_true_cal : True class
    - y_prob_cal : Predicted probabilities
predict(y_prob,cost_mat)
- Parameters
    - y_prob : Predicted probabilities
    - cost_mat : Cost matrix of the classification problem. 
Returns
y_pred : Predicted class
BMR Code
End of explanation
fig_sav()
Explanation: BMR Results
End of explanation
print(data.data[data.target == 1, 2].mean())
Explanation: BMR Results
Why so important focusing on the Recall
Average cost of a False Negative
End of explanation
print(data.cost_mat[:,0].mean())
Explanation: Average cost of a False Positive
End of explanation
from costcla.models import CostSensitiveDecisionTreeClassifier
from costcla.models import CostSensitiveRandomForestClassifier
classifiers = {"CSDT": {"f": CostSensitiveDecisionTreeClassifier()},
               "CSRF": {"f": CostSensitiveRandomForestClassifier(combination='majority_bmr')}}
# Fit the classifiers using the training dataset
for model in classifiers.keys():
    classifiers[model]["f"].fit(X_train, y_train, cost_mat_train)
    if model == "CSRF":
        classifiers[model]["c"] = classifiers[model]["f"].predict(X_test, cost_mat_test)
    else:
        classifiers[model]["c"] = classifiers[model]["f"].predict(X_test)
for model in ['CSDT', 'CSRF']:
    # Evaluate
    results.loc[model] = 0
    results.loc[model, measures.keys()] = \
    [measures[measure](y_test, classifiers[model]["c"]) for measure in measures.keys()]
    results["Savings"].loc[model] = savings_score(y_test, classifiers[model]["c"], cost_mat_test)
Explanation: BMR Results
Bayes Minimum Risk increases the savings by using a cost-insensitive method and then introducing the costs
Why not introduce the costs during the estimation of the methods?
Cost-Sensitive Decision Trees (CSDT)
A a new cost-based impurity measure taking into account the costs when all the examples in a leaf
costcla.models.CostSensitiveDecisionTreeClassifier(criterion='direct_cost', criterion_weight=False, pruned=True)
Cost-Sensitive Random Forest (CSRF)
Ensemble of CSDT
costcla.models.CostSensitiveRandomForestClassifier(n_estimators=10, max_samples=0.5, max_features=0.5,combination='majority_voting)
CSDT & CSRF Code
End of explanation
fig_sav()
Explanation: CSDT & CSRF Results
End of explanation
#Format from https://github.com/ellisonbg/talk-2013-scipy
from IPython.display import display, HTML
s = 
<style>
.rendered_html {
    font-family: "proxima-nova", helvetica;
    font-size: 100%;
    line-height: 1.3;
}
.rendered_html h1 {
    margin: 0.25em 0em 0.5em;
    color: #015C9C;
    text-align: center;
    line-height: 1.2; 
    page-break-before: always;
}
.rendered_html h2 {
    margin: 1.1em 0em 0.5em;
    color: #26465D;
    line-height: 1.2;
}
.rendered_html h3 {
    margin: 1.1em 0em 0.5em;
    color: #002845;
    line-height: 1.2;
}
.rendered_html li {
    line-height: 1.5; 
}
.prompt {
    font-size: 120%; 
}
.CodeMirror-lines {
    font-size: 120%; 
}
.output_area {
    font-size: 120%; 
}
#notebook {
    background-image: url('files/images/witewall_3.png');
}
h1.bigtitle {
    margin: 4cm 1cm 4cm 1cm;
    font-size: 300%;
}
h3.point {
    font-size: 200%;
    text-align: center;
    margin: 2em 0em 2em 0em;
    #26465D
}
.logo {
    margin: 20px 0 20px 0;
}
a.anchor-link {
    display: none;
}
h1.title { 
    font-size: 250%;
}
</style>
display(HTML(s))
Explanation: Lessons Learned (so far ...)
Selecting models based on traditional statistics does not give the best results in terms of cost
Models should be evaluated taking into account real financial costs of the application
Algorithms should be developed to incorporate those financial costs
<center>
<img src="https://raw.githubusercontent.com/albahnsen/CostSensitiveClassification/master/logo.png" style="width: 600px;" align="middle">
</center>
CostCla Library
CostCla is a Python open source cost-sensitive classification library built on top of Scikit-learn, Pandas and Numpy. 
Source code, binaries and documentation are distributed under 3-Clause BSD license in the website http://albahnsen.com/CostSensitiveClassification/
CostCla Algorithms
Cost-proportionate over-sampling <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.29.514" target="_blank">[Elkan, 2001]</a> 
SMOTE <a href="http://arxiv.org/abs/1106.1813" target="_blank">[Chawla et al., 2002]</a> 
Cost-proportionate rejection-sampling <a href="http://ieeexplore.ieee.org/lpdocs/epic03/wrapper.htm?arnumber=1250950" target="_blank">[Zadrozny et al., 2003]</a>
Thresholding optimization <a href="http://www.aaai.org/Papers/AAAI/2006/AAAI06-076.pdf" target="_blank">[Sheng and Ling, 2006]</a> 
Bayes minimum risk <a href="http://albahnsen.com/files/%20Improving%20Credit%20Card%20Fraud%20Detection%20by%20using%20Calibrated%20Probabilities%20-%20Publish.pdf" target="_blank">[Correa Bahnsen et al., 2014a]</a>  
Cost-sensitive logistic regression <a href="http://albahnsen.com/files/Example-Dependent%20Cost-Sensitive%20Logistic%20Regression%20for%20Credit%20Scoring_publish.pdf" target="_blank">[Correa Bahnsen et al., 2014b]</a>  
Cost-sensitive decision trees <a href="http://albahnsen.com/files/Example-Dependent%20Cost-Sensitive%20Decision%20Trees.pdf" target="_blank">[Correa Bahnsen et al., 2015a]</a>  
Cost-sensitive ensemble methods: cost-sensitive bagging, cost-sensitive pasting, cost-sensitive random forest and cost-sensitive random patches <a href="http://arxiv.org/abs/1505.04637" target="_blank">[Correa Bahnsen et al., 2015c]</a>
CostCla Databases
Credit Scoring1 - Kaggle credit competition <a href="https://www.kaggle.com/c/GiveMeSomeCredit" target="_blank">[Data]</a>, cost matrix: <a href="http://albahnsen.com/files/Example-Dependent%20Cost-Sensitive%20Logistic%20Regression%20for%20Credit%20Scoring_publish.pdf" target="_blank">[Correa Bahnsen et al., 2014]</a>  
Credit Scoring 2 - PAKDD2009 Credit <a href="http://sede.neurotech.com.br/PAKDD2009/" target="_blank">[Data]</a>, cost matrix: <a href="http://albahnsen.com/files/Example-Dependent%20Cost-Sensitive%20Logistic%20Regression%20for%20Credit%20Scoring_publish.pdf" target="_blank">[Correa Bahnsen et al., 2014a]</a>  
Direct Marketing - PAKDD2009 Credit <a href="https://archive.ics.uci.edu/ml/datasets/Bank+Marketing" target="_blank">[Data]</a>, cost matrix: <a href="http://albahnsen.com/files/%20Improving%20Credit%20Card%20Fraud%20Detection%20by%20using%20Calibrated%20Probabilities%20-%20Publish.pdf" target="_blank">[Correa Bahnsen et al., 2014b]</a>  
Churn Modeling, soon 
Fraud Detection, soon
Future Work
CSDT in Cython
Cost-sensitive class-dependent algorithms
Sampling algorithms
Probability calibration (Only ROCCH)
Other algorithms
More databases
You find the presentation and the IPython Notebook here:
<a href="http://nbviewer.ipython.org/format/slides/github/albahnsen/CostSensitiveClassification/blob/master/doc/tutorials/slides_edcs_fraud_detection.ipynb#/" target="_blank">http://nbviewer.ipython.org/format/slides/github/
albahnsen/CostSensitiveClassification/blob/
master/doc/tutorials/slides_edcs_fraud_detection.ipynb#/</a>
<a href="https://github.com/albahnsen/CostSensitiveClassification/blob/master/doc/tutorials/slides_edcs_fraud_detection.ipynb" target="_blank">https://github.com/albahnsen/CostSensitiveClassification/ blob/master/doc/tutorials/slides_edcs_fraud_detection.ipynb</a>
<h1 class="bigtitle">Thanks!</h1>
<center>
<table style="border-collapse: collapse; border-top-color: rgb(255, 255, 255); border-right-color: rgb(255, 255, 255); border-bottom-color: rgb(255, 255, 255); border-left-color: rgb(255, 255, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; " border="0" bordercolor="#888" cellspacing="0" align="left">
  <tr>
    <td>
<a href="mailto: al.bahnsen@gmail.com"><svg width="40px" height="40px" viewBox="0 0 60 60" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
    <path d="M0.224580688,30 C0.224580688,13.4314567 13.454941,0 29.7754193,0 C46.0958976,0 59.3262579,13.4314567 59.3262579,30 C59.3262579,46.5685433 46.0958976,60 29.7754193,60 C13.454941,60 0.224580688,46.5685433 0.224580688,30 Z M0.224580688,30" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
    <path d="M35.0384324,31.6384006 L47.2131148,40.5764264 L47.2131148,20 L35.0384324,31.6384006 Z M13.7704918,20 L13.7704918,40.5764264 L25.9449129,31.6371491 L13.7704918,20 Z M30.4918033,35.9844891 L27.5851037,33.2065217 L13.7704918,42 L47.2131148,42 L33.3981762,33.2065217 L30.4918033,35.9844891 Z M46.2098361,20 L14.7737705,20 L30.4918033,32.4549304 L46.2098361,20 Z M46.2098361,20" id="Shape" fill="#333333" sketch:type="MSShapeGroup"></path>
    <path d="M59.3262579,30 C59.3262579,46.5685433 46.0958976,60 29.7754193,60 C23.7225405,60 18.0947051,58.1525134 13.4093244,54.9827754 L47.2695458,5.81941103 C54.5814438,11.2806503 59.3262579,20.0777973 59.3262579,30 Z M59.3262579,30" id="reflec" fill-opacity="0.08" fill="#000000" sketch:type="MSShapeGroup"></path>
</svg></a> 
</td> 
<td>
<a href="mailto: al.bahnsen@gmail.com" target="_blank">al.bahnsen@gmail.com</a>  
</td> </tr><tr> <td>
<a href="http://github.com/albahnsen"><svg width="40px" height="40px" viewBox="0 0 60 60" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
    <path d="M0.336871032,30 C0.336871032,13.4314567 13.5672313,0 29.8877097,0 C46.208188,0 59.4385483,13.4314567 59.4385483,30 C59.4385483,46.5685433 46.208188,60 29.8877097,60 C13.5672313,60 0.336871032,46.5685433 0.336871032,30 Z M0.336871032,30" id="Github" fill="#333333" sketch:type="MSShapeGroup"></path>
    <path d="M18.2184245,31.9355566 C19.6068506,34.4507902 22.2845295,36.0156764 26.8007287,36.4485173 C26.1561023,36.9365335 25.3817877,37.8630984 25.2749857,38.9342607 C24.4644348,39.4574749 22.8347506,39.62966 21.5674303,39.2310659 C19.7918469,38.6717023 19.1119377,35.1642642 16.4533306,35.6636959 C15.8773626,35.772144 15.9917933,36.1507609 16.489567,36.4722998 C17.3001179,36.9955141 18.0629894,37.6500075 18.6513541,39.04366 C19.1033554,40.113871 20.0531304,42.0259813 23.0569369,42.0259813 C24.2489236,42.0259813 25.0842679,41.8832865 25.0842679,41.8832865 C25.0842679,41.8832865 25.107154,44.6144649 25.107154,45.6761142 C25.107154,46.9004355 23.4507693,47.2457569 23.4507693,47.8346108 C23.4507693,48.067679 23.9990832,48.0895588 24.4396415,48.0895588 C25.3102685,48.0895588 27.1220883,47.3646693 27.1220883,46.0918317 C27.1220883,45.0806012 27.1382993,41.6806599 27.1382993,41.0860982 C27.1382993,39.785673 27.8372803,39.3737607 27.8372803,39.3737607 C27.8372803,39.3737607 27.924057,46.3153869 27.6704022,47.2457569 C27.3728823,48.3397504 26.8360115,48.1846887 26.8360115,48.6727049 C26.8360115,49.3985458 29.0168704,48.8505978 29.7396911,47.2571725 C30.2984945,46.0166791 30.0543756,39.2072834 30.0543756,39.2072834 L30.650369,39.1949165 C30.650369,39.1949165 30.6837446,42.3123222 30.6637192,43.7373675 C30.6427402,45.2128317 30.5426134,47.0792797 31.4208692,47.9592309 C31.9977907,48.5376205 33.868733,49.5526562 33.868733,48.62514 C33.868733,48.0857536 32.8436245,47.6424485 32.8436245,46.1831564 L32.8436245,39.4688905 C33.6618042,39.4688905 33.5387911,41.6768547 33.5387911,41.6768547 L33.5988673,45.7788544 C33.5988673,45.7788544 33.4186389,47.2733446 35.2190156,47.8992991 C35.8541061,48.1209517 37.2139245,48.1808835 37.277815,47.8089257 C37.3417055,47.4360167 35.6405021,46.8814096 35.6252446,45.7236791 C35.6157088,45.0178155 35.6567131,44.6059032 35.6567131,41.5379651 C35.6567131,38.470027 35.2438089,37.336079 33.8048426,36.4323453 C38.2457082,35.9766732 40.9939527,34.880682 42.3337458,31.9450695 C42.4383619,31.9484966 42.8791491,30.5737742 42.8219835,30.5742482 C43.1223642,29.4659853 43.2844744,28.1550957 43.3168964,26.6025764 C43.3092677,22.3930799 41.2895654,20.9042975 40.9014546,20.205093 C41.4736082,17.0182425 40.8060956,15.5675121 40.4961791,15.0699829 C39.3518719,14.6637784 36.5149435,16.1145088 34.9653608,17.1371548 C32.438349,16.3998984 27.0982486,16.4712458 25.0957109,17.3274146 C21.4005522,14.6875608 19.445694,15.0918628 19.445694,15.0918628 C19.445694,15.0918628 18.1821881,17.351197 19.1119377,20.6569598 C17.8961113,22.2028201 16.9902014,23.2968136 16.9902014,26.1963718 C16.9902014,27.8297516 17.1828264,29.2918976 17.6176632,30.5685404 C17.5643577,30.5684093 18.2008493,31.9359777 18.2184245,31.9355566 Z M18.2184245,31.9355566" id="Path" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
    <path d="M59.4385483,30 C59.4385483,46.5685433 46.208188,60 29.8877097,60 C23.8348308,60 18.2069954,58.1525134 13.5216148,54.9827754 L47.3818361,5.81941103 C54.6937341,11.2806503 59.4385483,20.0777973 59.4385483,30 Z M59.4385483,30" id="reflec" fill-opacity="0.08" fill="#000000" sketch:type="MSShapeGroup"></path>
</svg></a>
</td><td>
<a href="http://github.com/albahnsen" target="_blank">http://github.com/albahnsen</a>  
</td> </tr><tr> <td>
<a href="http://linkedin.com/in/albahnsen"><svg width="40px" height="40px" viewBox="0 0 60 60" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
    <path d="M0.449161376,30 C0.449161376,13.4314567 13.6795217,0 30,0 C46.3204783,0 59.5508386,13.4314567 59.5508386,30 C59.5508386,46.5685433 46.3204783,60 30,60 C13.6795217,60 0.449161376,46.5685433 0.449161376,30 Z M0.449161376,30" fill="#007BB6" sketch:type="MSShapeGroup"></path>
    <path d="M22.4680392,23.7098144 L15.7808366,23.7098144 L15.7808366,44.1369537 L22.4680392,44.1369537 L22.4680392,23.7098144 Z M22.4680392,23.7098144" id="Path" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
    <path d="M22.9084753,17.3908761 C22.8650727,15.3880081 21.4562917,13.862504 19.1686418,13.862504 C16.8809918,13.862504 15.3854057,15.3880081 15.3854057,17.3908761 C15.3854057,19.3522579 16.836788,20.9216886 19.0818366,20.9216886 L19.1245714,20.9216886 C21.4562917,20.9216886 22.9084753,19.3522579 22.9084753,17.3908761 Z M22.9084753,17.3908761" id="Path" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
    <path d="M46.5846502,32.4246563 C46.5846502,26.1503226 43.2856534,23.2301456 38.8851658,23.2301456 C35.3347011,23.2301456 33.7450983,25.2128128 32.8575489,26.6036896 L32.8575489,23.7103567 L26.1695449,23.7103567 C26.2576856,25.6271338 26.1695449,44.137496 26.1695449,44.137496 L32.8575489,44.137496 L32.8575489,32.7292961 C32.8575489,32.1187963 32.9009514,31.5097877 33.0777669,31.0726898 C33.5610713,29.8530458 34.6614937,28.5902885 36.5089747,28.5902885 C38.9297703,28.5902885 39.8974476,30.4634101 39.8974476,33.2084226 L39.8974476,44.1369537 L46.5843832,44.1369537 L46.5846502,32.4246563 Z M46.5846502,32.4246563" id="Path" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
    <path d="M59.5508386,30 C59.5508386,46.5685433 46.3204783,60 30,60 C23.9471212,60 18.3192858,58.1525134 13.6339051,54.9827754 L47.4941264,5.81941103 C54.8060245,11.2806503 59.5508386,20.0777973 59.5508386,30 Z M59.5508386,30" id="reflec" fill-opacity="0.08" fill="#000000" sketch:type="MSShapeGroup"></path>
</svg></a> 
</td> <td>
<a href="http://linkedin.com/in/albahnsen" target="_blank">http://linkedin.com/in/albahnsen</a>  
</td> </tr><tr> <td>
<a href="http://twitter.com/albahnsen"><svg width="40px" height="40px" viewBox="0 0 60 60" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
    <path d="M0,30 C0,13.4314567 13.4508663,0 30.0433526,0 C46.6358389,0 60.0867052,13.4314567 60.0867052,30 C60.0867052,46.5685433 46.6358389,60 30.0433526,60 C13.4508663,60 0,46.5685433 0,30 Z M0,30" fill="#4099FF" sketch:type="MSShapeGroup"></path>
    <path d="M29.2997675,23.8879776 L29.3627206,24.9260453 L28.3135016,24.798935 C24.4943445,24.3116787 21.1578281,22.6592444 18.3249368,19.8840023 L16.9399677,18.5069737 L16.5832333,19.5238563 C15.8277956,21.7906572 16.3104363,24.1845684 17.8842648,25.7946325 C18.72364,26.6844048 18.5347806,26.8115152 17.0868584,26.2818888 C16.5832333,26.1124083 16.1425613,25.985298 16.1005925,26.0488532 C15.9537019,26.1971486 16.457327,28.1249885 16.8560302,28.8876505 C17.4016241,29.9469033 18.5137962,30.9849709 19.7308902,31.5993375 L20.7591248,32.0865938 L19.5420308,32.1077788 C18.3669055,32.1077788 18.3249368,32.1289639 18.4508431,32.57385 C18.8705307,33.9508786 20.5282967,35.4126474 22.3749221,36.048199 L23.6759536,36.4930852 L22.5427971,37.1710069 C20.8640467,38.1455194 18.891515,38.6963309 16.9189833,38.738701 C15.9746862,38.759886 15.1982642,38.8446262 15.1982642,38.9081814 C15.1982642,39.1200319 17.7583585,40.306395 19.2482495,40.7724662 C23.7179224,42.1494948 29.0269705,41.5563132 33.0140027,39.2047722 C35.846894,37.5311528 38.6797853,34.2050993 40.0018012,30.9849709 C40.7152701,29.2689815 41.428739,26.1335934 41.428739,24.6294545 C41.428739,23.654942 41.4916922,23.5278317 42.6668174,22.3626537 C43.359302,21.6847319 44.0098178,20.943255 44.135724,20.7314044 C44.3455678,20.3288884 44.3245835,20.3288884 43.2543801,20.6890343 C41.4707078,21.324586 41.2188952,21.2398458 42.1002392,20.2865183 C42.750755,19.6085965 43.527177,18.3798634 43.527177,18.0197174 C43.527177,17.9561623 43.2124113,18.0620876 42.8556769,18.252753 C42.477958,18.4646036 41.6385828,18.7823794 41.0090514,18.9730449 L39.8758949,19.3331908 L38.8476603,18.634084 C38.281082,18.252753 37.4836756,17.829052 37.063988,17.7019416 C35.9937846,17.4053509 34.357003,17.447721 33.3917215,17.7866818 C30.768674,18.7400093 29.110908,21.1974757 29.2997675,23.8879776 Z M29.2997675,23.8879776" id="Path" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
    <path d="M60.0867052,30 C60.0867052,46.5685433 46.6358389,60 30.0433526,60 C23.8895925,60 18.1679598,58.1525134 13.4044895,54.9827754 L47.8290478,5.81941103 C55.2628108,11.2806503 60.0867052,20.0777973 60.0867052,30 Z M60.0867052,30" id="reflec" fill-opacity="0.08" fill="#000000" sketch:type="MSShapeGroup"></path>
</svg></a>
</td> <td>
<a href="http://twitter.com/albahnsen" target="_blank">@albahnsen</a>  
</td> </tr>
</table>
</center>
End of explanation
<END_TASK>