• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mmschlk / shapiq / 18754124332

23 Oct 2025 03:48PM UTC coverage: 92.865% (-0.2%) from 93.032%
18754124332

Pull #431

github

web-flow
Merge e4a9a83cb into 830c6bc23
Pull Request #431: Product kernel explainer

186 of 210 new or added lines in 13 files covered. (88.57%)

2 existing lines in 1 file now uncovered.

5375 of 5788 relevant lines covered (92.86%)

0.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.61
/src/shapiq/explainer/product_kernel/validation.py
1
"""Conversion functions for the product kernel explainer implementation."""
2

3
from __future__ import annotations
1✔
4

5
from typing import TYPE_CHECKING
1✔
6

7
from sklearn.gaussian_process import GaussianProcessRegressor
1✔
8
from sklearn.svm import SVC, SVR
1✔
9

10
from .base import ProductKernelModel
1✔
11
from .conversion import convert_gp_reg, convert_svm
1✔
12

13
if TYPE_CHECKING:
1✔
NEW
14
    from shapiq.typing import Model
×
15

16

17
SUPPORTED_MODELS = {
1✔
18
    "sklearn.svm.SVR",
19
    "sklearn.svm.SVC",
20
    "sklearn.gaussian_process.GaussianProcessRegressor",
21
}
22

23

24
def validate_pk_model(
1✔
25
    model: Model,  # pyright: ignore[reportInvalidTypeVarUse]
26
) -> ProductKernelModel:
27
    """Validate the product kernel model.
28

29
    Args:
30
        model: The model to validate.
31

32
    Returns:
33
        The validated product kernel model.
34

35
    Raises:
36
        TypeError: If the model is not supported.
37
    """
38
    # product kernel model already in the correct format
39
    if isinstance(model, ProductKernelModel):
1✔
NEW
40
        return model
×
41

42
    if isinstance(model, SVR):
1✔
43
        return convert_svm(model)
1✔
44

45
    if isinstance(model, SVC):
1✔
46
        if model.classes_.shape[0] == 2:
1✔
47
            return convert_svm(model)
1✔
NEW
48
        msg = "Only binary SVM classification supported."
×
NEW
49
        raise TypeError(msg)
×
50

51
    if isinstance(model, GaussianProcessRegressor):
1✔
52
        return convert_gp_reg(model)
1✔
53

54
    msg = f"Unsupported model type.Supported models are: {SUPPORTED_MODELS}"
1✔
55
    raise TypeError(msg)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc