@@ -889,7 +889,10 @@ def summary(self) -> "LinearSVCTrainingSummary": # type: ignore[override]
889
889
trained on the training set. An exception is thrown if `trainingSummary is None`.
890
890
"""
891
891
if self .hasSummary :
892
- return LinearSVCTrainingSummary (super (LinearSVCModel , self ).summary )
892
+ s = LinearSVCTrainingSummary (super (LinearSVCModel , self ).summary )
893
+ if is_remote ():
894
+ s .__source_transformer__ = self # type: ignore[attr-defined]
895
+ return s
893
896
else :
894
897
raise RuntimeError (
895
898
"No training summary available for this %s" % self .__class__ .__name__
@@ -909,7 +912,10 @@ def evaluate(self, dataset: DataFrame) -> "LinearSVCSummary":
909
912
if not isinstance (dataset , DataFrame ):
910
913
raise TypeError ("dataset must be a DataFrame but got %s." % type (dataset ))
911
914
java_lsvc_summary = self ._call_java ("evaluate" , dataset )
912
- return LinearSVCSummary (java_lsvc_summary )
915
+ s = LinearSVCSummary (java_lsvc_summary )
916
+ if is_remote ():
917
+ s .__source_transformer__ = self # type: ignore[attr-defined]
918
+ return s
913
919
914
920
915
921
class LinearSVCSummary (_BinaryClassificationSummary ):
@@ -1578,14 +1584,16 @@ def summary(self) -> "LogisticRegressionTrainingSummary":
1578
1584
trained on the training set. An exception is thrown if `trainingSummary is None`.
1579
1585
"""
1580
1586
if self .hasSummary :
1587
+ s : LogisticRegressionTrainingSummary
1581
1588
if self .numClasses <= 2 :
1582
- return BinaryLogisticRegressionTrainingSummary (
1589
+ s = BinaryLogisticRegressionTrainingSummary (
1583
1590
super (LogisticRegressionModel , self ).summary
1584
1591
)
1585
1592
else :
1586
- return LogisticRegressionTrainingSummary (
1587
- super (LogisticRegressionModel , self ).summary
1588
- )
1593
+ s = LogisticRegressionTrainingSummary (super (LogisticRegressionModel , self ).summary )
1594
+ if is_remote ():
1595
+ s .__source_transformer__ = self # type: ignore[attr-defined]
1596
+ return s
1589
1597
else :
1590
1598
raise RuntimeError (
1591
1599
"No training summary available for this %s" % self .__class__ .__name__
@@ -1605,10 +1613,14 @@ def evaluate(self, dataset: DataFrame) -> "LogisticRegressionSummary":
1605
1613
if not isinstance (dataset , DataFrame ):
1606
1614
raise TypeError ("dataset must be a DataFrame but got %s." % type (dataset ))
1607
1615
java_blr_summary = self ._call_java ("evaluate" , dataset )
1616
+ s : LogisticRegressionSummary
1608
1617
if self .numClasses <= 2 :
1609
- return BinaryLogisticRegressionSummary (java_blr_summary )
1618
+ s = BinaryLogisticRegressionSummary (java_blr_summary )
1610
1619
else :
1611
- return LogisticRegressionSummary (java_blr_summary )
1620
+ s = LogisticRegressionSummary (java_blr_summary )
1621
+ if is_remote ():
1622
+ s .__source_transformer__ = self # type: ignore[attr-defined]
1623
+ return s
1612
1624
1613
1625
1614
1626
class LogisticRegressionSummary (_ClassificationSummary ):
@@ -2304,22 +2316,24 @@ def summary(self) -> "RandomForestClassificationTrainingSummary":
2304
2316
trained on the training set. An exception is thrown if `trainingSummary is None`.
2305
2317
"""
2306
2318
if self .hasSummary :
2319
+ s : RandomForestClassificationTrainingSummary
2307
2320
if self .numClasses <= 2 :
2308
- return BinaryRandomForestClassificationTrainingSummary (
2321
+ s = BinaryRandomForestClassificationTrainingSummary (
2309
2322
super (RandomForestClassificationModel , self ).summary
2310
2323
)
2311
2324
else :
2312
- return RandomForestClassificationTrainingSummary (
2325
+ s = RandomForestClassificationTrainingSummary (
2313
2326
super (RandomForestClassificationModel , self ).summary
2314
2327
)
2328
+ if is_remote ():
2329
+ s .__source_transformer__ = self # type: ignore[attr-defined]
2330
+ return s
2315
2331
else :
2316
2332
raise RuntimeError (
2317
2333
"No training summary available for this %s" % self .__class__ .__name__
2318
2334
)
2319
2335
2320
- def evaluate (
2321
- self , dataset : DataFrame
2322
- ) -> Union ["BinaryRandomForestClassificationSummary" , "RandomForestClassificationSummary" ]:
2336
+ def evaluate (self , dataset : DataFrame ) -> "RandomForestClassificationSummary" :
2323
2337
"""
2324
2338
Evaluates the model on a test dataset.
2325
2339
@@ -2333,10 +2347,14 @@ def evaluate(
2333
2347
if not isinstance (dataset , DataFrame ):
2334
2348
raise TypeError ("dataset must be a DataFrame but got %s." % type (dataset ))
2335
2349
java_rf_summary = self ._call_java ("evaluate" , dataset )
2350
+ s : RandomForestClassificationSummary
2336
2351
if self .numClasses <= 2 :
2337
- return BinaryRandomForestClassificationSummary (java_rf_summary )
2352
+ s = BinaryRandomForestClassificationSummary (java_rf_summary )
2338
2353
else :
2339
- return RandomForestClassificationSummary (java_rf_summary )
2354
+ s = RandomForestClassificationSummary (java_rf_summary )
2355
+ if is_remote ():
2356
+ s .__source_transformer__ = self # type: ignore[attr-defined]
2357
+ return s
2340
2358
2341
2359
2342
2360
class RandomForestClassificationSummary (_ClassificationSummary ):
@@ -2363,7 +2381,10 @@ class RandomForestClassificationTrainingSummary(
2363
2381
2364
2382
2365
2383
@inherit_doc
2366
- class BinaryRandomForestClassificationSummary (_BinaryClassificationSummary ):
2384
+ class BinaryRandomForestClassificationSummary (
2385
+ _BinaryClassificationSummary ,
2386
+ RandomForestClassificationSummary ,
2387
+ ):
2367
2388
"""
2368
2389
BinaryRandomForestClassification results for a given model.
2369
2390
@@ -3341,9 +3362,12 @@ def summary( # type: ignore[override]
3341
3362
trained on the training set. An exception is thrown if `trainingSummary is None`.
3342
3363
"""
3343
3364
if self .hasSummary :
3344
- return MultilayerPerceptronClassificationTrainingSummary (
3365
+ s = MultilayerPerceptronClassificationTrainingSummary (
3345
3366
super (MultilayerPerceptronClassificationModel , self ).summary
3346
3367
)
3368
+ if is_remote ():
3369
+ s .__source_transformer__ = self # type: ignore[attr-defined]
3370
+ return s
3347
3371
else :
3348
3372
raise RuntimeError (
3349
3373
"No training summary available for this %s" % self .__class__ .__name__
@@ -3363,7 +3387,10 @@ def evaluate(self, dataset: DataFrame) -> "MultilayerPerceptronClassificationSum
3363
3387
if not isinstance (dataset , DataFrame ):
3364
3388
raise TypeError ("dataset must be a DataFrame but got %s." % type (dataset ))
3365
3389
java_mlp_summary = self ._call_java ("evaluate" , dataset )
3366
- return MultilayerPerceptronClassificationSummary (java_mlp_summary )
3390
+ s = MultilayerPerceptronClassificationSummary (java_mlp_summary )
3391
+ if is_remote ():
3392
+ s .__source_transformer__ = self # type: ignore[attr-defined]
3393
+ return s
3367
3394
3368
3395
3369
3396
class MultilayerPerceptronClassificationSummary (_ClassificationSummary ):
@@ -4290,7 +4317,10 @@ def summary(self) -> "FMClassificationTrainingSummary":
4290
4317
trained on the training set. An exception is thrown if `trainingSummary is None`.
4291
4318
"""
4292
4319
if self .hasSummary :
4293
- return FMClassificationTrainingSummary (super (FMClassificationModel , self ).summary )
4320
+ s = FMClassificationTrainingSummary (super (FMClassificationModel , self ).summary )
4321
+ if is_remote ():
4322
+ s .__source_transformer__ = self # type: ignore[attr-defined]
4323
+ return s
4294
4324
else :
4295
4325
raise RuntimeError (
4296
4326
"No training summary available for this %s" % self .__class__ .__name__
@@ -4310,7 +4340,10 @@ def evaluate(self, dataset: DataFrame) -> "FMClassificationSummary":
4310
4340
if not isinstance (dataset , DataFrame ):
4311
4341
raise TypeError ("dataset must be a DataFrame but got %s." % type (dataset ))
4312
4342
java_fm_summary = self ._call_java ("evaluate" , dataset )
4313
- return FMClassificationSummary (java_fm_summary )
4343
+ s = FMClassificationSummary (java_fm_summary )
4344
+ if is_remote ():
4345
+ s .__source_transformer__ = self # type: ignore[attr-defined]
4346
+ return s
4314
4347
4315
4348
4316
4349
class FMClassificationSummary (_BinaryClassificationSummary ):
0 commit comments