mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-13 15:56:57 +08:00
Fix pylint (#888)
* add_pylint_to_workflow * fix-pylint * fix_pylinterror * fix-issue
This commit is contained in:
@@ -13,7 +13,6 @@ class BaseModel(Serializable, metaclass=abc.ABCMeta):
|
||||
@abc.abstractmethod
|
||||
def predict(self, *args, **kwargs) -> object:
|
||||
"""Make predictions after modeling things"""
|
||||
pass
|
||||
|
||||
def __call__(self, *args, **kwargs) -> object:
|
||||
"""leverage Python syntactic sugar to make the models' behaviors like functions"""
|
||||
|
||||
@@ -13,7 +13,7 @@ reduce: {(A,B): {C1: object, C2: object}} -> {(A,B): object}
|
||||
"""
|
||||
|
||||
from qlib.model.ens.ensemble import Ensemble, RollingEnsemble
|
||||
from typing import Callable, Union
|
||||
from typing import Callable
|
||||
from joblib import Parallel, delayed
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@ class FeatureInt:
|
||||
class LightGBMFInt(FeatureInt):
|
||||
"""LightGBM (F)eature (Int)erpreter"""
|
||||
|
||||
def __init__(self):
|
||||
self.model = None
|
||||
|
||||
def get_feature_importance(self, *args, **kwargs) -> pd.Series:
|
||||
"""get feature importance
|
||||
|
||||
@@ -35,6 +38,8 @@ class LightGBMFInt(FeatureInt):
|
||||
parameters reference:
|
||||
https://lightgbm.readthedocs.io/en/latest/pythonapi/lightgbm.Booster.html?highlight=feature_importance#lightgbm.Booster.feature_importance
|
||||
"""
|
||||
return pd.Series(self.model.feature_importance(*args, **kwargs), index=self.model.feature_name()).sort_values(
|
||||
return pd.Series(
|
||||
self.model.feature_importance(*args, **kwargs), index=self.model.feature_name()
|
||||
).sort_values( # pylint: disable=E1101
|
||||
ascending=False
|
||||
)
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
import abc
|
||||
from qlib.model.meta.task import MetaTask
|
||||
from typing import Dict, Union, List, Tuple, Text
|
||||
from ...workflow.task.gen import RollingGen, task_generator
|
||||
from ...data.dataset.handler import DataHandler
|
||||
from ...utils.serial import Serializable
|
||||
|
||||
|
||||
@@ -73,4 +71,3 @@ class MetaTaskDataset(Serializable, metaclass=abc.ABCMeta):
|
||||
seg : Text
|
||||
the name of the segment
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
# Licensed under the MIT License.
|
||||
|
||||
import abc
|
||||
from qlib.contrib.meta.data_selection.dataset import MetaDatasetDS
|
||||
from typing import Union, List, Tuple
|
||||
from typing import List
|
||||
|
||||
from qlib.model.meta.task import MetaTask
|
||||
from .dataset import MetaTaskDataset
|
||||
|
||||
|
||||
@@ -23,7 +21,6 @@ class MetaModel(metaclass=abc.ABCMeta):
|
||||
"""
|
||||
The training process of the meta-model.
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def inference(self, *args, **kwargs) -> object:
|
||||
@@ -35,7 +32,6 @@ class MetaModel(metaclass=abc.ABCMeta):
|
||||
object:
|
||||
Some information to guide the model learning
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class MetaTaskModel(MetaModel):
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
import abc
|
||||
from typing import Union, List, Tuple
|
||||
|
||||
from qlib.data.dataset import Dataset
|
||||
from ...utils import init_instance_by_config
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ class RiskModel(BaseModel):
|
||||
"return_decomposed_components" in inspect.getfullargspec(self._predict).args
|
||||
), "This risk model does not support return decomposed components of the covariance matrix "
|
||||
|
||||
F, cov_b, var_u = self._predict(X, return_decomposed_components=True)
|
||||
F, cov_b, var_u = self._predict(X, return_decomposed_components=True) # pylint: disable=E1123
|
||||
return F, cov_b, var_u
|
||||
|
||||
# estimate covariance
|
||||
|
||||
@@ -12,17 +12,13 @@ In ``DelayTrainer``, the first step is only to save some necessary info to model
|
||||
"""
|
||||
|
||||
import socket
|
||||
import time
|
||||
import re
|
||||
from typing import Callable, List
|
||||
|
||||
from tqdm.auto import tqdm
|
||||
from qlib.data.dataset import Dataset
|
||||
from qlib.log import get_module_logger
|
||||
from qlib.model.base import Model
|
||||
from qlib.utils import flatten_dict, get_callable_kwargs, init_instance_by_config, auto_filter_kwargs, fill_placeholder
|
||||
from qlib.utils import flatten_dict, init_instance_by_config, auto_filter_kwargs, fill_placeholder
|
||||
from qlib.workflow import R
|
||||
from qlib.workflow.record_temp import SignalRecord
|
||||
from qlib.workflow.recorder import Recorder
|
||||
from qlib.workflow.task.manage import TaskManager, run_task
|
||||
from qlib.data.dataset.weight import Reweighter
|
||||
|
||||
Reference in New Issue
Block a user