@@ -44,6 +44,7 @@ public abstract class LinearPredictor : PredictorBase<Float>,
4444 ICanSaveInTextFormat ,
4545 ICanSaveInSourceCode ,
4646 ICanSaveModel ,
47+ ICanGetSummaryAsIRow ,
4748 ICanSaveSummary ,
4849 IPredictorWithFeatureWeights < Float > ,
4950 IWhatTheFeatureValueMapper ,
@@ -343,6 +344,30 @@ public void SaveAsCode(TextWriter writer, RoleMappedSchema schema)
343344
344345 public abstract void SaveSummary ( TextWriter writer , RoleMappedSchema schema ) ;
345346
347+ public virtual IRow GetSummaryIRowOrNull ( RoleMappedSchema schema )
348+ {
349+ var cols = new List < IColumn > ( ) ;
350+
351+ var names = default ( VBuffer < DvText > ) ;
352+ MetadataUtils . GetSlotNames ( schema , RoleMappedSchema . ColumnRole . Feature , Weight . Length , ref names ) ;
353+ var slotNamesCol = RowColumnUtils . GetColumn ( MetadataUtils . Kinds . SlotNames ,
354+ new VectorType ( TextType . Instance , Weight . Length ) , ref names ) ;
355+ var slotNamesRow = RowColumnUtils . GetRow ( null , slotNamesCol ) ;
356+ var colType = new VectorType ( NumberType . R4 , Weight . Length ) ;
357+
358+ // Add the bias and the weight columns.
359+ var bias = Bias ;
360+ cols . Add ( RowColumnUtils . GetColumn ( "Bias" , NumberType . R4 , ref bias ) ) ;
361+ var weights = Weight ;
362+ cols . Add ( RowColumnUtils . GetColumn ( "Weights" , colType , ref weights , slotNamesRow ) ) ;
363+ return RowColumnUtils . GetRow ( null , cols . ToArray ( ) ) ;
364+ }
365+
366+ public virtual IRow GetStatsIRowOrNull ( RoleMappedSchema schema )
367+ {
368+ return null ;
369+ }
370+
346371 public abstract void SaveAsIni ( TextWriter writer , RoleMappedSchema schema , ICalibrator calibrator = null ) ;
347372
348373 public virtual void GetFeatureWeights ( ref VBuffer < Float > weights )
@@ -366,8 +391,7 @@ public ValueMapper<TSrc, VBuffer<Float>> GetWhatTheFeatureMapper<TSrc, TDstContr
366391
367392 public sealed partial class LinearBinaryPredictor : LinearPredictor ,
368393 ICanGetSummaryInKeyValuePairs ,
369- IParameterMixer < Float > ,
370- ICanGetSummaryAsIRow
394+ IParameterMixer < Float >
371395 {
372396 public const string LoaderSignature = "Linear2CExec" ;
373397 public const string RegistrationName = "LinearBinaryPredictor" ;
@@ -503,26 +527,7 @@ public IList<KeyValuePair<string, object>> GetSummaryInKeyValuePairs(RoleMappedS
503527 return results ;
504528 }
505529
506- public IRow GetSummaryIRowOrNull ( RoleMappedSchema schema )
507- {
508- var cols = new List < IColumn > ( ) ;
509-
510- var names = default ( VBuffer < DvText > ) ;
511- MetadataUtils . GetSlotNames ( schema , RoleMappedSchema . ColumnRole . Feature , Weight . Length , ref names ) ;
512- var slotNamesCol = RowColumnUtils . GetColumn ( MetadataUtils . Kinds . SlotNames ,
513- new VectorType ( TextType . Instance , Weight . Length ) , ref names ) ;
514- var slotNamesRow = RowColumnUtils . GetRow ( null , slotNamesCol ) ;
515- var colType = new VectorType ( NumberType . R4 , Weight . Length ) ;
516-
517- // Add the bias and the weight columns.
518- var bias = Bias ;
519- cols . Add ( RowColumnUtils . GetColumn ( "Bias" , NumberType . R4 , ref bias ) ) ;
520- var weights = Weight ;
521- cols . Add ( RowColumnUtils . GetColumn ( "Weights" , colType , ref weights , slotNamesRow ) ) ;
522- return RowColumnUtils . GetRow ( null , cols . ToArray ( ) ) ;
523- }
524-
525- public IRow GetStatsIRowOrNull ( RoleMappedSchema schema )
530+ public override IRow GetStatsIRowOrNull ( RoleMappedSchema schema )
526531 {
527532 if ( _stats == null )
528533 return null ;
@@ -582,8 +587,7 @@ public override void SaveAsIni(TextWriter writer, RoleMappedSchema schema, ICali
582587
583588 public sealed class LinearRegressionPredictor : RegressionPredictor ,
584589 IParameterMixer < Float > ,
585- ICanGetSummaryInKeyValuePairs ,
586- ICanGetSummaryAsIRow
590+ ICanGetSummaryInKeyValuePairs
587591 {
588592 public const string LoaderSignature = "LinearRegressionExec" ;
589593 public const string RegistrationName = "LinearRegressionPredictor" ;
@@ -663,30 +667,6 @@ public IList<KeyValuePair<string, object>> GetSummaryInKeyValuePairs(RoleMappedS
663667
664668 return results ;
665669 }
666-
667- public IRow GetSummaryIRowOrNull ( RoleMappedSchema schema )
668- {
669- var cols = new List < IColumn > ( ) ;
670-
671- var names = default ( VBuffer < DvText > ) ;
672- MetadataUtils . GetSlotNames ( schema , RoleMappedSchema . ColumnRole . Feature , Weight . Length , ref names ) ;
673- var slotNamesCol = RowColumnUtils . GetColumn ( MetadataUtils . Kinds . SlotNames ,
674- new VectorType ( TextType . Instance , Weight . Length ) , ref names ) ;
675- var slotNamesRow = RowColumnUtils . GetRow ( null , slotNamesCol ) ;
676- var colType = new VectorType ( NumberType . R4 , Weight . Length ) ;
677-
678- // Add the bias and the weight columns.
679- var bias = Bias ;
680- cols . Add ( RowColumnUtils . GetColumn ( "Bias" , NumberType . R4 , ref bias ) ) ;
681- var weights = Weight ;
682- cols . Add ( RowColumnUtils . GetColumn ( "Weights" , colType , ref weights , slotNamesRow ) ) ;
683- return RowColumnUtils . GetRow ( null , cols . ToArray ( ) ) ;
684- }
685-
686- public IRow GetStatsIRowOrNull ( RoleMappedSchema schema )
687- {
688- return null ;
689- }
690670 }
691671
692672 public sealed class PoissonRegressionPredictor : RegressionPredictor , IParameterMixer < Float >
0 commit comments