Skip to content

Commit 73627dd

Browse files
author
Tomoki Ohtsuki
committed
pre-commit
1 parent 7b05882 commit 73627dd

5 files changed

Lines changed: 215 additions & 102 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ skip = ["cp38-*", "pp38-*"]
5757
archs = ["auto64"]
5858

5959
[tool.cibuildwheel.macos.environment]
60-
MACOSX_DEPLOYMENT_TARGET = "10.14"
60+
MACOSX_DEPLOYMENT_TARGET = "10.14"
Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,48 @@
11
from collections.abc import Sequence
22
from typing import Annotated
33

4-
from numpy.typing import ArrayLike
54
import scipy.sparse
6-
5+
from numpy.typing import ArrayLike
76

87
class Metrics:
98
def __init__(self, arg: int, /) -> None: ...
10-
119
def merge(self, arg: Metrics, /) -> None: ...
12-
1310
def as_dict(self) -> dict[str, float]: ...
1411

1512
class EvaluatorCore:
16-
def __init__(self, grount_truth: scipy.sparse.csr_matrix[float], recommendable: Sequence[Sequence[int]]) -> None: ...
17-
18-
def get_metrics_f64(self, score_array: Annotated[ArrayLike, dict(dtype='float64', shape=(None, None))], cutoff: int, offset: int, n_threads: int, recall_with_cutoff: bool = False) -> Metrics: ...
19-
20-
def get_metrics_f32(self, score_array: Annotated[ArrayLike, dict(dtype='float32', shape=(None, None))], cutoff: int, offset: int, n_threads: int, recall_with_cutoff: bool = False) -> Metrics: ...
21-
13+
def __init__(
14+
self,
15+
grount_truth: scipy.sparse.csr_matrix[float],
16+
recommendable: Sequence[Sequence[int]],
17+
) -> None: ...
18+
def get_metrics_f64(
19+
self,
20+
score_array: Annotated[ArrayLike, dict(dtype="float64", shape=(None, None))],
21+
cutoff: int,
22+
offset: int,
23+
n_threads: int,
24+
recall_with_cutoff: bool = False,
25+
) -> Metrics: ...
26+
def get_metrics_f32(
27+
self,
28+
score_array: Annotated[ArrayLike, dict(dtype="float32", shape=(None, None))],
29+
cutoff: int,
30+
offset: int,
31+
n_threads: int,
32+
recall_with_cutoff: bool = False,
33+
) -> Metrics: ...
2234
def get_ground_truth(self) -> scipy.sparse.csr_matrix[float]: ...
23-
2435
def cache_X_as_set(self, arg: int, /) -> None: ...
25-
26-
def __getstate__(self) -> tuple[scipy.sparse.csr_matrix[float], list[list[int]]]: ...
27-
28-
def __setstate__(self, arg: tuple[scipy.sparse.csr_matrix[float], Sequence[Sequence[int]]], /) -> None: ...
29-
30-
def evaluate_list_vs_list(recomemndations: Sequence[Sequence[int]], grount_truths: Sequence[Sequence[int]], n_items: int, n_threads: int) -> Metrics: ...
36+
def __getstate__(
37+
self,
38+
) -> tuple[scipy.sparse.csr_matrix[float], list[list[int]]]: ...
39+
def __setstate__(
40+
self, arg: tuple[scipy.sparse.csr_matrix[float], Sequence[Sequence[int]]], /
41+
) -> None: ...
42+
43+
def evaluate_list_vs_list(
44+
recomemndations: Sequence[Sequence[int]],
45+
grount_truths: Sequence[Sequence[int]],
46+
n_items: int,
47+
n_threads: int,
48+
) -> Metrics: ...
Lines changed: 62 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import enum
22
from typing import Annotated
33

4-
from numpy.typing import ArrayLike
54
import scipy.sparse
6-
5+
from numpy.typing import ArrayLike
76

87
class LossType(enum.Enum):
98
ORIGINAL = 0
@@ -26,78 +25,97 @@ CHOLESKY: SolverType = SolverType.CHOLESKY
2625
CG: SolverType = SolverType.CG
2726

2827
class IALSModelConfig:
29-
def __init__(self, arg0: int, arg1: float, arg2: float, arg3: float, arg4: float, arg5: int, arg6: LossType, /) -> None: ...
30-
28+
def __init__(
29+
self,
30+
arg0: int,
31+
arg1: float,
32+
arg2: float,
33+
arg3: float,
34+
arg4: float,
35+
arg5: int,
36+
arg6: LossType,
37+
/,
38+
) -> None: ...
3139
def __getstate__(self) -> tuple: ...
32-
33-
def __setstate__(self, arg: tuple[int, float, float, float, float, int, LossType], /) -> None: ...
40+
def __setstate__(
41+
self, arg: tuple[int, float, float, float, float, int, LossType], /
42+
) -> None: ...
3443

3544
class IALSModelConfigBuilder:
3645
def __init__(self) -> None: ...
37-
3846
def build(self) -> IALSModelConfig: ...
39-
4047
def set_K(self, arg: int, /) -> IALSModelConfigBuilder: ...
41-
4248
def set_alpha0(self, arg: float, /) -> IALSModelConfigBuilder: ...
43-
4449
def set_reg(self, arg: float, /) -> IALSModelConfigBuilder: ...
45-
4650
def set_nu(self, arg: float, /) -> IALSModelConfigBuilder: ...
47-
4851
def set_init_stdev(self, arg: float, /) -> IALSModelConfigBuilder: ...
49-
5052
def set_random_seed(self, arg: int, /) -> IALSModelConfigBuilder: ...
51-
5253
def set_loss_type(self, arg: LossType, /) -> IALSModelConfigBuilder: ...
5354

5455
class IALSSolverConfig:
55-
def __init__(self, arg0: int, arg1: SolverType, arg2: int, arg3: int, arg4: int, /) -> None: ...
56-
56+
def __init__(
57+
self, arg0: int, arg1: SolverType, arg2: int, arg3: int, arg4: int, /
58+
) -> None: ...
5759
def __getstate__(self) -> tuple[int, SolverType, int, int, int]: ...
58-
5960
def __setstate__(self, arg: tuple[int, SolverType, int, int, int], /) -> None: ...
6061

6162
class IALSSolverConfigBuilder:
6263
def __init__(self) -> None: ...
63-
6464
def build(self) -> IALSSolverConfig: ...
65-
6665
def set_n_threads(self, arg: int, /) -> IALSSolverConfigBuilder: ...
67-
6866
def set_solver_type(self, arg: SolverType, /) -> IALSSolverConfigBuilder: ...
69-
7067
def set_max_cg_steps(self, arg: int, /) -> IALSSolverConfigBuilder: ...
71-
7268
def set_ialspp_subspace_dimension(self, arg: int, /) -> IALSSolverConfigBuilder: ...
73-
7469
def set_ialspp_iteration(self, arg: int, /) -> IALSSolverConfigBuilder: ...
7570

7671
class IALSTrainer:
77-
def __init__(self, arg0: IALSModelConfig, arg1: scipy.sparse.csr_matrix[float], /) -> None: ...
78-
72+
def __init__(
73+
self, arg0: IALSModelConfig, arg1: scipy.sparse.csr_matrix[float], /
74+
) -> None: ...
7975
def step(self, arg: IALSSolverConfig, /) -> None: ...
80-
81-
def user_scores(self, arg0: int, arg1: int, arg2: IALSSolverConfig, /) -> Annotated[ArrayLike, dict(dtype='float32', shape=(None, None), order='C')]: ...
82-
83-
def transform_user(self, arg0: scipy.sparse.csr_matrix[float], arg1: IALSSolverConfig, /) -> Annotated[ArrayLike, dict(dtype='float32', shape=(None, None), order='C')]: ...
84-
85-
def transform_item(self, arg0: scipy.sparse.csr_matrix[float], arg1: IALSSolverConfig, /) -> Annotated[ArrayLike, dict(dtype='float32', shape=(None, None), order='C')]: ...
86-
76+
def user_scores(
77+
self, arg0: int, arg1: int, arg2: IALSSolverConfig, /
78+
) -> Annotated[ArrayLike, dict(dtype="float32", shape=(None, None), order="C")]: ...
79+
def transform_user(
80+
self, arg0: scipy.sparse.csr_matrix[float], arg1: IALSSolverConfig, /
81+
) -> Annotated[ArrayLike, dict(dtype="float32", shape=(None, None), order="C")]: ...
82+
def transform_item(
83+
self, arg0: scipy.sparse.csr_matrix[float], arg1: IALSSolverConfig, /
84+
) -> Annotated[ArrayLike, dict(dtype="float32", shape=(None, None), order="C")]: ...
8785
def compute_loss(self, arg: IALSSolverConfig, /) -> float: ...
88-
8986
@property
90-
def user(self) -> Annotated[ArrayLike, dict(dtype='float32', shape=(None, None), order='C')]: ...
91-
87+
def user(
88+
self,
89+
) -> Annotated[ArrayLike, dict(dtype="float32", shape=(None, None), order="C")]: ...
9290
@user.setter
93-
def user(self, arg: Annotated[ArrayLike, dict(dtype='float32', shape=(None, None), order='C')], /) -> None: ...
94-
91+
def user(
92+
self,
93+
arg: Annotated[ArrayLike, dict(dtype="float32", shape=(None, None), order="C")],
94+
/,
95+
) -> None: ...
9596
@property
96-
def item(self) -> Annotated[ArrayLike, dict(dtype='float32', shape=(None, None), order='C')]: ...
97-
97+
def item(
98+
self,
99+
) -> Annotated[ArrayLike, dict(dtype="float32", shape=(None, None), order="C")]: ...
98100
@item.setter
99-
def item(self, arg: Annotated[ArrayLike, dict(dtype='float32', shape=(None, None), order='C')], /) -> None: ...
100-
101-
def __getstate__(self) -> tuple[IALSModelConfig, Annotated[ArrayLike, dict(dtype='float32', shape=(None, None), order='C')], Annotated[ArrayLike, dict(dtype='float32', shape=(None, None), order='C')]]: ...
102-
103-
def __setstate__(self, arg: tuple[IALSModelConfig, Annotated[ArrayLike, dict(dtype='float32', shape=(None, None), order='C')], Annotated[ArrayLike, dict(dtype='float32', shape=(None, None), order='C')]], /) -> None: ...
101+
def item(
102+
self,
103+
arg: Annotated[ArrayLike, dict(dtype="float32", shape=(None, None), order="C")],
104+
/,
105+
) -> None: ...
106+
def __getstate__(
107+
self,
108+
) -> tuple[
109+
IALSModelConfig,
110+
Annotated[ArrayLike, dict(dtype="float32", shape=(None, None), order="C")],
111+
Annotated[ArrayLike, dict(dtype="float32", shape=(None, None), order="C")],
112+
]: ...
113+
def __setstate__(
114+
self,
115+
arg: tuple[
116+
IALSModelConfig,
117+
Annotated[ArrayLike, dict(dtype="float32", shape=(None, None), order="C")],
118+
Annotated[ArrayLike, dict(dtype="float32", shape=(None, None), order="C")],
119+
],
120+
/,
121+
) -> None: ...

src/irspack/recommenders/_knn.pyi

Lines changed: 65 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,78 @@
11
import scipy.sparse
22

3-
43
class CosineSimilarityComputer:
5-
def __init__(self, X: scipy.sparse.csr_matrix[float], shrinkage: float, normalize: bool, n_threads: int = 1, max_chunk_size: int = 128) -> None: ...
6-
7-
def compute_similarity(self, arg0: scipy.sparse.csr_matrix[float], arg1: int, /) -> scipy.sparse.csr_matrix[float]: ...
4+
def __init__(
5+
self,
6+
X: scipy.sparse.csr_matrix[float],
7+
shrinkage: float,
8+
normalize: bool,
9+
n_threads: int = 1,
10+
max_chunk_size: int = 128,
11+
) -> None: ...
12+
def compute_similarity(
13+
self, arg0: scipy.sparse.csr_matrix[float], arg1: int, /
14+
) -> scipy.sparse.csr_matrix[float]: ...
815

916
class JaccardSimilarityComputer:
10-
def __init__(self, X: scipy.sparse.csr_matrix[float], shrinkage: float, n_threads: int = 1, max_chunk_size: int = 128) -> None: ...
11-
12-
def compute_similarity(self, arg0: scipy.sparse.csr_matrix[float], arg1: int, /) -> scipy.sparse.csr_matrix[float]: ...
17+
def __init__(
18+
self,
19+
X: scipy.sparse.csr_matrix[float],
20+
shrinkage: float,
21+
n_threads: int = 1,
22+
max_chunk_size: int = 128,
23+
) -> None: ...
24+
def compute_similarity(
25+
self, arg0: scipy.sparse.csr_matrix[float], arg1: int, /
26+
) -> scipy.sparse.csr_matrix[float]: ...
1327

1428
class TverskyIndexComputer:
15-
def __init__(self, X: scipy.sparse.csr_matrix[float], shrinkage: float, alpha: float, beta: float, n_threads: int = 1, max_chunk_size: int = 128) -> None: ...
16-
17-
def compute_similarity(self, arg0: scipy.sparse.csr_matrix[float], arg1: int, /) -> scipy.sparse.csr_matrix[float]: ...
29+
def __init__(
30+
self,
31+
X: scipy.sparse.csr_matrix[float],
32+
shrinkage: float,
33+
alpha: float,
34+
beta: float,
35+
n_threads: int = 1,
36+
max_chunk_size: int = 128,
37+
) -> None: ...
38+
def compute_similarity(
39+
self, arg0: scipy.sparse.csr_matrix[float], arg1: int, /
40+
) -> scipy.sparse.csr_matrix[float]: ...
1841

1942
class AsymmetricSimilarityComputer:
20-
def __init__(self, X: scipy.sparse.csr_matrix[float], shrinkage: float, alpha: float, n_threads: int = 1, max_chunk_size: int = 128) -> None: ...
21-
22-
def compute_similarity(self, arg0: scipy.sparse.csr_matrix[float], arg1: int, /) -> scipy.sparse.csr_matrix[float]: ...
43+
def __init__(
44+
self,
45+
X: scipy.sparse.csr_matrix[float],
46+
shrinkage: float,
47+
alpha: float,
48+
n_threads: int = 1,
49+
max_chunk_size: int = 128,
50+
) -> None: ...
51+
def compute_similarity(
52+
self, arg0: scipy.sparse.csr_matrix[float], arg1: int, /
53+
) -> scipy.sparse.csr_matrix[float]: ...
2354

2455
class P3alphaComputer:
25-
def __init__(self, X: scipy.sparse.csr_matrix[float], alpha: float = 0, n_threads: int = 1, max_chunk_size: int = 128) -> None: ...
26-
27-
def compute_W(self, arg0: scipy.sparse.csr_matrix[float], arg1: int, /) -> scipy.sparse.csc_matrix[float]: ...
56+
def __init__(
57+
self,
58+
X: scipy.sparse.csr_matrix[float],
59+
alpha: float = 0,
60+
n_threads: int = 1,
61+
max_chunk_size: int = 128,
62+
) -> None: ...
63+
def compute_W(
64+
self, arg0: scipy.sparse.csr_matrix[float], arg1: int, /
65+
) -> scipy.sparse.csc_matrix[float]: ...
2866

2967
class RP3betaComputer:
30-
def __init__(self, X: scipy.sparse.csr_matrix[float], alpha: float = 0, beta: float = 0, n_threads: int = 1, max_chunk_size: int = 128) -> None: ...
31-
32-
def compute_W(self, arg0: scipy.sparse.csr_matrix[float], arg1: int, /) -> scipy.sparse.csc_matrix[float]: ...
68+
def __init__(
69+
self,
70+
X: scipy.sparse.csr_matrix[float],
71+
alpha: float = 0,
72+
beta: float = 0,
73+
n_threads: int = 1,
74+
max_chunk_size: int = 128,
75+
) -> None: ...
76+
def compute_W(
77+
self, arg0: scipy.sparse.csr_matrix[float], arg1: int, /
78+
) -> scipy.sparse.csc_matrix[float]: ...

0 commit comments

Comments
 (0)