<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Build a model
Step1:  Decision Tree Plot
Step2:  sklearn_explain approach
Step3:  Automatic Feature Binning
This binning was built using a equi-frequency approach (5 bins , all bins contain the same number of rows)
Step4:  Customized Feature binning
We use a second explainer and we customize the binning so that the decision tree defines the bin (lower) limits
Step5:  Score Customized Binning
Score qbining can also be customized .... (interest ?)
<ASSISTANT_TASK:>
Python Code:
ds = datasets.load_breast_cancer();
from sklearn.tree import DecisionTreeClassifier
clf = DecisionTreeClassifier(min_samples_leaf=30, random_state = 1960)
NC = 12
X = ds.data[:,0:NC]
y = ds.target
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5, random_state=1960)
clf.fit(X_train , y_train)
Explanation: Build a model
End of explanation
import graphviz 
from sklearn import tree
dot_data = tree.export_graphviz(clf, out_file=None, 
                         feature_names=ds.feature_names[0:NC],  
                         class_names=ds.target_names,  
                         filled=True, rounded=True,  
                         special_characters=True)  
graph = graphviz.Source(dot_data)  
graph
Explanation: Decision Tree Plot
End of explanation
# Explain the score = ln(p(1) / (1 - p(1)))
import sklearn_explain.explainer as expl
lExplainer = expl.cModelScoreExplainer(clf)
lExplainer.mSettings.mFeatureNames = ds.feature_names[0:NC]
lExplainer.mSettings.mExplanationOrder = 2
    
lExplainer.fit(X_train)
df_rc = lExplainer.explain(X_test)
# print(df_rc.columns)
df_rc_2 = lExplainer.explain(X_test[0].reshape(1, -1))
X_test[0].reshape(1, -1)
df_rc_2
df_rc_2[[col for col in df_rc_2.columns if col.startswith('detailed')]]
Explanation: sklearn_explain approach
End of explanation
lExplainer.mImplementation.mFeatureQuantiles
Explanation: Automatic Feature Binning
This binning was built using a equi-frequency approach (5 bins , all bins contain the same number of rows)
End of explanation
lFeature_Quantiles = {
'mean area': {0: -np.inf,
  1: 571.85},
'mean concave points': {0: -np.inf,
  1: 0.51},
'mean perimeter': {0: -np.inf,
  1: 98.32},
'radius error': {0: -np.inf,
  1: 0.354}
}
lFeature_Quantiles
lExplainer2 = expl.cModelScoreExplainer(clf)
lExplainer2.mSettings.mFeatureNames = ds.feature_names[0:NC]
lExplainer2.mSettings.mCustomFeatureQuantiles = lFeature_Quantiles
lExplainer2.mSettings.mExplanationOrder = 2
    
lExplainer2.fit(X_train)
df_rc2 = lExplainer2.explain(X_test)
# print(df_rc2.columns)
df_rc_2 = lExplainer2.explain(X_test[0].reshape(1, -1))
df_rc_2[[col for col in df_rc_2.columns if col.startswith('detailed')]]
Explanation: Customized Feature binning
We use a second explainer and we customize the binning so that the decision tree defines the bin (lower) limits
End of explanation
lExplainer.mImplementation.mScoreQuantiles
lScore_Quantiles =  {
    0: -np.inf,
     1: 0.
}
lExplainer3 = expl.cModelScoreExplainer(clf)
lExplainer3.mSettings.mFeatureNames = ds.feature_names[0:NC]
lExplainer3.mSettings.mCustomFeatureQuantiles = lFeature_Quantiles
lExplainer3.mSettings.mCustomScoreQuantiles = lScore_Quantiles
lExplainer3.mSettings.mExplanationOrder = 2
    
lExplainer3.fit(X_train)
df_rc3 = lExplainer2.explain(X_test)
# print(df_rc2.columns)
df_rc_3 = lExplainer3.explain(X_test[0].reshape(1, -1))
df_rc_3[[col for col in df_rc_3.columns if col.startswith('detailed')]]
Explanation: Score Customized Binning
Score qbining can also be customized .... (interest ?)
End of explanation
<END_TASK>