예제 #1
0
 def test_feature_serialization(self):
     processed_cycler_run_path = os.path.join(TEST_FILE_DIR,
                                              PROCESSED_CYCLER_FILE)
     predictor = DegradationPredictor.from_processed_cycler_run_file(
         processed_cycler_run_path,
         prediction_type='multi',
         features_label='full_model')
     #    import nose
     #    nose.tools.set_trace()
     dumpfn(
         predictor,
         os.path.join(
             TEST_FILE_DIR,
             "2017-12-04_4_65C-69per_6C_CH29_features_predict_only.json"))
     predictor_reloaded = loadfn(
         os.path.join(
             TEST_FILE_DIR,
             "2017-12-04_4_65C-69per_6C_CH29_features_predict_only.json"))
     self.assertIsInstance(predictor_reloaded, DegradationPredictor)
     # test nominal capacity is being generated
     self.assertEqual(predictor_reloaded.nominal_capacity,
                      1.0628421000000001)
     os.remove(
         os.path.join(
             TEST_FILE_DIR,
             "2017-12-04_4_65C-69per_6C_CH29_features_predict_only.json"))
예제 #2
0
 def test_feature_old_class(self):
     processed_cycler_run_path = os.path.join(TEST_FILE_DIR, PROCESSED_CYCLER_FILE)
     with ScratchDir('.'):
         os.environ['BEEP_ROOT'] = os.getcwd()
         predictor = DegradationPredictor.from_processed_cycler_run_file(processed_cycler_run_path,
                                                                         features_label='full_model')
         self.assertEqual(predictor.feature_labels[4], "charge_time_cycles_1:5")
예제 #3
0
 def test_feature_generation_full_model(self):
     processed_cycler_run_path = os.path.join(TEST_FILE_DIR,
                                              processed_cycler_file)
     predictor = DegradationPredictor.from_processed_cycler_run_file(
         processed_cycler_run_path, features_label='full_model')
     self.assertEqual(len(predictor.X), 1)  # just test if works for now
     # Ensure no NaN values
     self.assertFalse(np.any(predictor.X.isnull()))
예제 #4
0
 def test_feature_old_class(self):
     processed_cycler_run_path = os.path.join(TEST_FILE_DIR,
                                              self.processed_cycler_file)
     with ScratchDir("."):
         os.environ["BEEP_PROCESSING_DIR"] = os.getcwd()
         predictor = DegradationPredictor.from_processed_cycler_run_file(
             processed_cycler_run_path, features_label="full_model")
         self.assertEqual(predictor.feature_labels[4],
                          "charge_time_cycles_1:5")
예제 #5
0
 def test_feature_serialization_for_training(self):
     processed_cycler_run_path = os.path.join(TEST_FILE_DIR,
                                              processed_cycler_file)
     predictor = DegradationPredictor.from_processed_cycler_run_file(
         processed_cycler_run_path,
         features_label='full_model',
         predict_only=False)
     dumpfn(
         predictor,
         os.path.join(TEST_FILE_DIR,
                      "2017-12-04_4_65C-69per_6C_CH29_features.json"))
     predictor_reloaded = loadfn(
         os.path.join(TEST_FILE_DIR,
                      "2017-12-04_4_65C-69per_6C_CH29_features.json"))
     self.assertIsInstance(predictor_reloaded, DegradationPredictor)
예제 #6
0
def memory_profile(s3_objs=None):
    """
    Function for memory profiling pipelines with s3_objs.

    Args:
        s3_objs ([str]): list of s3_objs in the kitware d3batt
            publication s3 bucket.

    """
    s3_objs = s3_objs or MEMORY_PROFILE_S3_OBJS

    # Cache s3 objects
    cache_s3_objs(s3_objs, filter_existing_files=True)

    with ScratchDir("."):
        # Copy all pre-defined s3 objects
        for obj_name in s3_objs:
            shutil.copy(os.path.join(S3_CACHE, obj_name), ".")

        # Snip data path prefix
        data_paths = [
            os.path.basename(obj) for obj in s3_objs if "Metadata" not in obj
        ]

        # Validation
        # validator = ValidatorBeep()
        # validator.validate_from_paths(data_paths)

        # Data structuring
        raw_cycler_runs = [
            RawCyclerRun.from_file(data_path) for data_path in data_paths
        ]
        processed_cycler_runs = [
            ProcessedCyclerRun.from_raw_cycler_run(raw_cycler_run)
            for raw_cycler_run in raw_cycler_runs
        ]

        # Featurization
        predictors = [
            DegradationPredictor.init_full_model(processed_cycler_run)
            for processed_cycler_run in processed_cycler_runs
        ]

        # Prediction
        [
            DegradationModel.init_full_model().predict(predictor)
            for predictor in predictors
        ]
예제 #7
0
 def test_diagnostic_feature_generation(self):
     os.environ['BEEP_ROOT'] = TEST_FILE_DIR
     maccor_file_w_parameters = os.path.join(
         TEST_FILE_DIR, "PredictionDiagnostics_000136_00002D.037")
     raw_run = RawCyclerRun.from_file(maccor_file_w_parameters)
     v_range, resolution, nominal_capacity, full_fast_charge, diagnostic_available = \
         raw_run.determine_structuring_parameters()
     pcycler_run = ProcessedCyclerRun.from_raw_cycler_run(
         raw_run, diagnostic_available=diagnostic_available)
     predictor = DegradationPredictor.init_full_model(
         pcycler_run,
         predict_only=False,
         mid_pred_cycle=11,
         final_pred_cycle=12,
         diagnostic_features=True)
     diagnostic_feature_label = predictor.feature_labels[-1]
     self.assertEqual(diagnostic_feature_label,
                      "median_diagnostic_cycles_discharge_capacity")
     np.testing.assert_almost_equal(
         predictor.X[diagnostic_feature_label][0], 4.2327690032, decimal=8)
예제 #8
0
 def test_feature_label_full_model(self):
     processed_cycler_run_path = os.path.join(TEST_FILE_DIR,
                                              processed_cycler_file)
     predictor = DegradationPredictor.from_processed_cycler_run_file(
         processed_cycler_run_path, features_label='full_model')
     self.assertEqual(predictor.feature_labels[4], "charge_time_cycles_1:5")