@@ -44,6 +44,7 @@ public abstract class LinearPredictor : PredictorBase<Float>,
44
44
ICanSaveInTextFormat ,
45
45
ICanSaveInSourceCode ,
46
46
ICanSaveModel ,
47
+ ICanGetSummaryAsIRow ,
47
48
ICanSaveSummary ,
48
49
IPredictorWithFeatureWeights < Float > ,
49
50
IWhatTheFeatureValueMapper ,
@@ -343,6 +344,30 @@ public void SaveAsCode(TextWriter writer, RoleMappedSchema schema)
343
344
344
345
public abstract void SaveSummary ( TextWriter writer , RoleMappedSchema schema ) ;
345
346
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
+
346
371
public abstract void SaveAsIni ( TextWriter writer , RoleMappedSchema schema , ICalibrator calibrator = null ) ;
347
372
348
373
public virtual void GetFeatureWeights ( ref VBuffer < Float > weights )
@@ -366,8 +391,7 @@ public ValueMapper<TSrc, VBuffer<Float>> GetWhatTheFeatureMapper<TSrc, TDstContr
366
391
367
392
public sealed partial class LinearBinaryPredictor : LinearPredictor ,
368
393
ICanGetSummaryInKeyValuePairs ,
369
- IParameterMixer < Float > ,
370
- ICanGetSummaryAsIRow
394
+ IParameterMixer < Float >
371
395
{
372
396
public const string LoaderSignature = "Linear2CExec" ;
373
397
public const string RegistrationName = "LinearBinaryPredictor" ;
@@ -503,26 +527,7 @@ public IList<KeyValuePair<string, object>> GetSummaryInKeyValuePairs(RoleMappedS
503
527
return results ;
504
528
}
505
529
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 )
526
531
{
527
532
if ( _stats == null )
528
533
return null ;
@@ -582,8 +587,7 @@ public override void SaveAsIni(TextWriter writer, RoleMappedSchema schema, ICali
582
587
583
588
public sealed class LinearRegressionPredictor : RegressionPredictor ,
584
589
IParameterMixer < Float > ,
585
- ICanGetSummaryInKeyValuePairs ,
586
- ICanGetSummaryAsIRow
590
+ ICanGetSummaryInKeyValuePairs
587
591
{
588
592
public const string LoaderSignature = "LinearRegressionExec" ;
589
593
public const string RegistrationName = "LinearRegressionPredictor" ;
@@ -663,30 +667,6 @@ public IList<KeyValuePair<string, object>> GetSummaryInKeyValuePairs(RoleMappedS
663
667
664
668
return results ;
665
669
}
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
- }
690
670
}
691
671
692
672
public sealed class PoissonRegressionPredictor : RegressionPredictor , IParameterMixer < Float >
0 commit comments