@@ -35,9 +35,15 @@ namespace Microsoft.ML.Transforms.Projections
35
35
{
36
36
public enum WhiteningKind
37
37
{
38
+ /// <summary>
39
+ /// PCA whitening.
40
+ /// </summary>
38
41
[ TGUI ( Label = "PCA whitening" ) ]
39
42
Pca ,
40
43
44
+ /// <summary>
45
+ /// ZCA whitening.
46
+ /// </summary>
41
47
[ TGUI ( Label = "ZCA whitening" ) ]
42
48
Zca
43
49
}
@@ -186,9 +192,9 @@ internal static VectorWhiteningTransformer Create(IHostEnvironment env, ModelLoa
186
192
}
187
193
188
194
// Factory method for SignatureDataTransform.
189
- internal static IDataTransform Create ( IHostEnvironment env , Options args , IDataView input )
195
+ internal static IDataTransform Create ( IHostEnvironment env , Options options , IDataView input )
190
196
{
191
- var infos = args . Columns . Select ( colPair => new VectorWhiteningEstimator . ColumnInfo ( colPair , args ) ) . ToArray ( ) ;
197
+ var infos = options . Columns . Select ( colPair => new VectorWhiteningEstimator . ColumnInfo ( colPair , options ) ) . ToArray ( ) ;
192
198
( var models , var invModels ) = TrainVectorWhiteningTransform ( env , input , infos ) ;
193
199
return new VectorWhiteningTransformer ( env , models , invModels , infos ) . MakeDataTransform ( input ) ;
194
200
}
@@ -665,7 +671,8 @@ private static float DotProduct(float[] a, int aOffset, ReadOnlySpan<float> b, R
665
671
/// <include file='doc.xml' path='doc/members/member[@name="Whitening"]/*'/>
666
672
public sealed class VectorWhiteningEstimator : IEstimator < VectorWhiteningTransformer >
667
673
{
668
- public static class Defaults
674
+ [ BestFriend ]
675
+ internal static class Defaults
669
676
{
670
677
public const WhiteningKind Kind = WhiteningKind . Zca ;
671
678
public const float Eps = 1e-5f ;
@@ -679,11 +686,29 @@ public static class Defaults
679
686
/// </summary>
680
687
public sealed class ColumnInfo
681
688
{
689
+ /// <summary>
690
+ /// Name of the column resulting from the transformation of <see cref="InputColumnName"/>.
691
+ /// </summary>
682
692
public readonly string Name ;
693
+ /// <summary>
694
+ /// Name of column to transform. If set to <see langword="null"/>, the value of the <see cref="Name"/> will be used as source.
695
+ /// </summary>
683
696
public readonly string InputColumnName ;
697
+ /// <summary>
698
+ /// Whitening kind (PCA/ZCA).
699
+ /// </summary>
684
700
public readonly WhiteningKind Kind ;
701
+ /// <summary>
702
+ /// Whitening constant, prevents division by zero.
703
+ /// </summary>
685
704
public readonly float Epsilon ;
705
+ /// <summary>
706
+ /// Maximum number of rows used to train the transform.
707
+ /// </summary>
686
708
public readonly int MaxRow ;
709
+ /// <summary>
710
+ /// In case of PCA whitening, indicates the number of components to retain.
711
+ /// </summary>
687
712
public readonly int PcaNum ;
688
713
internal readonly bool SaveInv ;
689
714
@@ -714,20 +739,20 @@ public ColumnInfo(string name, string inputColumnName = null, WhiteningKind kind
714
739
Contracts . CheckUserArg ( PcaNum >= 0 , nameof ( PcaNum ) ) ;
715
740
}
716
741
717
- internal ColumnInfo ( VectorWhiteningTransformer . Column item , VectorWhiteningTransformer . Options args )
742
+ internal ColumnInfo ( VectorWhiteningTransformer . Column item , VectorWhiteningTransformer . Options options )
718
743
{
719
744
Name = item . Name ;
720
745
Contracts . CheckValue ( Name , nameof ( Name ) ) ;
721
746
InputColumnName = item . Source ?? item . Name ;
722
747
Contracts . CheckValue ( InputColumnName , nameof ( InputColumnName ) ) ;
723
- Kind = item . Kind ?? args . Kind ;
748
+ Kind = item . Kind ?? options . Kind ;
724
749
Contracts . CheckUserArg ( Kind == WhiteningKind . Pca || Kind == WhiteningKind . Zca , nameof ( item . Kind ) ) ;
725
- Epsilon = item . Eps ?? args . Eps ;
750
+ Epsilon = item . Eps ?? options . Eps ;
726
751
Contracts . CheckUserArg ( 0 <= Epsilon && Epsilon < float . PositiveInfinity , nameof ( item . Eps ) ) ;
727
- MaxRow = item . MaxRows ?? args . MaxRows ;
752
+ MaxRow = item . MaxRows ?? options . MaxRows ;
728
753
Contracts . CheckUserArg ( MaxRow > 0 , nameof ( item . MaxRows ) ) ;
729
- SaveInv = item . SaveInverse ?? args . SaveInverse ;
730
- PcaNum = item . PcaNum ?? args . PcaNum ;
754
+ SaveInv = item . SaveInverse ?? options . SaveInverse ;
755
+ PcaNum = item . PcaNum ?? options . PcaNum ;
731
756
Contracts . CheckUserArg ( PcaNum >= 0 , nameof ( item . PcaNum ) ) ;
732
757
}
733
758
@@ -803,6 +828,9 @@ internal VectorWhiteningEstimator(IHostEnvironment env, string outputColumnName,
803
828
{
804
829
}
805
830
831
+ /// <summary>
832
+ /// Trains and returns a <see cref="VectorWhiteningTransformer"/>.
833
+ /// </summary>
806
834
public VectorWhiteningTransformer Fit ( IDataView input )
807
835
{
808
836
// Build transformation matrices for whitening process, then construct a trained transform.
@@ -811,7 +839,8 @@ public VectorWhiteningTransformer Fit(IDataView input)
811
839
}
812
840
813
841
/// <summary>
814
- /// Returns the schema that would be produced by the transformation.
842
+ /// Returns the <see cref="SchemaShape"/> of the schema which will be produced by the transformer.
843
+ /// Used for schema propagation and verification in a pipeline.
815
844
/// </summary>
816
845
public SchemaShape GetOutputSchema ( SchemaShape inputSchema )
817
846
{
0 commit comments