Giter Site home page Giter Site logo

jylfamily / interpert_machine_learning Goto Github PK

View Code? Open in Web Editor NEW
12.0 12.0 3.0 11.06 MB

https://christophm.github.io/interpretable-ml-book/index.html

Home Page: https://christophm.github.io/interpretable-ml-book/index.html

Python 20.14% Tcl 0.89% PowerShell 0.05% Batchfile 0.05% Jupyter Notebook 78.87%

interpert_machine_learning's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

interpert_machine_learning's Issues

"Resolving Discrepancies in Interaction Bins for EBM Model: Approach and Query"

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()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.