jylfamily / interpert_machine_learning Goto Github PK
View Code? Open in Web Editor NEWhttps://christophm.github.io/interpretable-ml-book/index.html
Home Page: https://christophm.github.io/interpretable-ml-book/index.html
https://christophm.github.io/interpretable-ml-book/index.html
Home Page: https://christophm.github.io/interpretable-ml-book/index.html
In the context of my machine learning project, I'm currently working on generating a heatmap for the interaction functions within the EBM model. The focus of this model is on predicting baryon fractions, and I'm particularly interested in visualizing the interaction effects based on pairs of parameters. To create this heatmap, I've utilized the pcolormesh technique.
However, I've encountered a discrepancy in the number of interaction bins. The EBM model was configured with a maximum of 32 interaction bins, yet upon inspecting ebm.bins_, I've noticed the presence of only 29 interaction bins. The EBM documentation doesn't provide a clear explanation for the absence of these 3 bins. To address this, I've attempted to align the shape of term_scores_ by performing linear interpolation on the bins. While I've taken this approach, I'm uncertain if it's the correct way to address the issue.
Could you kindly guide me on the appropriate method to handle this situation?
And here is the code for the pcolormesh:
def add_edges(edges, num_to_add):
"""Add additional bin edges through linear interpolation."""
last_diff = edges[-1] - edges[-2]
return np.concatenate([edges, [edges[-1] + last_diff * (i+1) for i in range(num_to_add)]])
it_feat = [f for f in ebm.term_features_ if len(f) > 1]
fig, ax = plt.subplots(nrows=2, ncols=5, figsize=(22, 8))
j = 0
it_scores = ebm.term_scores_[10:]
Define a common color range for all plots
vmin = min([score.min() for score in it_scores])
vmax = max([score.max() for score in it_scores])
for row in ax:
for col in row:
idx, idy = it_feat[j]
x_edges = add_edges(ebm.bins_[idx][1], 4)
y_edges = add_edges(ebm.bins_[idy][1], 4)
print(x_edges.shape)
c = col.pcolormesh(x_edges, y_edges, it_scores[j], shading='auto', cmap='bwr', vmin=vmin, vmax=vmax)
colnameX, colnameY = ebm.feature_names_in_[it_feat[j][0]], ebm.feature_names_in_[it_feat[j][1]]
col.set_xlabel(colnameX)
col.set_ylabel(colnameY)
j += 1
plt.tight_layout(pad=2.5)
Add a common colorbar
fig.subplots_adjust(right=0.83)
cbar_ax = fig.add_axes([0.85, 0.15, 0.01, 0.7])
fig.colorbar(c, cax=cbar_ax, label='Baryon Fraction')
fig.savefig('interaction_term_score.png')
plt.show()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.