Close Menu

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Excessive Danger Zone? Analysts Cut up as Bitcoin (BTC) Ignores Geopolitical Chaos

    March 2, 2026

    How to Play as Assassin

    March 2, 2026

    Public Sector Group Peshawar Jobs Discover 2026 2026 Job Commercial Pakistan

    March 2, 2026
    Facebook X (Twitter) Instagram
    Monday, March 2
    Trending
    • Excessive Danger Zone? Analysts Cut up as Bitcoin (BTC) Ignores Geopolitical Chaos
    • How to Play as Assassin
    • Public Sector Group Peshawar Jobs Discover 2026 2026 Job Commercial Pakistan
    • Moving metrics: How the Ford government pulled back reporting its successes and failures
    • Will not allow any entity to use neighbouring territory to destabilise our peace, president says in joint sitting – Pakistan
    • Bangladesh deal with gender obstacles
    • Anthropic Hits Again After US Army Labels It a ‘Provide Chain Threat’
    • Oil surges 9% as Iran battle disrupts Center Japanese flows
    • Bitcoin Traders Warn of New Lows as BTC Weathers Iran Storm
    • PlayStation Retro Anime Spoof Hits Steam After 27 Years In Japan
    Facebook X (Twitter) Instagram Pinterest Vimeo
    The News92The News92
    • Home
    • World
    • National
    • Sports
    • Crypto
    • Travel
    • Lifestyle
    • Jobs
    • Insurance
    • Gaming
    • AI & Tech
    • Health & Fitness
    The News92The News92
    Home - AI & Tech - How to Build an Explainable AI Analysis Pipeline Using SHAP-IQ to Understand Feature Importance, Interaction Effects, and Model Decision Breakdown
    AI & Tech

    How to Build an Explainable AI Analysis Pipeline Using SHAP-IQ to Understand Feature Importance, Interaction Effects, and Model Decision Breakdown

    Naveed AhmadBy Naveed AhmadMarch 2, 2026No Comments2 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    INSTANCE_I = int(np.clip(INSTANCE_I, 0, len(X_test)-1))
    x = X_test.iloc[INSTANCE_I].values
    y_true = float(y_test.iloc[INSTANCE_I])
    pred = float(model.predict([x])[0])
    
    
    iv = explainer.explain(x, budget=int(BUDGET_LOCAL), random_state=0)
    baseline = float(getattr(iv, "baseline_value", 0.0))
    
    
    main_effects = extract_main_effects(iv, feature_names)
    pair_df = extract_pair_matrix(iv, feature_names)
    
    
    print("\n" + "="*90)
    print("LOCAL EXPLANATION (single test instance)")
    print("="*90)
    print(f"Index={INDEX} | max_order={MAX_ORDER} | budget={BUDGET_LOCAL} | instance={INSTANCE_I}")
    print(f"Prediction: {pred:.6f} | True: {y_true:.6f} | Baseline (if available): {baseline:.6f}")
    
    
    print("\nTop main effects (signed):")
    display(main_effects.reindex(main_effects.abs().sort_values(ascending=False).head(TOP_K).index).to_frame())
    
    
    print("\nASCII view (signed main effects, top-k):")
    print(ascii_bar(main_effects, top_k=TOP_K))
    
    
    print("\nTop pairwise interactions by |value| (local):")
    pairs = []
    for i in range(n_features):
       for j in range(i+1, n_features):
           v = float(pair_df.iat[i, j])
           pairs.append((feature_names[i], feature_names[j], v, abs(v)))
    pairs_df = pd.DataFrame(pairs, columns=["feature_i", "feature_j", "interaction", "abs_interaction"]).sort_values("abs_interaction", ascending=False).head(min(25, len(pairs)))
    display(pairs_df)
    
    
    fig1 = plot_local_feature_bar(main_effects, TOP_K)
    fig2 = plot_local_interaction_heatmap(pair_df, list(main_effects.abs().sort_values(ascending=False).head(TOP_K).index))
    fig3 = plot_waterfall(baseline, main_effects, TOP_K)
    
    
    fig1.show()
    fig2.show()
    fig3.show()
    
    
    if GLOBAL_ON:
       print("\n" + "="*90)
       print("GLOBAL SUMMARIES (sampled over multiple test points)")
       print("="*90)
       GLOBAL_N = int(np.clip(GLOBAL_N, 5, len(X_test)))
       sample = X_test.sample(n=GLOBAL_N, random_state=1).values
    
    
       global_main, global_pair = global_summaries(
           explainer=explainer,
           X_samples=sample,
           feature_names=feature_names,
           budget=int(BUDGET_GLOBAL),
           seed=123,
       )
    
    
       print(f"Samples={GLOBAL_N} | budget/sample={BUDGET_GLOBAL}")
       print("\nGlobal feature importance (mean |main effect|):")
       display(global_main.head(TOP_K))
    
    
       top_feats_global = list(global_main["feature"].head(TOP_K).values)
       sub = global_pair.loc[top_feats_global, top_feats_global]
    
    
       figg1 = px.bar(global_main.head(TOP_K), x="mean_abs_main_effect", y="feature", orientation="h", title="Global Feature Importance (mean |main effect|, sampled)")
       figg1.update_layout(yaxis={"categoryorder": "total ascending"})
       figg2 = px.imshow(sub.values, x=sub.columns, y=sub.index, aspect="auto", title="Global Pairwise Interaction Importance (mean |interaction|, sampled)")
    
    
       figg1.show()
       figg2.show()
    
    
    print("\nDone. If you want it faster: lower budgets or GLOBAL_N, or set MAX_ORDER=1.")
    
    
    



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleIndia’s economic growth slips to 7.8%, but still leads major nations
    Next Article Market jitters hit KSE-100, index down 15,000 factors – Enterprise
    Naveed Ahmad
    • Website
    • Tumblr

    Related Posts

    AI & Tech

    Anthropic Hits Again After US Army Labels It a ‘Provide Chain Threat’

    March 2, 2026
    AI & Tech

    The Data Centers Have Arrived at the Edge of the Arctic Circle

    March 2, 2026
    AI & Tech

    FireRedTeam Releases FireRed-OCR-2B Utilizing GRPO to Solve Structural Hallucinations in Tables and LaTeX for Software Developers

    March 2, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Demo
    Top Posts

    How to Get a Bigger Penis – The Stem Cell Secret to Natural Penis Enlargement & A Quiz

    February 22, 20261 Views

    10 Totally different Methods to Safe Your Enterprise Premises

    February 19, 20261 Views

    Oatly loses ‘milk’ branding battle in UK Supreme Courtroom

    February 12, 20261 Views
    Stay In Touch
    • Facebook
    • YouTube
    • TikTok
    • WhatsApp
    • Twitter
    • Instagram
    Latest Reviews

    Subscribe to Updates

    Get the latest tech news from FooBar about tech, design and biz.

    Demo
    Most Popular

    How to Get a Bigger Penis – The Stem Cell Secret to Natural Penis Enlargement & A Quiz

    February 22, 20261 Views

    10 Totally different Methods to Safe Your Enterprise Premises

    February 19, 20261 Views

    Oatly loses ‘milk’ branding battle in UK Supreme Courtroom

    February 12, 20261 Views
    Our Picks

    Excessive Danger Zone? Analysts Cut up as Bitcoin (BTC) Ignores Geopolitical Chaos

    March 2, 2026

    How to Play as Assassin

    March 2, 2026

    Public Sector Group Peshawar Jobs Discover 2026 2026 Job Commercial Pakistan

    March 2, 2026

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    Facebook X (Twitter) Instagram Pinterest
    • About Us
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    • Advertise
    • Disclaimer
    © 2026 TheNews92.com. All Rights Reserved. Unauthorized reproduction or redistribution of content is strictly prohibited.

    Type above and press Enter to search. Press Esc to cancel.