Former-commit-id:master846b08ee7c[formerly898f9492d1] [formerly3ba67f75a0[formerly58b375e8e7]] [formerlyed311ab694[formerly4f094bb67d] [formerlyf26d423c16[formerlyf794ff34ef]]] [formerlyf05635c1f4[formerly79b26421d1] [formerly58d01d0765[formerlyac8fad3853]] [formerlyb0b655300f[formerly9726f96eb4] [formerlyc28b652837[formerlyb66948d1d0]]]] [formerly464b9b56a8[formerly6d27652e84] [formerlyf8cdb514b1[formerly36da7b0133]] [formerly58f0a2ad3b[formerlyae260a8a2c] [formerly0b4306ce91[formerly4736c33b82]]] [formerly15024cfb98[formerlyaffb9d5be6] [formerly49b5cbb379[formerlyd386e84f3f]] [formerly0df3fd4bc8[formerly1452be20a9] [formerly6cea47368c[formerly4beb72e53d]]]]] [formerly2cb122a0e2[formerly369a07af54] [formerly117719f457[formerlyf418d8f99e]] [formerlya2f8ef45a1[formerly0f9187e9eb] [formerly1e667b994f[formerly684958c828]]] [formerly353202c937[formerly2e4d260432] [formerly0f060e89f2[formerly12d6c71af7]] [formerlyf90287aa50[formerly5f14e91aaa] [formerly15e8680f49[formerly97f0a20a9f]]]] [formerly4188a6742e[formerly4f52141057] [formerly42f46569fa[formerly56b44ec1f0]] [formerly045abdc1fc[formerlyd00f538f5c] [formerly0ca3d4c0ba[formerlyb326214bbb]]] [formerly4344f68bac[formerlyf0ae7e9d07] [formerly813a1a2864[formerly5e348e98c8]] [formerlyd1429e68cc[formerlybea65a0891] [formerlyda1ab85194[formerlyd4d39f564f]]]]]] Former-commit-id:0e4c0fc5f7[formerlyfb8130714b] [formerly3d492794ed[formerly17a0b69347]] [formerlyb0c8ebc55b[formerly0d73519131] [formerlyb171b2dcd9[formerlye6de695a37]]] [formerlya3f7312030[formerly2e8279331d] [formerly9765d5a57d[formerly11a90a6519]] [formerlyf561ea4acf[formerlye972418bab] [formerlyc057b0a413[formerly714782adde]]]] [formerlydb10531717[formerly81a1b9ee57] [formerly9279abaa59[formerlyee80e83eb8]] [formerly38a18cc254[formerlye9ca3caf08] [formerly340477e530[formerlyc9b004a2c3]]] [formerly734509d15d[formerlyad1cd45b34] [formerly30f7c10b83[formerly710c9cc680]] [formerly4a0f1409e6[formerly7d6d940ad5] [formerlyda1ab85194]]]] Former-commit-id:61bd2ced30[formerlyccbc4bb634] [formerly0b4b809341[formerly502825f55d]] [formerlyb6fd349efe[formerly95572c4684] [formerlyd137c99d11[formerlyf5d2a4e046]]] [formerly72e04400d6[formerlydf838a0f39] [formerlyf61a4b36a4[formerlybb719729f3]] [formerlyd7983d5901[formerly485071deb0] [formerlyfe336da384[formerly4a1117cd30]]]] Former-commit-id:4c31aa2002[formerly368204e633] [formerlycb20d97745[formerly1e2bd5a92e]] [formerly6bae8da79f[formerly5e825dad67] [formerly9aadaada35[formerly4087666752]]] Former-commit-id:45827781fd[formerlydf48b013a0] [formerly0398938d7a[formerlycec8951ed4]] Former-commit-id:a43bf0a20a[formerly2e8d602276] Former-commit-id:b8cd12701e
| @@ -0,0 +1 @@ | |||
| Subproject commit af54e6970476a081bf0cd65990c9f56a1200d8a2 | |||
| @@ -0,0 +1 @@ | |||
| Subproject commit 046b20d2f6d4543dcbe18f0a1d4bcbb1f61cf518 | |||
| @@ -0,0 +1 @@ | |||
| Subproject commit 70aeefed6b7307941581357c4b7858bb3f88e1da | |||
| @@ -170,9 +170,3 @@ class ContinuityValidation(transformer.TransformerPrimitiveBase[Inputs, Outputs, | |||
| inputs['d3mIndex'] = list(range(inputs.shape[0])) | |||
| return inputs | |||
| def _write(self, inputs:Inputs): | |||
| """ | |||
| write inputs to current directory, only for test | |||
| """ | |||
| inputs.to_csv(str(time.time())+'.csv') | |||
| @@ -91,8 +91,3 @@ class DuplicationValidation(transformer.TransformerPrimitiveBase[Inputs, Outputs | |||
| return inputs | |||
| def _write(self, inputs:Inputs): | |||
| """ | |||
| write inputs to current directory, only for test | |||
| """ | |||
| inputs.to_csv(str(time.time())+'.csv') | |||
| @@ -169,7 +169,7 @@ class LSTMOutlierDetector(CollectiveBaseDetector): | |||
| # print(danger_coefficient, averaged_relative_error) | |||
| else: | |||
| else: # pragma: no cover | |||
| danger_coefficient = np.zeros(relative_error.shape) | |||
| averaged_relative_error = np.zeros(relative_error.shape) | |||
| @@ -210,7 +210,7 @@ class LSTMOutlierDetector(CollectiveBaseDetector): | |||
| if __name__ == "__main__": | |||
| if __name__ == "__main__": # pragma: no cover | |||
| X_train = np.asarray( | |||
| [3., 4., 8., 16, 18, 13., 22., 36., 59., 128, 62, 67, 78, 100]).reshape(-1, 1) | |||
| @@ -186,14 +186,14 @@ class BKFilter(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams | |||
| if len(self._training_indices) > 0: | |||
| # self._clf.fit(self._training_inputs) | |||
| self._fitted = True | |||
| else: | |||
| else: # pragma: no cover | |||
| if self.hyperparams['error_on_no_input']: | |||
| raise RuntimeError("No input columns were selected") | |||
| self.logger.warn("No input columns were selected") | |||
| if not self._fitted: | |||
| if not self._fitted: # pragma: no cover | |||
| raise PrimitiveNotFittedError("Primitive not fitted.") | |||
| sk_inputs = inputs | |||
| if self.hyperparams['use_semantic_types']: | |||
| @@ -209,7 +209,7 @@ class BKFilter(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams | |||
| outputs.columns = self._input_column_names | |||
| output_columns = [outputs] | |||
| else: | |||
| else: # pragma: no cover | |||
| if self.hyperparams['error_on_no_input']: | |||
| raise RuntimeError("No input columns were selected") | |||
| self.logger.warn("No input columns were selected") | |||
| @@ -217,14 +217,11 @@ class BKFilter(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams | |||
| add_index_columns=self.hyperparams['add_index_columns'], | |||
| inputs=inputs, column_indices=self._training_indices, | |||
| columns_list=output_columns) | |||
| # self._write(outputs) | |||
| # self.logger.warning('produce was called3') | |||
| return CallResult(outputs) | |||
| @classmethod | |||
| def _get_columns_to_fit(cls, inputs: Inputs, hyperparams: Hyperparams): | |||
| def _get_columns_to_fit(cls, inputs: Inputs, hyperparams: Hyperparams): # pragma: no cover | |||
| """ | |||
| Select columns to fit. | |||
| Args: | |||
| @@ -261,7 +258,7 @@ class BKFilter(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams | |||
| # return columns_to_produce | |||
| @classmethod | |||
| def _can_produce_column(cls, inputs_metadata: metadata_base.DataMetadata, column_index: int, hyperparams: Hyperparams) -> bool: | |||
| def _can_produce_column(cls, inputs_metadata: metadata_base.DataMetadata, column_index: int, hyperparams: Hyperparams) -> bool: # pragma: no cover | |||
| """ | |||
| Output whether a column can be processed. | |||
| Args: | |||
| @@ -354,8 +351,6 @@ class BKFilter(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams | |||
| return target_columns_metadata | |||
| def _write(self, inputs:Inputs): | |||
| inputs.to_csv(str(time.time())+'.csv') | |||
| def _bkfilter(self, X, low, high, K): | |||
| """ | |||
| @@ -163,14 +163,14 @@ class HPFilter(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams | |||
| if len(self._training_indices) > 0: | |||
| # self._clf.fit(self._training_inputs) | |||
| self._fitted = True | |||
| else: | |||
| else: # pragma: no cover | |||
| if self.hyperparams['error_on_no_input']: | |||
| raise RuntimeError("No input columns were selected") | |||
| self.logger.warn("No input columns were selected") | |||
| if not self._fitted: | |||
| if not self._fitted: # pragma: no cover | |||
| raise PrimitiveNotFittedError("Primitive not fitted.") | |||
| sk_inputs = inputs | |||
| if self.hyperparams['use_semantic_types']: | |||
| @@ -186,7 +186,7 @@ class HPFilter(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams | |||
| outputs.columns = self._input_column_names | |||
| output_columns = [outputs] | |||
| else: | |||
| else: # pragma: no cover | |||
| if self.hyperparams['error_on_no_input']: | |||
| raise RuntimeError("No input columns were selected") | |||
| self.logger.warn("No input columns were selected") | |||
| @@ -194,14 +194,11 @@ class HPFilter(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams | |||
| add_index_columns=self.hyperparams['add_index_columns'], | |||
| inputs=inputs, column_indices=self._training_indices, | |||
| columns_list=output_columns) | |||
| # self._write(outputs) | |||
| # self.logger.warning('produce was called3') | |||
| return CallResult(outputs) | |||
| @classmethod | |||
| def _get_columns_to_fit(cls, inputs: Inputs, hyperparams: Hyperparams): | |||
| def _get_columns_to_fit(cls, inputs: Inputs, hyperparams: Hyperparams): # pragma: no cover | |||
| """ | |||
| Select columns to fit. | |||
| Args: | |||
| @@ -238,7 +235,7 @@ class HPFilter(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams | |||
| # return columns_to_produce | |||
| @classmethod | |||
| def _can_produce_column(cls, inputs_metadata: metadata_base.DataMetadata, column_index: int, hyperparams: Hyperparams) -> bool: | |||
| def _can_produce_column(cls, inputs_metadata: metadata_base.DataMetadata, column_index: int, hyperparams: Hyperparams) -> bool: # pragma: no cover | |||
| """ | |||
| Output whether a column can be processed. | |||
| Args: | |||
| @@ -331,9 +328,6 @@ class HPFilter(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams | |||
| return target_columns_metadata | |||
| def _write(self, inputs:Inputs): | |||
| inputs.to_csv(str(time.time())+'.csv') | |||
| def _hpfilter(self, X, lamb): | |||
| """ | |||
| Perform HPFilter | |||
| @@ -224,7 +224,7 @@ class SKTruncatedSVD(UnsupervisedLearnerPrimitiveBase[Inputs, Outputs, Params, H | |||
| Returns: | |||
| None | |||
| """ | |||
| if self._fitted: | |||
| if self._fitted: # pragma: no cover | |||
| return CallResult(None) | |||
| # Get cols to fit. | |||
| @@ -239,7 +239,7 @@ class SKTruncatedSVD(UnsupervisedLearnerPrimitiveBase[Inputs, Outputs, Params, H | |||
| if len(self._training_indices) > 0: | |||
| self._clf.fit(self._training_inputs) | |||
| self._fitted = True | |||
| else: | |||
| else: # pragma: no cover | |||
| if self.hyperparams['error_on_no_input']: | |||
| raise RuntimeError("No input columns were selected") | |||
| self.logger.warn("No input columns were selected") | |||
| @@ -257,7 +257,7 @@ class SKTruncatedSVD(UnsupervisedLearnerPrimitiveBase[Inputs, Outputs, Params, H | |||
| # self.logger.warning(str(self.metadata.query()['name'])) | |||
| if not self._fitted: | |||
| if not self._fitted: # pragma: no cover | |||
| raise PrimitiveNotFittedError("Primitive not fitted.") | |||
| sk_inputs = inputs | |||
| if self.hyperparams['use_semantic_types']: | |||
| @@ -272,7 +272,7 @@ class SKTruncatedSVD(UnsupervisedLearnerPrimitiveBase[Inputs, Outputs, Params, H | |||
| if len(outputs.columns) == len(self._input_column_names): | |||
| outputs.columns = self._input_column_names | |||
| output_columns = [outputs] | |||
| else: | |||
| else: # pragma: no cover | |||
| if self.hyperparams['error_on_no_input']: | |||
| raise RuntimeError("No input columns were selected") | |||
| self.logger.warn("No input columns were selected") | |||
| @@ -286,7 +286,7 @@ class SKTruncatedSVD(UnsupervisedLearnerPrimitiveBase[Inputs, Outputs, Params, H | |||
| return CallResult(outputs) | |||
| def get_params(self) -> Params: | |||
| def get_params(self) -> Params: # pragma: no cover | |||
| """ | |||
| Return parameters. | |||
| Args: | |||
| @@ -320,7 +320,7 @@ class SKTruncatedSVD(UnsupervisedLearnerPrimitiveBase[Inputs, Outputs, Params, H | |||
| target_columns_metadata_=self._target_columns_metadata | |||
| ) | |||
| def set_params(self, *, params: Params) -> None: | |||
| def set_params(self, *, params: Params) -> None: # pragma: no cover | |||
| """ | |||
| Set parameters for SKTruncatedSVD. | |||
| Args: | |||
| @@ -351,7 +351,7 @@ class SKTruncatedSVD(UnsupervisedLearnerPrimitiveBase[Inputs, Outputs, Params, H | |||
| @classmethod | |||
| def _get_columns_to_fit(cls, inputs: Inputs, hyperparams: Hyperparams): | |||
| def _get_columns_to_fit(cls, inputs: Inputs, hyperparams: Hyperparams): # pragma: no cover | |||
| """ | |||
| Select columns to fit. | |||
| Args: | |||
| @@ -377,7 +377,7 @@ class SKTruncatedSVD(UnsupervisedLearnerPrimitiveBase[Inputs, Outputs, Params, H | |||
| # return columns_to_produce | |||
| @classmethod | |||
| def _can_produce_column(cls, inputs_metadata: metadata_base.DataMetadata, column_index: int, hyperparams: Hyperparams) -> bool: | |||
| def _can_produce_column(cls, inputs_metadata: metadata_base.DataMetadata, column_index: int, hyperparams: Hyperparams) -> bool: # pragma: no cover | |||
| """ | |||
| Output whether a column can be processed. | |||
| Args: | |||
| @@ -408,35 +408,35 @@ class SKTruncatedSVD(UnsupervisedLearnerPrimitiveBase[Inputs, Outputs, Params, H | |||
| return False | |||
| @classmethod | |||
| def _get_target_columns_metadata(cls, outputs_metadata: metadata_base.DataMetadata, hyperparams) -> List[OrderedDict]: | |||
| """ | |||
| Output metadata of selected columns. | |||
| Args: | |||
| outputs_metadata: metadata_base.DataMetadata | |||
| hyperparams: d3m.metadata.hyperparams.Hyperparams | |||
| Returns: | |||
| d3m.metadata.base.DataMetadata | |||
| """ | |||
| outputs_length = outputs_metadata.query((metadata_base.ALL_ELEMENTS,))['dimension']['length'] | |||
| target_columns_metadata: List[OrderedDict] = [] | |||
| for column_index in range(outputs_length): | |||
| column_metadata = OrderedDict(outputs_metadata.query_column(column_index)) | |||
| # Update semantic types and prepare it for predicted targets. | |||
| semantic_types = set(column_metadata.get('semantic_types', [])) | |||
| semantic_types_to_remove = set([]) | |||
| add_semantic_types = [] | |||
| add_semantic_types.add(hyperparams["return_semantic_type"]) | |||
| semantic_types = semantic_types - semantic_types_to_remove | |||
| semantic_types = semantic_types.union(add_semantic_types) | |||
| column_metadata['semantic_types'] = list(semantic_types) | |||
| target_columns_metadata.append(column_metadata) | |||
| return target_columns_metadata | |||
| # @classmethod | |||
| # def _get_target_columns_metadata(cls, outputs_metadata: metadata_base.DataMetadata, hyperparams) -> List[OrderedDict]: | |||
| # """ | |||
| # Output metadata of selected columns. | |||
| # Args: | |||
| # outputs_metadata: metadata_base.DataMetadata | |||
| # hyperparams: d3m.metadata.hyperparams.Hyperparams | |||
| # Returns: | |||
| # d3m.metadata.base.DataMetadata | |||
| # """ | |||
| # outputs_length = outputs_metadata.query((metadata_base.ALL_ELEMENTS,))['dimension']['length'] | |||
| # target_columns_metadata: List[OrderedDict] = [] | |||
| # for column_index in range(outputs_length): | |||
| # column_metadata = OrderedDict(outputs_metadata.query_column(column_index)) | |||
| # # Update semantic types and prepare it for predicted targets. | |||
| # semantic_types = set(column_metadata.get('semantic_types', [])) | |||
| # semantic_types_to_remove = set([]) | |||
| # add_semantic_types = [] | |||
| # add_semantic_types.add(hyperparams["return_semantic_type"]) | |||
| # semantic_types = semantic_types - semantic_types_to_remove | |||
| # semantic_types = semantic_types.union(add_semantic_types) | |||
| # column_metadata['semantic_types'] = list(semantic_types) | |||
| # target_columns_metadata.append(column_metadata) | |||
| # return target_columns_metadata | |||
| @classmethod | |||
| def _update_predictions_metadata(cls, inputs_metadata: metadata_base.DataMetadata, outputs: Optional[Outputs], | |||
| @@ -500,11 +500,3 @@ class SKTruncatedSVD(UnsupervisedLearnerPrimitiveBase[Inputs, Outputs, Params, H | |||
| return target_columns_metadata | |||
| def _write(self, inputs:Inputs): | |||
| """ | |||
| write inputs to current directory, only for test | |||
| """ | |||
| inputs.to_csv(str(time.time())+'.csv') | |||
| # SKTruncatedSVD.__doc__ = TruncatedSVD.__doc__ | |||
| @@ -276,14 +276,14 @@ class TRMF(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams]): | |||
| if len(self._training_indices) > 0: | |||
| self._clf.fit(self._training_inputs) | |||
| self._fitted = True | |||
| else: | |||
| else: # pragma: no cover | |||
| if self.hyperparams['error_on_no_input']: | |||
| raise RuntimeError("No input columns were selected") | |||
| self.logger.warn("No input columns were selected") | |||
| if not self._fitted: | |||
| if not self._fitted: # pragma: no cover | |||
| raise PrimitiveNotFittedError("Primitive not fitted.") | |||
| sk_inputs = inputs | |||
| @@ -301,7 +301,7 @@ class TRMF(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams]): | |||
| if len(outputs.columns) == len(self._input_column_names): | |||
| outputs.columns = self._input_column_names | |||
| output_columns = [outputs] | |||
| else: | |||
| else: # pragma: no cover | |||
| if self.hyperparams['error_on_no_input']: | |||
| raise RuntimeError("No input columns were selected") | |||
| self.logger.warn("No input columns were selected") | |||
| @@ -316,7 +316,7 @@ class TRMF(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams]): | |||
| @classmethod | |||
| def _get_columns_to_fit(cls, inputs: Inputs, hyperparams: Hyperparams): | |||
| def _get_columns_to_fit(cls, inputs: Inputs, hyperparams: Hyperparams): # pragma: no cover | |||
| """ | |||
| Select columns to fit. | |||
| Args: | |||
| @@ -342,7 +342,7 @@ class TRMF(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams]): | |||
| # return columns_to_produce | |||
| @classmethod | |||
| def _can_produce_column(cls, inputs_metadata: metadata_base.DataMetadata, column_index: int, hyperparams: Hyperparams) -> bool: | |||
| def _can_produce_column(cls, inputs_metadata: metadata_base.DataMetadata, column_index: int, hyperparams: Hyperparams) -> bool: # pragma: no cover | |||
| """ | |||
| Output whether a column can be processed. | |||
| Args: | |||
| @@ -373,35 +373,35 @@ class TRMF(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams]): | |||
| return False | |||
| @classmethod | |||
| def _get_target_columns_metadata(cls, outputs_metadata: metadata_base.DataMetadata, hyperparams) -> List[OrderedDict]: | |||
| """ | |||
| Output metadata of selected columns. | |||
| Args: | |||
| outputs_metadata: metadata_base.DataMetadata | |||
| hyperparams: d3m.metadata.hyperparams.Hyperparams | |||
| Returns: | |||
| d3m.metadata.base.DataMetadata | |||
| """ | |||
| outputs_length = outputs_metadata.query((metadata_base.ALL_ELEMENTS,))['dimension']['length'] | |||
| target_columns_metadata: List[OrderedDict] = [] | |||
| for column_index in range(outputs_length): | |||
| column_metadata = OrderedDict(outputs_metadata.query_column(column_index)) | |||
| # Update semantic types and prepare it for predicted targets. | |||
| semantic_types = set(column_metadata.get('semantic_types', [])) | |||
| semantic_types_to_remove = set([]) | |||
| add_semantic_types = [] | |||
| add_semantic_types.add(hyperparams["return_semantic_type"]) | |||
| semantic_types = semantic_types - semantic_types_to_remove | |||
| semantic_types = semantic_types.union(add_semantic_types) | |||
| column_metadata['semantic_types'] = list(semantic_types) | |||
| target_columns_metadata.append(column_metadata) | |||
| return target_columns_metadata | |||
| # @classmethod | |||
| # def _get_target_columns_metadata(cls, outputs_metadata: metadata_base.DataMetadata, hyperparams) -> List[OrderedDict]: | |||
| # """ | |||
| # Output metadata of selected columns. | |||
| # Args: | |||
| # outputs_metadata: metadata_base.DataMetadata | |||
| # hyperparams: d3m.metadata.hyperparams.Hyperparams | |||
| # Returns: | |||
| # d3m.metadata.base.DataMetadata | |||
| # """ | |||
| # outputs_length = outputs_metadata.query((metadata_base.ALL_ELEMENTS,))['dimension']['length'] | |||
| # target_columns_metadata: List[OrderedDict] = [] | |||
| # for column_index in range(outputs_length): | |||
| # column_metadata = OrderedDict(outputs_metadata.query_column(column_index)) | |||
| # # Update semantic types and prepare it for predicted targets. | |||
| # semantic_types = set(column_metadata.get('semantic_types', [])) | |||
| # semantic_types_to_remove = set([]) | |||
| # add_semantic_types = [] | |||
| # add_semantic_types.add(hyperparams["return_semantic_type"]) | |||
| # semantic_types = semantic_types - semantic_types_to_remove | |||
| # semantic_types = semantic_types.union(add_semantic_types) | |||
| # column_metadata['semantic_types'] = list(semantic_types) | |||
| # target_columns_metadata.append(column_metadata) | |||
| # return target_columns_metadata | |||
| @classmethod | |||
| def _update_predictions_metadata(cls, inputs_metadata: metadata_base.DataMetadata, outputs: Optional[Outputs], | |||
| @@ -465,12 +465,6 @@ class TRMF(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperparams]): | |||
| return target_columns_metadata | |||
| def _write(self, inputs:Inputs): | |||
| """ | |||
| write inputs to current directory, only for test | |||
| """ | |||
| inputs.to_csv(str(time.time())+'.csv') | |||
| """ | |||
| Temporal Regularized Matrix Factorization | |||
| @@ -564,7 +558,7 @@ class trmf: | |||
| return np.dot(self.F, X_preds) | |||
| def _predict_X(self, h): | |||
| def _predict_X(self, h): # pragma: no cover | |||
| """Predict X h timepoints ahead. | |||
| Evaluates matrix X with the help of matrix W. | |||
| @@ -59,7 +59,7 @@ class ContinuityValidationTest(unittest.TestCase): | |||
| hyperparams_class = ContinuityValidation.ContinuityValidation.metadata.get_hyperparams() | |||
| primitive = ContinuityValidation.ContinuityValidation(hyperparams=hyperparams_class.defaults()) | |||
| new_main = primitive.produce(inputs=main).value | |||
| # print(new_main) | |||
| expected_output = container.DataFrame({'d3mIndex': [0, 1, 2, 3], | |||
| 'timestamp': [1., 2., 3., 4.], | |||
| @@ -124,6 +124,67 @@ class ContinuityValidationTest(unittest.TestCase): | |||
| self._test_continuity(new_main) | |||
| hyperparams = hyperparams_class.defaults() | |||
| hyperparams = hyperparams.replace({'continuity_option': 'ablation'}) | |||
| primitive2 = ContinuityValidation.ContinuityValidation(hyperparams=hyperparams) | |||
| new_main2 = primitive2.produce(inputs=main).value | |||
| print(new_main2) | |||
| self.assertEqual(utils.to_json_structure(new_main2.metadata.to_internal_simple_structure()), [{ | |||
| 'selector': [], | |||
| 'metadata': { | |||
| # 'top_level': 'main', | |||
| 'schema': metadata_base.CONTAINER_SCHEMA_VERSION, | |||
| 'structural_type': 'd3m.container.pandas.DataFrame', | |||
| 'semantic_types': ['https://metadata.datadrivendiscovery.org/types/Table'], | |||
| 'dimension': { | |||
| 'name': 'rows', | |||
| 'semantic_types': ['https://metadata.datadrivendiscovery.org/types/TabularRow'], | |||
| 'length': 2, | |||
| }, | |||
| }, | |||
| }, { | |||
| 'selector': ['__ALL_ELEMENTS__'], | |||
| 'metadata': { | |||
| 'dimension': { | |||
| 'name': 'columns', | |||
| 'semantic_types': ['https://metadata.datadrivendiscovery.org/types/TabularColumn'], | |||
| 'length': 5, | |||
| }, | |||
| }, | |||
| }, { | |||
| 'selector': ['__ALL_ELEMENTS__', 0], | |||
| 'metadata': { | |||
| 'name': 'd3mIndex', | |||
| 'structural_type': 'numpy.int64', | |||
| }, | |||
| }, { | |||
| 'selector': ['__ALL_ELEMENTS__', 1], | |||
| 'metadata': { | |||
| 'name': 'timestamp', | |||
| 'structural_type': 'numpy.float64', | |||
| }, | |||
| }, { | |||
| 'selector': ['__ALL_ELEMENTS__', 2], | |||
| 'metadata': { | |||
| 'name': 'a', | |||
| 'structural_type': 'numpy.float64', | |||
| }, | |||
| }, { | |||
| 'selector': ['__ALL_ELEMENTS__', 3], | |||
| 'metadata': { | |||
| 'name': 'b', | |||
| 'structural_type': 'numpy.float64', | |||
| }, | |||
| }, { | |||
| 'selector': ['__ALL_ELEMENTS__', 4], | |||
| 'metadata': { | |||
| 'name': 'ground_truth', | |||
| 'structural_type': 'numpy.int64', | |||
| }, | |||
| }]) | |||
| def _test_continuity(self, data_value): | |||
| tmp_col = data_value['timestamp'] | |||
| @@ -102,6 +102,54 @@ class DuplicationValidationTest(unittest.TestCase): | |||
| self._test_drop_duplication(new_main) | |||
| hyperparams = hyperparams_class.defaults() | |||
| hyperparams = hyperparams.replace({'keep_option': 'average'}) | |||
| primitive2 = DuplicationValidation.DuplicationValidation(hyperparams=hyperparams) | |||
| new_main2 = primitive2.produce(inputs=main).value | |||
| print(new_main2) | |||
| self.assertEqual(utils.to_json_structure(new_main.metadata.to_internal_simple_structure()), [{ | |||
| 'selector': [], | |||
| 'metadata': { | |||
| # 'top_level': 'main', | |||
| 'schema': metadata_base.CONTAINER_SCHEMA_VERSION, | |||
| 'structural_type': 'd3m.container.pandas.DataFrame', | |||
| 'semantic_types': ['https://metadata.datadrivendiscovery.org/types/Table'], | |||
| 'dimension': { | |||
| 'name': 'rows', | |||
| 'semantic_types': ['https://metadata.datadrivendiscovery.org/types/TabularRow'], | |||
| 'length': 2, | |||
| }, | |||
| }, | |||
| }, { | |||
| 'selector': ['__ALL_ELEMENTS__'], | |||
| 'metadata': { | |||
| 'dimension': { | |||
| 'name': 'columns', | |||
| 'semantic_types': ['https://metadata.datadrivendiscovery.org/types/TabularColumn'], | |||
| 'length': 3, | |||
| }, | |||
| }, | |||
| }, { | |||
| 'selector': ['__ALL_ELEMENTS__', 0], | |||
| 'metadata': { | |||
| 'name': 'timestamp', | |||
| 'structural_type': 'numpy.float64', | |||
| }, | |||
| }, { | |||
| 'selector': ['__ALL_ELEMENTS__', 1], | |||
| 'metadata': { | |||
| 'name': 'a', | |||
| 'structural_type': 'numpy.float64', | |||
| }, | |||
| }, { | |||
| 'selector': ['__ALL_ELEMENTS__', 2], | |||
| 'metadata': { | |||
| 'name': 'b', | |||
| 'structural_type': 'numpy.float64', | |||
| }, | |||
| }]) | |||
| def _test_drop_duplication(self, data_value): | |||
| self.assertEqual(True in list(data_value.duplicated('timestamp')), False) | |||