Skip to content

Commit

Permalink
optimized supervised imports statements, unused imports removed.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielAvdar committed Jan 30, 2024
1 parent 2135803 commit 4122487
Show file tree
Hide file tree
Showing 56 changed files with 12 additions and 181 deletions.
1 change: 0 additions & 1 deletion supervised/algorithms/baseline.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import os

import sklearn
from sklearn.base import ClassifierMixin, RegressorMixin
Expand Down
3 changes: 1 addition & 2 deletions supervised/algorithms/catboost.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import copy
import logging
import os
import time

import numpy as np
Expand Down Expand Up @@ -28,7 +27,7 @@
logger.setLevel(LOG_LEVEL)

import catboost
from catboost import CatBoost, CatBoostClassifier, CatBoostRegressor, Pool
from catboost import CatBoostClassifier, CatBoostRegressor, Pool


def catboost_eval_metric(ml_task, eval_metric):
Expand Down
1 change: 0 additions & 1 deletion supervised/algorithms/decision_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from sklearn.base import BaseEstimator, ClassifierMixin, RegressorMixin
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor

from supervised.algorithms.algorithm import BaseAlgorithm
from supervised.algorithms.registry import (
BINARY_CLASSIFICATION,
MULTICLASS_CLASSIFICATION,
Expand Down
2 changes: 0 additions & 2 deletions supervised/algorithms/extra_trees.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import logging
import os

import sklearn
from sklearn.base import ClassifierMixin, RegressorMixin
from sklearn.ensemble import ExtraTreesClassifier, ExtraTreesRegressor

from supervised.algorithms.algorithm import BaseAlgorithm
from supervised.algorithms.registry import (
BINARY_CLASSIFICATION,
MULTICLASS_CLASSIFICATION,
Expand Down
3 changes: 0 additions & 3 deletions supervised/algorithms/knn.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import logging
import os

import numpy as np
import sklearn
from sklearn.base import ClassifierMixin, RegressorMixin
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier, KNeighborsRegressor

from supervised.algorithms.algorithm import BaseAlgorithm
from supervised.algorithms.registry import (
BINARY_CLASSIFICATION,
MULTICLASS_CLASSIFICATION,
Expand Down
1 change: 0 additions & 1 deletion supervised/algorithms/lightgbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import copy
import logging
import os
import time

import lightgbm as lgb
import numpy as np
Expand Down
3 changes: 0 additions & 3 deletions supervised/algorithms/linear.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import logging
import os
import warnings

import numpy as np
import pandas as pd
import sklearn
from sklearn.base import ClassifierMixin, RegressorMixin
from sklearn.exceptions import ConvergenceWarning
from sklearn.linear_model import LinearRegression, LogisticRegression

from supervised.algorithms.algorithm import BaseAlgorithm
from supervised.algorithms.registry import (
BINARY_CLASSIFICATION,
MULTICLASS_CLASSIFICATION,
Expand Down
1 change: 0 additions & 1 deletion supervised/algorithms/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from sklearn.base import ClassifierMixin, RegressorMixin
from sklearn.neural_network import MLPClassifier, MLPRegressor

from supervised.algorithms.algorithm import BaseAlgorithm
from supervised.algorithms.registry import (
BINARY_CLASSIFICATION,
MULTICLASS_CLASSIFICATION,
Expand Down
3 changes: 0 additions & 3 deletions supervised/algorithms/random_forest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import logging
import os

import numpy as np
import sklearn
from sklearn.base import ClassifierMixin, RegressorMixin
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor

from supervised.algorithms.algorithm import BaseAlgorithm
from supervised.algorithms.registry import (
BINARY_CLASSIFICATION,
MULTICLASS_CLASSIFICATION,
Expand Down
12 changes: 0 additions & 12 deletions supervised/algorithms/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,4 @@ def get_eval_metric(algorithm_name, ml_task, automl_eval_metric):

return automl_eval_metric


import supervised.algorithms.baseline
import supervised.algorithms.catboost
import supervised.algorithms.decision_tree
import supervised.algorithms.extra_trees
import supervised.algorithms.knn
import supervised.algorithms.lightgbm
import supervised.algorithms.linear
import supervised.algorithms.nn

# Import algorithm to be registered
import supervised.algorithms.random_forest
import supervised.algorithms.xgboost
5 changes: 0 additions & 5 deletions supervised/algorithms/xgboost.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import copy
import logging
import os
import time
from inspect import signature

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -31,8 +28,6 @@
logger = logging.getLogger(__name__)
logger.setLevel(LOG_LEVEL)

import tempfile


class XgbAlgorithmException(Exception):
def __init__(self, message):
Expand Down
1 change: 0 additions & 1 deletion supervised/automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
warnings.filterwarnings("ignore", message=".*The 'nopython' keyword.*")

from collections.abc import Iterable
from re import U

# libraries for type hints
from typing import List, Optional, Union
Expand Down
10 changes: 2 additions & 8 deletions supervised/base_automl.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import copy
import gc
import json
import logging
import os
import shutil
import sys
import time
import types
from abc import ABC
Expand All @@ -25,33 +22,30 @@
AlgorithmsRegistry,
)
from supervised.callbacks.early_stopping import EarlyStopping
from supervised.callbacks.learner_time_constraint import LearnerTimeConstraint
from supervised.callbacks.metric_logger import MetricLogger
from supervised.callbacks.total_time_constraint import TotalTimeConstraint
from supervised.ensemble import Ensemble
from supervised.exceptions import AutoMLException, NotTrainedException
from supervised.model_framework import ModelFramework
from supervised.preprocessing.exclude_missing_target import ExcludeRowsMissingTarget

# disable EDA
# from supervised.preprocessing.eda import EDA
from supervised.preprocessing.preprocessing_utils import PreprocessingUtils
from supervised.tuner.data_info import DataInfo
from supervised.tuner.mljar_tuner import MljarTuner
from supervised.tuner.time_controller import TimeController
from supervised.utils.automl_plots import AutoMLPlots
from supervised.utils.config import LOG_LEVEL, mem
from supervised.utils.config import LOG_LEVEL
from supervised.utils.data_validation import (
check_bool,
check_greater_than_zero_integer,
check_greater_than_zero_integer_or_float,
check_integer,
check_positive_integer,
)
from supervised.utils.jsonencoder import MLJSONEncoder
from supervised.utils.leaderboard_plots import LeaderboardPlots
from supervised.utils.metric import Metric, UserDefinedEvalMetric
from supervised.utils.utils import dump_data, load_data
from supervised.utils.jsonencoder import MLJSONEncoder

try:
import matplotlib.font_manager as font_manager
Expand Down
2 changes: 0 additions & 2 deletions supervised/callbacks/early_stopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
logger = logging.getLogger(__name__)
logger.setLevel(LOG_LEVEL)

from supervised.utils.config import mem


class EarlyStopping(Callback):
def __init__(self, params):
Expand Down
3 changes: 0 additions & 3 deletions supervised/callbacks/max_iters_constraint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import numpy as np
import pandas as pd

from supervised.callbacks.callback import Callback


Expand Down
2 changes: 0 additions & 2 deletions supervised/callbacks/metric_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

log = logging.getLogger(__name__)

import numpy as np

from supervised.callbacks.callback import Callback
from supervised.utils.metric import Metric

Expand Down
5 changes: 1 addition & 4 deletions supervised/ensemble.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import copy
import json
import logging
import operator
import os
import time
import uuid

import numpy as np
import pandas as pd

from supervised.algorithms.algorithm import BaseAlgorithm
from supervised.algorithms.registry import (
BINARY_CLASSIFICATION,
MULTICLASS_CLASSIFICATION,
Expand All @@ -19,13 +17,12 @@
from supervised.model_framework import ModelFramework
from supervised.utils.additional_metrics import AdditionalMetrics
from supervised.utils.config import LOG_LEVEL
from supervised.utils.metric import Metric
from supervised.utils.jsonencoder import MLJSONEncoder
from supervised.utils.metric import Metric

logger = logging.getLogger(__name__)
logger.setLevel(LOG_LEVEL)

import matplotlib.pyplot as plt
from tabulate import tabulate

from supervised.utils.learning_curves import LearningCurves
Expand Down
11 changes: 0 additions & 11 deletions supervised/fairness/metrics.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
import os

import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from sklearn.metrics import (
accuracy_score,
classification_report,
confusion_matrix,
f1_score,
matthews_corrcoef,
mean_absolute_error,
mean_absolute_percentage_error,
mean_squared_error,
precision_score,
r2_score,
recall_score,
roc_auc_score,
)

from supervised.fairness.optimization import FairnessOptimization
Expand Down
4 changes: 0 additions & 4 deletions supervised/fairness/optimization.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import os

import numpy as np
import pandas as pd
from matplotlib import pyplot as plt


class FairnessOptimization:
Expand Down
7 changes: 1 addition & 6 deletions supervised/model_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import json
import logging
import os
import sys
import time
import uuid
import zipfile

import numpy as np
import pandas as pd
Expand All @@ -20,22 +18,19 @@
)
from supervised.callbacks.callback_list import CallbackList
from supervised.exceptions import AutoMLException
from supervised.preprocessing.exclude_missing_target import ExcludeRowsMissingTarget
from supervised.preprocessing.preprocessing import Preprocessing
from supervised.utils.additional_metrics import AdditionalMetrics
from supervised.utils.config import LOG_LEVEL
from supervised.utils.jsonencoder import MLJSONEncoder
from supervised.utils.metric import Metric
from supervised.validation.validation_step import ValidationStep
from supervised.utils.jsonencoder import MLJSONEncoder

logger = logging.getLogger(__name__)
logger.setLevel(LOG_LEVEL)

import joblib
import optuna

from supervised.tuner.optuna.tuner import OptunaTuner
from supervised.utils.config import mem
from supervised.utils.learning_curves import LearningCurves


Expand Down
3 changes: 0 additions & 3 deletions supervised/preprocessing/datetime_transformer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import datetime
import json

import numpy as np
import pandas as pd

Expand Down
1 change: 0 additions & 1 deletion supervised/preprocessing/eda.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
import os
import re
import warnings
from collections import defaultdict

Expand Down
2 changes: 0 additions & 2 deletions supervised/preprocessing/exclude_missing_target.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import json
import logging
import os
import warnings

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion supervised/preprocessing/goldenfeatures_transformer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import itertools
import json
import os
Expand Down
3 changes: 0 additions & 3 deletions supervised/preprocessing/kmeans_transformer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import datetime
import json
import os
import time

import joblib
import numpy as np
import pandas as pd
from sklearn.cluster import MiniBatchKMeans
from sklearn.preprocessing import StandardScaler

Expand Down
2 changes: 0 additions & 2 deletions supervised/preprocessing/label_binarizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

import numpy as np


Expand Down
1 change: 0 additions & 1 deletion supervised/preprocessing/label_encoder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import copy
import logging
from decimal import Decimal

Expand Down
3 changes: 0 additions & 3 deletions supervised/preprocessing/loo_encoder.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import copy
import json
import logging
import warnings
from decimal import Decimal

import numpy as np
import pandas as pd
from category_encoders.leave_one_out import LeaveOneOutEncoder

Expand Down
4 changes: 0 additions & 4 deletions supervised/preprocessing/preprocessing.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import copy
import logging
import warnings

import numpy as np
import pandas as pd

from supervised.algorithms.registry import (
BINARY_CLASSIFICATION,
MULTICLASS_CLASSIFICATION,
REGRESSION,
)
from supervised.exceptions import AutoMLException
from supervised.preprocessing.datetime_transformer import DateTimeTransformer
Expand All @@ -21,7 +18,6 @@
from supervised.preprocessing.label_encoder import LabelEncoder
from supervised.preprocessing.preprocessing_categorical import PreprocessingCategorical
from supervised.preprocessing.preprocessing_missing import PreprocessingMissingValues
from supervised.preprocessing.preprocessing_utils import PreprocessingUtils
from supervised.preprocessing.scale import Scale
from supervised.preprocessing.text_transformer import TextTransformer
from supervised.utils.config import LOG_LEVEL
Expand Down
Loading

0 comments on commit 4122487

Please sign in to comment.