def test_model(self): utils.validate_fit_event_struct(self.fit_event, self) transformer = self.fit_event.model self.assertEqual(self.fit_event.featureColumns, ['A', 'B', 'C', 'D']) expected_transformer = modeldb_types.Transformer( -1, 'LinearRegression', 'linear reg') utils.is_equal_transformer(transformer, expected_transformer, self)
def test_events(self): # There should be 3 FitEvents and 3 MetricEvents self.assertEqual(len(self.events), 6) # Validate fit and metric event structs for i in range(0, 5, 2): utils.validate_fit_event_struct(self.events[i], self) utils.validate_metric_event_struct(self.events[i + 1], self)
def test_overall_pipeline_fit_event(self): fit_event = self.pipeline_event.pipelineFit utils.validate_fit_event_struct(fit_event, self) transformer = fit_event.model expected_transformer = modeldb_types.Transformer( -1, 'Pipeline', 'pipeline with pca + logistic') utils.is_equal_transformer(transformer, expected_transformer, self) df = fit_event.df expected_df = modeldb_types.DataFrame( -1, [ modeldb_types.DataFrameColumn('A', 'int64'), modeldb_types.DataFrameColumn('B', 'int64'), ], 100, 'digits-dataset') utils.is_equal_dataframe(df, expected_df, self) spec = fit_event.spec expected_spec = modeldb_types.TransformerSpec( -1, 'Pipeline', [ modeldb_types.HyperParameter( 'logistic__n_jobs', '1', 'int', FMIN, FMAX), modeldb_types.HyperParameter( 'pca__copy', 'True', 'bool', FMIN, FMAX), modeldb_types.HyperParameter( 'pca__n_components', 'None', 'NoneType', FMIN, FMAX), modeldb_types.HyperParameter( 'logistic__fit_intercept', 'True', 'bool', FMIN, FMAX), modeldb_types.HyperParameter( 'pca__whiten', 'False', 'bool', FMIN, FMAX), modeldb_types.HyperParameter( 'steps', "[('pca', PCA(copy=True, n_components=None, whiten=False)), ('logistic', LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False))]", 'list', FMIN, FMAX), modeldb_types.HyperParameter( 'logistic', 'LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)', 'LinearRegression', FMIN, FMAX), modeldb_types.HyperParameter( 'pca', 'PCA(copy=True, n_components=None, whiten=False)', 'PCA', FMIN, FMAX), modeldb_types.HyperParameter( 'logistic__normalize', 'False', 'bool', FMIN, FMAX), modeldb_types.HyperParameter( 'logistic__copy_X', 'True', 'bool', FMIN, FMAX) ], 'pipeline with pca + logistic') utils.is_equal_transformer_spec(spec, expected_spec, self) self.assertItemsEqual(fit_event.featureColumns, ['A', 'B'])