diff --git a/src/tests/audition_tests/test_distance_from_best.py b/src/tests/audition_tests/test_distance_from_best.py index 4eb7c1aee..ea8a01633 100644 --- a/src/tests/audition_tests/test_distance_from_best.py +++ b/src/tests/audition_tests/test_distance_from_best.py @@ -203,7 +203,7 @@ def test_BestDistancePlotter_plot(): def test_BestDistancePlotter_plot_bounds(): - class FakeDistanceTable(object): + class FakeDistanceTable: @property def observed_bounds(self): return { diff --git a/src/tests/audition_tests/test_selection_rule_performance.py b/src/tests/audition_tests/test_selection_rule_performance.py index 54a4812f3..eb759abaa 100644 --- a/src/tests/audition_tests/test_selection_rule_performance.py +++ b/src/tests/audition_tests/test_selection_rule_performance.py @@ -15,7 +15,7 @@ TRAIN_END_TIMES = ["2014-01-01", "2015-01-01"] -class MockSelectionRulePicker(object): +class MockSelectionRulePicker: def results_for_rule(*args, **kwargs): return [ { diff --git a/src/tests/catwalk_tests/test_storage.py b/src/tests/catwalk_tests/test_storage.py index 4050030ab..53c0a589d 100644 --- a/src/tests/catwalk_tests/test_storage.py +++ b/src/tests/catwalk_tests/test_storage.py @@ -24,7 +24,7 @@ from tests.utils import CallSpy -class SomeClass(object): +class SomeClass: def __init__(self, val): self.val = val diff --git a/src/tests/utils.py b/src/tests/utils.py index b45507047..5d6ef405f 100644 --- a/src/tests/utils.py +++ b/src/tests/utils.py @@ -32,7 +32,7 @@ def fake_labels(length): return numpy.array([random.choice([True, False]) for i in range(0, length)]) -class MockTrainedModel(object): +class MockTrainedModel: def predict_proba(self, dataset): return numpy.random.rand(len(dataset), len(dataset)) diff --git a/src/triage/component/architect/builders.py b/src/triage/component/architect/builders.py index c1d75fb12..7844a066e 100644 --- a/src/triage/component/architect/builders.py +++ b/src/triage/component/architect/builders.py @@ -11,7 +11,7 @@ from triage.util.pandas import downcast_matrix -class BuilderBase(object): +class BuilderBase: def __init__( self, db_config, diff --git a/src/triage/component/architect/entity_date_table_generators.py b/src/triage/component/architect/entity_date_table_generators.py index 728f14aa5..e58f9361b 100644 --- a/src/triage/component/architect/entity_date_table_generators.py +++ b/src/triage/component/architect/entity_date_table_generators.py @@ -7,7 +7,7 @@ DEFAULT_ACTIVE_STATE = "active" -class EntityDateTableGenerator(object): +class EntityDateTableGenerator: """Create a table containing state membership on different dates The structure of the output table is: diff --git a/src/triage/component/architect/feature_dictionary_creator.py b/src/triage/component/architect/feature_dictionary_creator.py index 4d0082001..011b048f1 100644 --- a/src/triage/component/architect/feature_dictionary_creator.py +++ b/src/triage/component/architect/feature_dictionary_creator.py @@ -3,7 +3,7 @@ from triage.util.structs import FeatureNameList -class FeatureDictionaryCreator(object): +class FeatureDictionaryCreator: def __init__(self, features_schema_name, db_engine): self.features_schema_name = features_schema_name self.db_engine = db_engine diff --git a/src/triage/component/architect/feature_generators.py b/src/triage/component/architect/feature_generators.py index d7c386d42..5855e7993 100644 --- a/src/triage/component/architect/feature_generators.py +++ b/src/triage/component/architect/feature_generators.py @@ -16,7 +16,7 @@ ) -class FeatureGenerator(object): +class FeatureGenerator: def __init__( self, db_engine, diff --git a/src/triage/component/architect/feature_group_creator.py b/src/triage/component/architect/feature_group_creator.py index 3b69daee2..2da3629a6 100644 --- a/src/triage/component/architect/feature_group_creator.py +++ b/src/triage/component/architect/feature_group_creator.py @@ -40,7 +40,7 @@ def all_subsetter(config_item, table, features): return features -class FeatureGroupCreator(object): +class FeatureGroupCreator: """Divides a feature dictionary into groups based on given criteria""" subsetters = { diff --git a/src/triage/component/architect/feature_group_mixer.py b/src/triage/component/architect/feature_group_mixer.py index 4873a2646..fa6e5b61a 100644 --- a/src/triage/component/architect/feature_group_mixer.py +++ b/src/triage/component/architect/feature_group_mixer.py @@ -67,7 +67,7 @@ def all_features(feature_groups): return [feature_dict] -class FeatureGroupMixer(object): +class FeatureGroupMixer: """Generates different combinations of feature groups based on a list of strategies""" diff --git a/src/triage/component/architect/label_generators.py b/src/triage/component/architect/label_generators.py index 056cddd39..6459f0e38 100644 --- a/src/triage/component/architect/label_generators.py +++ b/src/triage/component/architect/label_generators.py @@ -6,7 +6,7 @@ DEFAULT_LABEL_NAME = "outcome" -class LabelGeneratorNoOp(object): +class LabelGeneratorNoOp: def generate_all_labels(self, labels_table, as_of_dates, label_timespans): logging.warning( "No label configuration is available, so no labels will be created" @@ -21,7 +21,7 @@ def clean_up(self, labels_table_name): pass -class LabelGenerator(object): +class LabelGenerator: def __init__(self, db_engine, query, label_name=None, replace=True): self.db_engine = db_engine self.replace = replace diff --git a/src/triage/component/architect/planner.py b/src/triage/component/architect/planner.py index 3a2220895..8d916d7e3 100644 --- a/src/triage/component/architect/planner.py +++ b/src/triage/component/architect/planner.py @@ -6,7 +6,7 @@ from . import utils, entity_date_table_generators -class Planner(object): +class Planner: def __init__( self, feature_start_time, diff --git a/src/triage/component/architect/utils.py b/src/triage/component/architect/utils.py index b13498085..ef1c8a414 100644 --- a/src/triage/component/architect/utils.py +++ b/src/triage/component/architect/utils.py @@ -129,7 +129,7 @@ def fake_labels(length): return numpy.array([random.choice([True, False]) for i in range(0, length)]) -class MockTrainedModel(object): +class MockTrainedModel: def predict_proba(self, dataset): return numpy.random.rand(len(dataset), len(dataset)) diff --git a/src/triage/component/audition/__init__.py b/src/triage/component/audition/__init__.py index 7f5c9f438..ee952927b 100644 --- a/src/triage/component/audition/__init__.py +++ b/src/triage/component/audition/__init__.py @@ -12,7 +12,7 @@ from .pre_audition import PreAudition -class Auditioner(object): +class Auditioner: def __init__( self, db_engine, @@ -354,7 +354,7 @@ def register_selection_rule_grid(self, rule_grid, plot=True): self.plot_selection_rules() -class AuditionRunner(object): +class AuditionRunner: def __init__(self, config_dict, db_engine, directory=None): self.dir = directory self.config = config_dict diff --git a/src/triage/component/audition/distance_from_best.py b/src/triage/component/audition/distance_from_best.py index 2c62d69e1..d348c152e 100644 --- a/src/triage/component/audition/distance_from_best.py +++ b/src/triage/component/audition/distance_from_best.py @@ -8,7 +8,7 @@ from .plotting import plot_cats, plot_bounds -class DistanceFromBestTable(object): +class DistanceFromBestTable: def __init__(self, db_engine, models_table, distance_table): """A database table that stores the distance from models and the best model for that train end time for a variety of chosen metrics @@ -207,7 +207,7 @@ def dataframe_as_of(self, model_group_ids, train_end_time): return base_df[base_df["train_end_time"] == train_end_time] -class BestDistancePlotter(object): +class BestDistancePlotter: def __init__(self, distance_from_best_table, directory=None): """Generate a plot illustrating the effect of different below-best maximum thresholds across the dataset. diff --git a/src/triage/component/audition/model_group_performance.py b/src/triage/component/audition/model_group_performance.py index b3d4daf1c..ba8d539e7 100644 --- a/src/triage/component/audition/model_group_performance.py +++ b/src/triage/component/audition/model_group_performance.py @@ -7,7 +7,7 @@ from .utils import str_in_sql -class ModelGroupPerformancePlotter(object): +class ModelGroupPerformancePlotter: def __init__(self, distance_from_best_table, directory=None): """Generate a plot illustrating the performance of a model group over time diff --git a/src/triage/component/audition/pre_audition.py b/src/triage/component/audition/pre_audition.py index 74aa5869a..9da9d962d 100644 --- a/src/triage/component/audition/pre_audition.py +++ b/src/triage/component/audition/pre_audition.py @@ -1,7 +1,7 @@ import pandas as pd -class PreAudition(object): +class PreAudition: def __init__(self, db_engine): """Prepare the model_groups and train_end_times for Auditioner to use diff --git a/src/triage/component/audition/regrets.py b/src/triage/component/audition/regrets.py index 66325ec76..a22bce113 100644 --- a/src/triage/component/audition/regrets.py +++ b/src/triage/component/audition/regrets.py @@ -6,7 +6,7 @@ from .plotting import plot_cats, plot_bounds -class SelectionRulePicker(object): +class SelectionRulePicker: def __init__(self, distance_from_best_table): """Runs simulations of different model group selection rules @@ -102,7 +102,7 @@ def model_group_from_rule( return bound_selection_rule.pick(localized_df, train_end_time) -class SelectionRulePlotter(object): +class SelectionRulePlotter: """Plot selection rules Args: diff --git a/src/triage/component/audition/rules_maker.py b/src/triage/component/audition/rules_maker.py index cdbd74e0e..cb56c6c9b 100644 --- a/src/triage/component/audition/rules_maker.py +++ b/src/triage/component/audition/rules_maker.py @@ -1,4 +1,4 @@ -class BaseRules(object): +class BaseRules: def __init__(self): self._metric = None self._parameter = None diff --git a/src/triage/component/audition/selection_rule_performance.py b/src/triage/component/audition/selection_rule_performance.py index 983d9af3e..195af430c 100644 --- a/src/triage/component/audition/selection_rule_performance.py +++ b/src/triage/component/audition/selection_rule_performance.py @@ -3,7 +3,7 @@ from .plotting import plot_cats -class SelectionRulePerformancePlotter(object): +class SelectionRulePerformancePlotter: """Plot regrets over time Generates a simple line chart with audition.BoundSelectionRule objects as diff --git a/src/triage/component/audition/selection_rules.py b/src/triage/component/audition/selection_rules.py index 1d11ea16c..f4d8cfb66 100644 --- a/src/triage/component/audition/selection_rules.py +++ b/src/triage/component/audition/selection_rules.py @@ -447,7 +447,7 @@ def wm(x): } -class BoundSelectionRule(object): +class BoundSelectionRule: """A selection rule bound with a set of arguments Args: diff --git a/src/triage/component/audition/thresholding.py b/src/triage/component/audition/thresholding.py index 4e617a2c5..26255a79e 100644 --- a/src/triage/component/audition/thresholding.py +++ b/src/triage/component/audition/thresholding.py @@ -91,7 +91,7 @@ def model_groups_filter( return model_group_ids -class ModelGroupThresholder(object): +class ModelGroupThresholder: def __init__( self, distance_from_best_table, diff --git a/src/triage/component/catwalk/__init__.py b/src/triage/component/catwalk/__init__.py index ed92a755e..25a0eb508 100644 --- a/src/triage/component/catwalk/__init__.py +++ b/src/triage/component/catwalk/__init__.py @@ -16,7 +16,7 @@ TaskBatch = namedtuple('TaskBatch', ['parallelizable', 'tasks', 'description']) -class ModelTrainTester(object): +class ModelTrainTester: def __init__( self, matrix_storage_engine, diff --git a/src/triage/component/catwalk/baselines/rankers.py b/src/triage/component/catwalk/baselines/rankers.py index 8f8ad1ad6..045ffcb6e 100644 --- a/src/triage/component/catwalk/baselines/rankers.py +++ b/src/triage/component/catwalk/baselines/rankers.py @@ -3,7 +3,7 @@ from triage.component.catwalk.exceptions import BaselineFeatureNotInMatrix -class PercentileRankOneFeature(object): +class PercentileRankOneFeature: def __init__(self, feature, descend=False): self.feature = feature # which feature to rank on self.descend = ( diff --git a/src/triage/component/catwalk/baselines/thresholders.py b/src/triage/component/catwalk/baselines/thresholders.py index 76ab8fb39..54fa42067 100644 --- a/src/triage/component/catwalk/baselines/thresholders.py +++ b/src/triage/component/catwalk/baselines/thresholders.py @@ -28,7 +28,7 @@ def get_operator_method(operator_string): return operator_method -class SimpleThresholder(object): +class SimpleThresholder: """ The simple thresholder applies a set of predetermined logical rules to a test matrix to classify entities. By default, it will classify entities as 1 if they satisfy any of the rules. When 'and' is set as the logical_operator, diff --git a/src/triage/component/catwalk/evaluation.py b/src/triage/component/catwalk/evaluation.py index caab7facd..01607fc16 100644 --- a/src/triage/component/catwalk/evaluation.py +++ b/src/triage/component/catwalk/evaluation.py @@ -149,7 +149,7 @@ class MetricEvaluationResult(typing.NamedTuple): num_positive_labels: int -class ModelEvaluator(object): +class ModelEvaluator: """An object that can score models based on its known metrics""" """Available metric calculation functions diff --git a/src/triage/component/catwalk/individual_importance/__init__.py b/src/triage/component/catwalk/individual_importance/__init__.py index e5df8cc24..5b8ca772a 100644 --- a/src/triage/component/catwalk/individual_importance/__init__.py +++ b/src/triage/component/catwalk/individual_importance/__init__.py @@ -28,7 +28,7 @@ def save(self, importance_records, model_id, as_of_date, method_name): -class IndividualImportanceCalculator(object): +class IndividualImportanceCalculator: """Calculates and saves individual importance scores and rankings using different methods Args: diff --git a/src/triage/component/catwalk/metrics.py b/src/triage/component/catwalk/metrics.py index 054d54d29..35897d738 100644 --- a/src/triage/component/catwalk/metrics.py +++ b/src/triage/component/catwalk/metrics.py @@ -22,7 +22,7 @@ import numpy -class Metric(object): +class Metric: """decorator for metrics: result will be a callable metric with an `greater_is_better` parameter defined as either True or False depending on whether larger or smaller metric values indicate @@ -35,7 +35,7 @@ def __init__(self, greater_is_better): self.greater_is_better = greater_is_better def __call__(self, function, *params, **kwparams): - class DecoratedMetric(object): + class DecoratedMetric: def __init__(self, greater_is_better, function): self.greater_is_better = greater_is_better self.function = function diff --git a/src/triage/component/catwalk/model_grouping.py b/src/triage/component/catwalk/model_grouping.py index 9eda7109d..f15a97539 100644 --- a/src/triage/component/catwalk/model_grouping.py +++ b/src/triage/component/catwalk/model_grouping.py @@ -12,7 +12,7 @@ ] -class ModelGrouper(object): +class ModelGrouper: """Assign a model group id to given model input based on default or custom configuration This class is a wrapper around the `get_model_group_id` stored procedure, diff --git a/src/triage/component/catwalk/model_trainers.py b/src/triage/component/catwalk/model_trainers.py index 97837697c..aaabc0345 100644 --- a/src/triage/component/catwalk/model_trainers.py +++ b/src/triage/component/catwalk/model_trainers.py @@ -41,7 +41,7 @@ def flatten_grid_config(grid_config): yield class_path, parameters -class ModelTrainer(object): +class ModelTrainer: """Trains a series of classifiers using the same training set Args: project_path (string) path to project folder, diff --git a/src/triage/component/catwalk/predictors.py b/src/triage/component/catwalk/predictors.py index 77e57d227..591469aa9 100644 --- a/src/triage/component/catwalk/predictors.py +++ b/src/triage/component/catwalk/predictors.py @@ -17,7 +17,7 @@ class ModelNotFoundError(ValueError): pass -class Predictor(object): +class Predictor: expected_matrix_ts_format = "%Y-%m-%d %H:%M:%S" available_tiebreakers = AVAILABLE_TIEBREAKERS diff --git a/src/triage/component/catwalk/protected_groups_generators.py b/src/triage/component/catwalk/protected_groups_generators.py index 7e943b86f..5ceb231f5 100644 --- a/src/triage/component/catwalk/protected_groups_generators.py +++ b/src/triage/component/catwalk/protected_groups_generators.py @@ -8,7 +8,7 @@ from triage.component.catwalk.storage import MatrixStore -class ProtectedGroupsGeneratorNoOp(object): +class ProtectedGroupsGeneratorNoOp: def generate_all_dates(self, *args, **kwargs): logging.warning( "No bias audit configuration is available, so protected groups will not be created" @@ -23,7 +23,7 @@ def as_dataframe(self, *args, **kwargs): return pandas.DataFrame() -class ProtectedGroupsGenerator(object): +class ProtectedGroupsGenerator: def __init__(self, db_engine, from_obj, attribute_columns, entity_id_column, knowledge_date_column, protected_groups_table_name, replace=True): self.db_engine = db_engine self.replace = replace diff --git a/src/triage/component/catwalk/storage.py b/src/triage/component/catwalk/storage.py index 682ef78f7..e8d37ba73 100644 --- a/src/triage/component/catwalk/storage.py +++ b/src/triage/component/catwalk/storage.py @@ -28,7 +28,7 @@ from triage.util.pandas import downcast_matrix -class Store(object): +class Store: """Base class for classes which know how to access a file in a preset medium. Used to hold references to persisted objects with knowledge about how they can be accessed. @@ -167,7 +167,7 @@ def open(self, *args, **kwargs): return open(self.path, *args, **kwargs) -class ProjectStorage(object): +class ProjectStorage: """Store and access files associated with a project. Args: @@ -213,7 +213,7 @@ def model_storage_engine(self, model_directory=None): return ModelStorageEngine(self, model_directory) -class ModelStorageEngine(object): +class ModelStorageEngine: """Store arbitrary models in a given project storage using joblib Args: @@ -249,7 +249,7 @@ def write(self, obj, model_hash): """Persist a model object using joblib. Also performs compression Args: - obj (object) A picklable model object + obj (object) A picklable model object model_hash (string) An identifier, unique within this project, for the model """ if self.should_cache: @@ -294,7 +294,7 @@ def _get_store(self, model_hash): return self.project_storage.get_store(self.directories, model_hash) -class MatrixStorageEngine(object): +class MatrixStorageEngine: """Store matrices in a given project storage Args: @@ -324,7 +324,7 @@ def get_store(self, matrix_uuid): ) -class MatrixStore(object): +class MatrixStore: """Base class for classes that allow access of a matrix and its metadata. Subclasses should be scoped to a storage format (e.g. CSV) @@ -592,7 +592,7 @@ def save(self): yaml.dump(self.metadata, fd, encoding="utf-8") -class TestMatrixType(object): +class TestMatrixType: string_name = "test" evaluation_obj = TestEvaluation prediction_obj = TestPrediction @@ -601,7 +601,7 @@ class TestMatrixType(object): is_test = True -class TrainMatrixType(object): +class TrainMatrixType: string_name = "train" evaluation_obj = TrainEvaluation prediction_obj = TrainPrediction diff --git a/src/triage/component/catwalk/subsetters.py b/src/triage/component/catwalk/subsetters.py index db8d290c5..6e73b21fb 100644 --- a/src/triage/component/catwalk/subsetters.py +++ b/src/triage/component/catwalk/subsetters.py @@ -7,7 +7,7 @@ from triage.component.catwalk.utils import (filename_friendly_hash, get_subset_table_name) from triage.component.results_schema import Subset -class Subsetter(object): +class Subsetter: def __init__( self, db_engine, diff --git a/src/triage/component/collate/collate.py b/src/triage/component/collate/collate.py index 06f916c4b..1ae173c2d 100644 --- a/src/triage/component/collate/collate.py +++ b/src/triage/component/collate/collate.py @@ -51,7 +51,7 @@ def split_distinct(quantity): return "", (q,) -class AggregateExpression(object): +class AggregateExpression: def __init__( self, aggregate1, @@ -437,7 +437,7 @@ def __init__( ) -class Aggregation(object): +class Aggregation: def __init__( self, aggregates, diff --git a/src/triage/component/collate/from_obj.py b/src/triage/component/collate/from_obj.py index 211b4f599..7dfa65ad5 100644 --- a/src/triage/component/collate/from_obj.py +++ b/src/triage/component/collate/from_obj.py @@ -7,7 +7,7 @@ import sqlparse -class FromObj(object): +class FromObj: def __init__(self, from_obj, name, knowledge_date_column): self.from_obj = from_obj self.name = name diff --git a/src/triage/component/collate/imputations.py b/src/triage/component/collate/imputations.py index 35ac067b6..920cffd33 100644 --- a/src/triage/component/collate/imputations.py +++ b/src/triage/component/collate/imputations.py @@ -1,4 +1,4 @@ -class BaseImputation(object): +class BaseImputation: """Base class for various imputation methods """ diff --git a/src/triage/component/postmodeling/contrast/model_evaluator.py b/src/triage/component/postmodeling/contrast/model_evaluator.py index 2f685c1de..df9b6010e 100644 --- a/src/triage/component/postmodeling/contrast/model_evaluator.py +++ b/src/triage/component/postmodeling/contrast/model_evaluator.py @@ -29,7 +29,7 @@ from triage.component.catwalk.storage import ProjectStorage, ModelStorageEngine, MatrixStorageEngine -class ModelEvaluator(object): +class ModelEvaluator: ''' ModelExtractor class calls the model metadata from the database and hold model_id metadata features on each of the class attibutes. diff --git a/src/triage/component/postmodeling/contrast/model_group_evaluator.py b/src/triage/component/postmodeling/contrast/model_group_evaluator.py index e16f10644..22da8b913 100644 --- a/src/triage/component/postmodeling/contrast/model_group_evaluator.py +++ b/src/triage/component/postmodeling/contrast/model_group_evaluator.py @@ -20,7 +20,7 @@ # Get indivual model information/metadata from Audition output -class ModelGroupEvaluator(object): +class ModelGroupEvaluator: ''' ModelGroup class calls the model group metadata from the database and hold metadata features on each of the class attibutes. diff --git a/src/triage/component/postmodeling/contrast/parameters.py b/src/triage/component/postmodeling/contrast/parameters.py index 8ad0686e7..cd7a0afa6 100644 --- a/src/triage/component/postmodeling/contrast/parameters.py +++ b/src/triage/component/postmodeling/contrast/parameters.py @@ -12,7 +12,7 @@ import json import warnings -class PostmodelParameters(object): +class PostmodelParameters: ''' PostmodelParameters reads all parameters from a 'yaml' file and store them in this object to be used in other functions. Different metrics can be diff --git a/src/triage/component/postmodeling/crosstabs.py b/src/triage/component/postmodeling/crosstabs.py index 0aba134ff..40146acc4 100644 --- a/src/triage/component/postmodeling/crosstabs.py +++ b/src/triage/component/postmodeling/crosstabs.py @@ -4,7 +4,7 @@ import yaml -class CrosstabsConfigLoader(object): +class CrosstabsConfigLoader: def __init__(self, config_path=None, config=None): self.output = {} self.models_list_query = None diff --git a/src/triage/component/timechop/timechop.py b/src/triage/component/timechop/timechop.py index a30300631..a5a7f1a26 100644 --- a/src/triage/component/timechop/timechop.py +++ b/src/triage/component/timechop/timechop.py @@ -30,7 +30,7 @@ # } -class Timechop(object): +class Timechop: def __init__( self, feature_start_time, diff --git a/src/triage/experiments/validate.py b/src/triage/experiments/validate.py index d7f07f22a..8ee7a3380 100644 --- a/src/triage/experiments/validate.py +++ b/src/triage/experiments/validate.py @@ -14,7 +14,7 @@ from triage.validation_primitives import string_is_tablesafe -class Validator(object): +class Validator: def __init__(self, db_engine=None, strict=True): self.db_engine = db_engine self.strict = strict