Extracting Local Model Coef_
See original GitHub issueHi, this is just a followup issue with regards to the local model weights.
I have the following code.
from sklearn.linear_model import LogisticRegression
clf = LogisticRegression()
clf.fit(X_train, y_train) # Just the Taiwan credit dataset
explainer = lime.lime_tabular.LimeTabularExplainer(X_train,
feature_names=feature_names,
class_names=['N', "Y"],
verbose=False,
discretize_continuous=False,
mode='classification')
i = 13
exp = explainer.explain_instance(X_train[i], clf.predict_proba)
total = 0
l = exp.as_map()[1]
l.sort()
for j in range(len(X_train[0])):
total += X_train[i][j] * (l[j][1])
total + exp.intercept[1]
The issue is that my manual calculation of exp.local_pred is never exactly correct. Am I doing something wrong here? It should just be a simple matter of multiplying the input features by the weights plus intercept no?
The training data is just 3 continuous features.
Thanks a lot in advance!
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
coef: Extract Model Coefficients - Rdrr.io
Description. coef is a generic function which extracts model coefficients from objects returned by modeling functions. coefficients is an alias for it.
Read more >Extract Model Coefficients - MATLAB & Simulink - MathWorks
Extract model coefficients such as transfer function numerator and denominator coefficients, state-space matrices, and PID gains.
Read more >Extract regression coefficient values | Edureka Community
I have a regression model for some time series data investigating drug utilisation. The purpose is to fit a spline to a time...
Read more >extract coefficients from e(b) after regress - Statalist
Can I extract individual coefficients directly from e(b) after the regress command, or must I copy e(b) to another matrix first and then...
Read more >Extract Model Coefficients - R
coef is a generic function which extracts model coefficients from objects returned by modeling functions. coefficients is an alias for it. Usage. coef(object,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@marcotcr you were exactly right, it works perfect now.
Thanks a lot for taking the time to explain.
That is not normal. I think there are two bugs in your code:
num_feature
coefs (this is a parameter to explain_instance, the default is 10). If you have more than 10 features in your dataset, the multiplication won’t work.I think if you do
you will get the same as exp.local_pred