fix flake8 warnings

bugfix/flake8
Taiga Noumi 2023-07-11 23:30:24 +09:00
parent 44b0169e4e
commit 3683b1e093
19 changed files with 85 additions and 27 deletions

View File

@ -24,7 +24,7 @@ result = run_experiment(params,
X_train,
y_train,
X_test,
'./wine-quality-{time}',
'./wine-quality-{time}',
type_of_target='continuous',
with_mlflow=True,
with_auto_hpo=True)

View File

@ -1 +1,5 @@
from nyaggle.version import __version__
__all__ = [
"__version__",
]

View File

@ -1,2 +1,8 @@
from nyaggle.ensemble.averaging import averaging, averaging_opt
from nyaggle.ensemble.stacking import stacking
from nyaggle.ensemble.stacking import stacking
__all__ = [
"averaging",
"averaging_opt",
"stacking",
]

View File

@ -1,6 +1,3 @@
from collections import namedtuple
EnsembleResult = namedtuple('EnsembleResult', ['test_prediction', 'oof_prediction', 'score'])

View File

@ -1,7 +1,7 @@
# pytorch
try:
import torch
import torch # noQA
_has_torch = True
except ImportError:
_has_torch = False
@ -15,7 +15,7 @@ def requires_torch():
# mlflow
try:
import mlflow
import mlflow # noQA
_has_mlflow = True
except ImportError:
_has_mlflow = False
@ -30,7 +30,7 @@ def requires_mlflow():
try:
import lightgbm
import lightgbm # noQA
_has_lightgbm = True
except ImportError:
_has_lightgbm = False
@ -45,7 +45,7 @@ def requires_lightgbm():
try:
import catboost
import catboost # noQA
_has_catboost = True
# TODO check catboost version >= 0.17
except ImportError:
@ -61,7 +61,7 @@ def requires_catboost():
try:
import xgboost
import xgboost # noQA
_has_xgboost = True
except ImportError:
_has_xgboost = False

View File

@ -1,2 +1,10 @@
from nyaggle.experiment.experiment import Experiment, add_leaderboard_score
from nyaggle.experiment.run import autoprep_gbdt, run_experiment, find_best_lgbm_parameter
__all__ = [
"Experiment",
"add_leaderboard_score",
"autoprep_gbdt",
"run_experiment",
"find_best_lgbm_parameter",
]

View File

@ -1 +1,6 @@
from nyaggle.feature.category_encoder.target_encoder import KFoldEncoderWrapper, TargetEncoder
__all__ = [
"KFoldEncoderWrapper",
"TargetEncoder",
]

View File

@ -7,19 +7,19 @@
# https://github.com/pfnet-research/xfeat/blob/master/xfeat/helper.py
# -----------------------------------------------------------------------------
# MIT License
#
#
# Copyright (c) 2020 Preferred Networks, Inc.
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -71,7 +71,8 @@ def aggregation(
Used to aggregate values for the groupby.
agg_methods:
List of function or function names, e.g. ['mean', 'max', 'min', numpy.mean].
Do not use a lambda function because the name attribute of the lambda function cannot generate a unique string of column names in <lambda>.
Do not use a lambda function because the name attribute of the lambda function
cannot generate a unique string of column names in <lambda>.
Returns:
Tuple of output dataframe and new column names.
"""

View File

@ -1 +1,5 @@
from nyaggle.feature.nlp.bert import BertSentenceVectorizer
__all__ = [
"BertSentenceVectorizer",
]

View File

@ -58,7 +58,7 @@ class BertSentenceVectorizer(BaseFeaturizer):
self.tokenizer = transformers.BertJapaneseTokenizer.from_pretrained(pretrained_model_name)
self.model = transformers.BertModel.from_pretrained(pretrained_model_name)
else:
raise ValueError('Specified language type () is invalid.'.format(lang))
raise ValueError(f'Specified language type ({lang}) is invalid.')
self.lang = lang
self.n_components = n_components

View File

@ -1 +1,8 @@
from nyaggle.feature_store.feature_store import cached_feature, save_feature, load_feature, load_features
__all__ = [
"cached_feature",
"save_feature",
"load_feature",
"load_features"
]

View File

@ -1 +1,6 @@
from nyaggle.hyper_parameters.parameters import get_hyperparam_byname, list_hyperparams
__all__ = [
"get_hyperparam_byname",
"list_hyperparams",
]

View File

@ -1,7 +1,7 @@
parameters = [
{
"name": "ieee-2019-17th",
"url": "https://nbviewer.jupyter.org/github/tmheo/IEEE-Fraud-Detection-17th-Place-Solution/blob/master/notebook/IEEE-17th-Place-Solution-CatBoost-Ensemble.ipynb",
"url": "https://nbviewer.jupyter.org/github/tmheo/IEEE-Fraud-Detection-17th-Place-Solution/blob/master/notebook/IEEE-17th-Place-Solution-CatBoost-Ensemble.ipynb", # noQA
"competition": "ieee-fraud-detection",
"rank": 17,
"metric": "auc",
@ -42,4 +42,3 @@ parameters = [
}
},
]

View File

@ -28,7 +28,7 @@ parameters = [
},
{
"name": "ieee-2019-17th",
"url": "https://nbviewer.jupyter.org/github/tmheo/IEEE-Fraud-Detection-17th-Place-Solution/blob/master/notebook/IEEE-17th-Place-Solution-LightGBM.ipynb",
"url": "https://nbviewer.jupyter.org/github/tmheo/IEEE-Fraud-Detection-17th-Place-Solution/blob/master/notebook/IEEE-17th-Place-Solution-LightGBM.ipynb", # noQA
"competition": "ieee-fraud-detection",
"rank": 17,
"metric": "auc",
@ -98,7 +98,7 @@ parameters = [
# 2019, Santander Customer Transaction Prediction
{
"name": "santander-2019-2nd",
"url": "https://github.com/KazukiOnodera/santander-customer-transaction-prediction/blob/master/py/990_2nd_place_solution_golf.py",
"url": "https://github.com/KazukiOnodera/santander-customer-transaction-prediction/blob/master/py/990_2nd_place_solution_golf.py", # noQA
"competition": "santander-customer-transaction-prediction",
"rank": 2,
"metric": "auc",
@ -120,7 +120,7 @@ parameters = [
},
{
"name": "santander-2019-5th",
"url": "https://github.com/tnmichael309/Kaggle-Santander-Customer-Transaction-Prediction-5th-Place-Partial-Solution/blob/master/notebooks/LGB%20Model.ipynb",
"url": "https://github.com/tnmichael309/Kaggle-Santander-Customer-Transaction-Prediction-5th-Place-Partial-Solution/blob/master/notebooks/LGB%20Model.ipynb", # noQA
"competition": "santander-customer-transaction-prediction",
"rank": 5,
"metric": "auc",
@ -193,7 +193,7 @@ parameters = [
# 2018, Microsoft Malware Prediction
{
"name": "microsoft-2018-2nd",
"url": "https://github.com/imor-de/microsoft_malware_prediction_kaggle_2nd/blob/master/code/7_Submission_M2.ipynb",
"url": "https://github.com/imor-de/microsoft_malware_prediction_kaggle_2nd/blob/master/code/7_Submission_M2.ipynb", # noQA
"competition": "microsoft-malware-prediction",
"rank": 2,
"metric": "auc",

View File

@ -1 +1,7 @@
from nyaggle.testing.util import *
from nyaggle.testing.util import make_classification_df, make_regression_df, get_temp_directory
__all__ = [
"make_classification_df",
"make_regression_df",
"get_temp_directory",
]

View File

@ -60,8 +60,6 @@ def make_regression_df(n_samples: int = 1024,
return X, y
@contextmanager
def get_temp_directory() -> str:
path = None
@ -71,4 +69,3 @@ def get_temp_directory() -> str:
finally:
if path:
shutil.rmtree(path, ignore_errors=True)

View File

@ -1,3 +1,10 @@
from nyaggle.util.plot_importance import plot_importance
from nyaggle.util.traits import is_instance, is_gbdt_instance
from nyaggle.util.submission import make_submission_df
__all__ = [
"plot_importance",
"is_instance",
"is_gbdt_instance",
"make_submission_df",
]

View File

@ -63,7 +63,7 @@ def is_instance(obj, class_path_str: Union[str, List, Tuple]) -> bool:
# Check module exists
try:
spec = importlib.util.find_spec(module_name)
except:
except (ValueError, AttributeError, ModuleNotFoundError):
spec = None
if spec is None:
continue

View File

@ -2,3 +2,15 @@ from nyaggle.validation.cross_validate import cross_validate
from nyaggle.validation.adversarial_validate import adversarial_validate
from nyaggle.validation.split import \
check_cv, TimeSeriesSplit, SlidingWindowSplit, Take, Nth, Skip, StratifiedGroupKFold
__all__ = [
"cross_validate",
"adversarial_validate",
"check_cv",
"TimeSeriesSplit",
"SlidingWindowSplit",
"Take",
"Nth",
"Skip",
"StratifiedGroupKFold",
]