Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
6 changes: 5 additions & 1 deletion src/python/nimbusml/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2543,7 +2543,7 @@ def summary(self, verbose=0, **params):
if len(self.steps) > 0 and not isinstance(
self.last_node, BasePredictor):
raise ValueError(
"Summary is availabe only for predictor types, instead "
"Summary is available only for predictor types, instead "
"got " +
self.last_node.type)

Expand Down Expand Up @@ -2581,6 +2581,10 @@ def summary(self, verbose=0, **params):
self._run_time = time.time() - start_time
raise e

# .summary() not supported if size of summary_data
# is less or equal to 1 (if only PredictedName in summary_data)
if summary_data.size == 1 and summary_data.columns.values == ["PredictorName"]:
raise TypeError("One or more predictors in this pipeline do not support the .summary() function.")
self.model_summary = summary_data

# stop the clock
Expand Down
30 changes: 23 additions & 7 deletions src/python/nimbusml/tests/model_summary/test_model_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,25 @@
#SymSgdBinaryClassifier(),
OrdinaryLeastSquaresRegressor(),
PoissonRegressionRegressor(),
OneVsRestClassifier(FastLinearBinaryClassifier()),
GamRegressor(),
GamBinaryClassifier(),
PcaAnomalyDetector(),
FactorizationMachineBinaryClassifier(),
KMeansPlusPlus(n_clusters=2),
NaiveBayesClassifier(),
FastForestBinaryClassifier(number_of_trees=2),
FastForestRegressor(number_of_trees=2),
FastTreesBinaryClassifier(number_of_trees=2),
FastTreesRegressor(number_of_trees=2),
FastTreesTweedieRegressor(number_of_trees=2),
LightGbmRegressor(number_of_iterations=2),
LightGbmClassifier(),
LightGbmBinaryClassifier(number_of_iterations=2)
]

learners_not_supported = [
#PcaTransformer(), # REVIEW: crashes
FactorizationMachineBinaryClassifier(),
OneVsRestClassifier(FastLinearBinaryClassifier()),
FactorizationMachineBinaryClassifier(),
KMeansPlusPlus(n_clusters=2),
NaiveBayesClassifier(),
LightGbmClassifier()
]


Expand All @@ -98,7 +98,6 @@ def test_model_summary(self):
pipeline.fit(train_stream, label_column)
pipeline.summary()

@unittest.skip("No unsupported learners")
def test_model_summary_not_supported(self):
for learner in learners_not_supported:
pipeline = Pipeline(
Expand All @@ -107,6 +106,23 @@ def test_model_summary_not_supported(self):
pipeline.fit(train_stream, label_column)
assert_raises(TypeError, pipeline.summary)

def test_model_summary_not_supported_specific(self):
path = get_dataset('infert').as_filepath()
data = FileDataStream.read_csv(path, sep=',',
names={0: 'row_num', 5: 'case'})
pipeline = Pipeline([
OneHotVectorizer(columns={'edu': 'education'}),
FactorizationMachineBinaryClassifier(feature=['induced', 'edu', 'parity'],
label='case')
])
pipeline.fit(data)
try:
pipeline.summary()
except TypeError as e:
self.assertEqual(e.args[0], "One or more predictors in this pipeline do not support the .summary() function.")
else:
assert False

def test_summary_called_back_to_back_on_predictor(self):
"""
When a predictor is fit without using a Pipeline,
Expand Down