Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
d0dfceec
Unverified
Commit
d0dfceec
authored
Apr 25, 2023
by
James Lamb
Committed by
GitHub
Apr 25, 2023
Browse files
[ci] [python-package] fix mypy errors about Dataset._set_init_score_by_predictor() (#5850)
parent
8670013d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
python-package/lightgbm/basic.py
python-package/lightgbm/basic.py
+6
-4
No files found.
python-package/lightgbm/basic.py
View file @
d0dfceec
...
@@ -1744,9 +1744,11 @@ class Dataset:
...
@@ -1744,9 +1744,11 @@ class Dataset:
data_has_header = any(self.params.get(alias, False) for alias in _ConfigAliases.get("header"))
data_has_header = any(self.params.get(alias, False) for alias in _ConfigAliases.get("header"))
num_data = self.num_data()
num_data = self.num_data()
if predictor is not None:
if predictor is not None:
init_score
=
predictor
.
predict
(
data
,
init_score: Union[np.ndarray, scipy.sparse.spmatrix] = predictor.predict(
raw_score
=
True
,
data=data,
data_has_header
=
data_has_header
)
raw_score=True,
data_has_header=data_has_header
)
init_score = init_score.ravel()
init_score = init_score.ravel()
if used_indices is not None:
if used_indices is not None:
assert not self._need_slice
assert not self._need_slice
...
@@ -1765,7 +1767,7 @@ class Dataset:
...
@@ -1765,7 +1767,7 @@ class Dataset:
new_init_score[j * num_data + i] = init_score[i * predictor.num_class + j]
new_init_score[j * num_data + i] = init_score[i * predictor.num_class + j]
init_score = new_init_score
init_score = new_init_score
elif self.init_score is not None:
elif self.init_score is not None:
init_score
=
np
.
zeros
(
self
.
init_score
.
shape
,
dtype
=
np
.
float64
)
init_score = np.
full_like
(self.init_score
, fill_value=0.0
, dtype=np.float64)
else:
else:
return self
return self
self.set_init_score(init_score)
self.set_init_score(init_score)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment