@@ -322,20 +322,17 @@ def differentiate(
322
322
use_sympy : bool = False ,
323
323
) -> _SelfType :
324
324
"""
325
- EXPERIMENTAL: Take the gradient of this formula. When used a linear
326
- regression, evaluating a trained model on model matrices generated by
327
- this formula is equivalent to estimating the gradient of that fitted
328
- form with respect to `wrt`.
325
+ Take the gradient of this formula with respect to the variables in
326
+ `wrt`.
327
+
328
+ When used a linear regression context, making predictions based on the
329
+ model matrices generated the differentiated formula is equivalent to
330
+ estimating the gradient of the fitted model with respect to `wrt`.
329
331
330
332
Args:
331
333
wrt: The variables with respect to which the gradient should be
332
334
taken.
333
335
use_sympy: Whether to use sympy to perform symbolic differentiation.
334
-
335
-
336
- Notes:
337
- This method is provisional and may be removed in any future major
338
- version.
339
336
"""
340
337
341
338
@@ -482,27 +479,25 @@ def differentiate( # pylint: disable=redefined-builtin
482
479
use_sympy : bool = False ,
483
480
) -> SimpleFormula :
484
481
"""
485
- EXPERIMENTAL: Take the gradient of this formula. When used a linear
486
- regression, evaluating a trained model on model matrices generated by
487
- this formula is equivalent to estimating the gradient of that fitted
488
- form with respect to `wrt`.
482
+ Take the gradient of this formula with respect to the variables in
483
+ `wrt`.
484
+
485
+ When used a linear regression context, making predictions based on the
486
+ model matrices generated the differentiated formula is equivalent to
487
+ estimating the gradient of the fitted model with respect to `wrt`.
489
488
490
489
Args:
491
490
wrt: The variables with respect to which the gradient should be
492
491
taken.
493
492
use_sympy: Whether to use sympy to perform symbolic differentiation.
494
-
495
-
496
- Notes:
497
- This method is provisional and may be removed in any future major
498
- version.
499
493
"""
500
494
return SimpleFormula (
501
495
[
502
496
differentiate_term (term , wrt , use_sympy = use_sympy )
503
497
for term in self .__terms
504
498
],
505
- _ordering = self .ordering ,
499
+ # Preserve term ordering even if differentiation modifies degrees/etc.
500
+ _ordering = OrderingMethod .NONE ,
506
501
)
507
502
508
503
def get_model_matrix (
@@ -784,20 +779,17 @@ def differentiate( # pylint: disable=redefined-builtin
784
779
use_sympy : bool = False ,
785
780
) -> SimpleFormula :
786
781
"""
787
- EXPERIMENTAL: Take the gradient of this formula. When used a linear
788
- regression, evaluating a trained model on model matrices generated by
789
- this formula is equivalent to estimating the gradient of that fitted
790
- form with respect to `wrt`.
782
+ Take the gradient of this formula with respect to the variables in
783
+ `wrt`.
784
+
785
+ When used a linear regression context, making predictions based on the
786
+ model matrices generated the differentiated formula is equivalent to
787
+ estimating the gradient of the fitted model with respect to `wrt`.
791
788
792
789
Args:
793
790
wrt: The variables with respect to which the gradient should be
794
791
taken.
795
792
use_sympy: Whether to use sympy to perform symbolic differentiation.
796
-
797
-
798
- Notes:
799
- This method is provisional and may be removed in any future major
800
- version.
801
793
"""
802
794
return cast (
803
795
SimpleFormula ,
0 commit comments