@@ -791,7 +791,7 @@ def _add_single(self, key: str, val: str | Section) -> Section:
791
791
792
792
def add_model_plot (
793
793
self ,
794
- section : str | None = None ,
794
+ section : str = "Model description/Training Procedure/Model Plot" ,
795
795
description : str | None = None ,
796
796
) -> Self :
797
797
"""Add a model plot
@@ -805,11 +805,10 @@ def add_model_plot(
805
805
806
806
Parameters
807
807
----------
808
- section : str or None, default=None
809
- The section that the model plot should be added to. If you're using
810
- the default skops template, you can leave this parameter as
811
- ``None``, otherwise you have to indicate the section. If the section
812
- does not exist, it will be created for you.
808
+ section : str (default="Model description/Training Procedure/Model Plot")
809
+ The section that the model plot should be added to. By default, the
810
+ section is set to fit the skops model card template. If you're using
811
+ a different template, you may have to choose a different section name.
813
812
814
813
description : str or None, default=None
815
814
An optional description to be added before the model plot. If you're
@@ -821,18 +820,8 @@ def add_model_plot(
821
820
-------
822
821
self : object
823
822
Card object.
824
- """
825
- if section is None :
826
- if self .template == Templates .skops .value :
827
- section = "Model description/Training Procedure/Model Plot"
828
- else :
829
- msg = NEED_SECTION_ERR_MSG .format (action = "add a model plot" )
830
- raise ValueError (msg )
831
-
832
- if description is None :
833
- if self .template == Templates .skops .value :
834
- description = "The model plot is below."
835
823
824
+ """
836
825
self ._add_model_plot (
837
826
self .get_model (), section_name = section , description = description
838
827
)
@@ -864,17 +853,19 @@ def _add_model_plot(
864
853
self ._add_single (section_name , section )
865
854
866
855
def add_hyperparams (
867
- self , section : str | None = None , description : str | None = None
856
+ self ,
857
+ section : str = "Model description/Training Procedure/Hyperparameters" ,
858
+ description : str | None = None ,
868
859
) -> Self :
869
860
"""Add the model's hyperparameters as a table
870
861
871
862
Parameters
872
863
----------
873
- section : str or None, default=None
874
- The section that the hyperparamters should be added to. If you're
875
- using the default skops template, you can leave this parameter as
876
- ``None``, otherwise you have to indicate the section. If the section
877
- does not exist, it will be created for you .
864
+ section : str ( default="Model description/Training Procedure/Hyperparameters")
865
+ The section that the hyperparameters should be added to. By default,
866
+ the section is set to fit the skops model card template. If you're
867
+ using a different template, you may have to choose a different section
868
+ name .
878
869
879
870
description : str or None, default=None
880
871
An optional description to be added before the hyperparamters. If
@@ -888,17 +879,6 @@ def add_hyperparams(
888
879
Card object.
889
880
890
881
"""
891
- if section is None :
892
- if self .template == Templates .skops .value :
893
- section = "Model description/Training Procedure/Hyperparameters"
894
- else :
895
- msg = NEED_SECTION_ERR_MSG .format (action = "add model hyperparameters" )
896
- raise ValueError (msg )
897
-
898
- if description is None :
899
- if self .template == Templates .skops .value :
900
- description = "The model is trained with below hyperparameters."
901
-
902
882
self ._add_hyperparams (
903
883
self .get_model (), section_name = section , description = description
904
884
)
@@ -924,7 +904,7 @@ def _add_hyperparams(
924
904
925
905
def add_get_started_code (
926
906
self ,
927
- section : str | None = None ,
907
+ section : str = "How to Get Started with the Model" ,
928
908
description : str | None = None ,
929
909
file_name : str | None = None ,
930
910
model_format : Literal ["pickle" , "skops" ] | None = None ,
@@ -936,11 +916,11 @@ def add_get_started_code(
936
916
937
917
Parameters
938
918
----------
939
- section : str or None, default=None
940
- The section that the code should be added to. If you're using the
941
- default skops template, you can leave this parameter as ``None``,
942
- otherwise you have to indicate the section. If the section does not
943
- exist, it will be created for you .
919
+ section : str ( default="How to Get Started with the Model")
920
+ The section that the code for loading the model should be added to.
921
+ By default, the section is set to fit the skops model card template.
922
+ If you're using a different template, you may have to choose a
923
+ different section name .
944
924
945
925
description : str or None, default=None
946
926
An optional description to be added before the code. If you're using
@@ -984,17 +964,6 @@ def add_get_started_code(
984
964
if (not file_name ) or (not model_format ):
985
965
return self
986
966
987
- if section is None :
988
- if self .template == Templates .skops .value :
989
- section = "How to Get Started with the Model"
990
- else :
991
- msg = NEED_SECTION_ERR_MSG .format (action = "add get started code" )
992
- raise ValueError (msg )
993
-
994
- if description is None :
995
- if self .template == Templates .skops .value :
996
- description = "Use the code below to get started with the model."
997
-
998
967
self ._add_get_started_code (
999
968
section ,
1000
969
file_name = file_name ,
@@ -1157,7 +1126,7 @@ def add_table(
1157
1126
1158
1127
def add_metrics (
1159
1128
self ,
1160
- section : str | None = None ,
1129
+ section : str = "Model description/Evaluation Results" ,
1161
1130
description : str | None = None ,
1162
1131
** kwargs : str | int | float ,
1163
1132
) -> Self :
@@ -1167,11 +1136,10 @@ def add_metrics(
1167
1136
1168
1137
Parameters
1169
1138
----------
1170
- section : str or None, default=None
1171
- The section that the metrics should be added to. If you're using the
1172
- default skops template, you can leave this parameter as ``None``,
1173
- otherwise you have to indicate the section. If the section does not
1174
- exist, it will be created for you.
1139
+ section : str (default="Model description/Evaluation Results")
1140
+ The section that metrics should be added to. By default, the section
1141
+ is set to fit the skops model card template. If you're using a
1142
+ different template, you may have to choose a different section name.
1175
1143
1176
1144
description : str or None, default=None
1177
1145
An optional description to be added before the metrics. If you're
@@ -1186,20 +1154,8 @@ def add_metrics(
1186
1154
-------
1187
1155
self : object
1188
1156
Card object.
1189
- """
1190
- if section is None :
1191
- if self .template == Templates .skops .value :
1192
- section = "Model description/Evaluation Results"
1193
- else :
1194
- msg = NEED_SECTION_ERR_MSG .format (action = "add metrics" )
1195
- raise ValueError (msg )
1196
1157
1197
- if description is None :
1198
- if self .template == Templates .skops .value :
1199
- description = (
1200
- "You can find the details about evaluation process and "
1201
- "the evaluation results."
1202
- )
1158
+ """
1203
1159
self ._metrics .update (kwargs )
1204
1160
self ._add_metrics (section , description = description , metrics = self ._metrics )
1205
1161
return self
0 commit comments