Skip to content

Commit b431409

Browse files
committed
review comments
1 parent 8b14113 commit b431409

File tree

4 files changed

+40
-39
lines changed

4 files changed

+40
-39
lines changed

src/Microsoft.ML.HalLearners/VectorWhitening.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,18 @@
3333

3434
namespace Microsoft.ML.Transforms.Projections
3535
{
36+
/// <summary>
37+
/// Which vector whitening technique to use. ZCA whitening ensures that the average covariance between whitened
38+
/// and original variables is maximal. In contrast, PCA whitening lead to maximally compressed whitened variables, as
39+
/// measured by squared covariance.
40+
/// </summary>
3641
public enum WhiteningKind
3742
{
38-
/// <summary>
39-
/// PCA whitening.
40-
/// </summary>
43+
/// <summary> PCA whitening.</summary>
4144
[TGUI(Label = "PCA whitening")]
4245
Pca,
4346

44-
/// <summary>
45-
/// ZCA whitening.
46-
/// </summary>
47+
/// <summary> ZCA whitening.</summary>
4748
[TGUI(Label = "ZCA whitening")]
4849
Zca
4950
}
@@ -691,7 +692,7 @@ public sealed class ColumnInfo
691692
/// </summary>
692693
public readonly string Name;
693694
/// <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+
/// Name of column to transform.
695696
/// </summary>
696697
public readonly string InputColumnName;
697698
/// <summary>

src/Microsoft.ML.PCA/PcaTransformer.cs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@
1717
using Microsoft.ML.Numeric;
1818
using Microsoft.ML.Transforms.Projections;
1919

20-
[assembly: LoadableClass(PcaTransformer.Summary, typeof(IDataTransform), typeof(PcaTransformer), typeof(PcaTransformer.Options), typeof(SignatureDataTransform),
21-
PcaTransformer.UserName, PcaTransformer.LoaderSignature, PcaTransformer.ShortName)]
20+
[assembly: LoadableClass(PrincipalComponentAnalysisTransformer.Summary, typeof(IDataTransform), typeof(PrincipalComponentAnalysisTransformer), typeof(PrincipalComponentAnalysisTransformer.Options), typeof(SignatureDataTransform),
21+
PrincipalComponentAnalysisTransformer.UserName, PrincipalComponentAnalysisTransformer.LoaderSignature, PrincipalComponentAnalysisTransformer.ShortName)]
2222

23-
[assembly: LoadableClass(PcaTransformer.Summary, typeof(IDataTransform), typeof(PcaTransformer), null, typeof(SignatureLoadDataTransform),
24-
PcaTransformer.UserName, PcaTransformer.LoaderSignature)]
23+
[assembly: LoadableClass(PrincipalComponentAnalysisTransformer.Summary, typeof(IDataTransform), typeof(PrincipalComponentAnalysisTransformer), null, typeof(SignatureLoadDataTransform),
24+
PrincipalComponentAnalysisTransformer.UserName, PrincipalComponentAnalysisTransformer.LoaderSignature)]
2525

26-
[assembly: LoadableClass(PcaTransformer.Summary, typeof(PcaTransformer), null, typeof(SignatureLoadModel),
27-
PcaTransformer.UserName, PcaTransformer.LoaderSignature)]
26+
[assembly: LoadableClass(PrincipalComponentAnalysisTransformer.Summary, typeof(PrincipalComponentAnalysisTransformer), null, typeof(SignatureLoadModel),
27+
PrincipalComponentAnalysisTransformer.UserName, PrincipalComponentAnalysisTransformer.LoaderSignature)]
2828

29-
[assembly: LoadableClass(typeof(IRowMapper), typeof(PcaTransformer), null, typeof(SignatureLoadRowMapper),
30-
PcaTransformer.UserName, PcaTransformer.LoaderSignature)]
29+
[assembly: LoadableClass(typeof(IRowMapper), typeof(PrincipalComponentAnalysisTransformer), null, typeof(SignatureLoadRowMapper),
30+
PrincipalComponentAnalysisTransformer.UserName, PrincipalComponentAnalysisTransformer.LoaderSignature)]
3131

32-
[assembly: LoadableClass(typeof(void), typeof(PcaTransformer), null, typeof(SignatureEntryPointModule), PcaTransformer.LoaderSignature)]
32+
[assembly: LoadableClass(typeof(void), typeof(PrincipalComponentAnalysisTransformer), null, typeof(SignatureEntryPointModule), PrincipalComponentAnalysisTransformer.LoaderSignature)]
3333

3434
namespace Microsoft.ML.Transforms.Projections
3535
{
3636
/// <include file='doc.xml' path='doc/members/member[@name="PCA"]/*' />
37-
public sealed class PcaTransformer : OneToOneTransformerBase
37+
public sealed class PrincipalComponentAnalysisTransformer : OneToOneTransformerBase
3838
{
3939
internal sealed class Options : TransformInputBase
4040
{
@@ -193,7 +193,7 @@ private static VersionInfo GetVersionInfo()
193193
verReadableCur: 0x00010002,
194194
verWeCanReadBack: 0x00010001,
195195
loaderSignature: LoaderSignature,
196-
loaderAssemblyName: typeof(PcaTransformer).Assembly.FullName);
196+
loaderAssemblyName: typeof(PrincipalComponentAnalysisTransformer).Assembly.FullName);
197197
}
198198

199199
private readonly int _numColumns;
@@ -202,8 +202,8 @@ private static VersionInfo GetVersionInfo()
202202

203203
private const string RegistrationName = "Pca";
204204

205-
internal PcaTransformer(IHostEnvironment env, IDataView input, PrincipalComponentAnalysisEstimator.ColumnInfo[] columns)
206-
: base(Contracts.CheckRef(env, nameof(env)).Register(nameof(PcaTransformer)), GetColumnPairs(columns))
205+
internal PrincipalComponentAnalysisTransformer(IHostEnvironment env, IDataView input, PrincipalComponentAnalysisEstimator.ColumnInfo[] columns)
206+
: base(Contracts.CheckRef(env, nameof(env)).Register(nameof(PrincipalComponentAnalysisTransformer)), GetColumnPairs(columns))
207207
{
208208
Host.AssertNonEmpty(ColumnPairs);
209209
_numColumns = columns.Length;
@@ -221,7 +221,7 @@ internal PcaTransformer(IHostEnvironment env, IDataView input, PrincipalComponen
221221
Train(columns, _transformInfos, input);
222222
}
223223

224-
private PcaTransformer(IHost host, ModelLoadContext ctx)
224+
private PrincipalComponentAnalysisTransformer(IHost host, ModelLoadContext ctx)
225225
: base(host, ctx)
226226
{
227227
Host.AssertValue(ctx);
@@ -260,14 +260,14 @@ private static IDataTransform Create(IHostEnvironment env, Options options, IDat
260260
item.Oversampling ?? options.Oversampling,
261261
item.Center ?? options.Center,
262262
item.Seed ?? options.Seed)).ToArray();
263-
return new PcaTransformer(env, input, cols).MakeDataTransform(input);
263+
return new PrincipalComponentAnalysisTransformer(env, input, cols).MakeDataTransform(input);
264264
}
265265

266266
// Factory method for SignatureLoadModel.
267-
private static PcaTransformer Create(IHostEnvironment env, ModelLoadContext ctx)
267+
private static PrincipalComponentAnalysisTransformer Create(IHostEnvironment env, ModelLoadContext ctx)
268268
{
269269
Contracts.CheckValue(env, nameof(env));
270-
var host = env.Register(nameof(PcaTransformer));
270+
var host = env.Register(nameof(PrincipalComponentAnalysisTransformer));
271271

272272
host.CheckValue(ctx, nameof(ctx));
273273
ctx.CheckAtModel(GetVersionInfo());
@@ -276,7 +276,7 @@ private static PcaTransformer Create(IHostEnvironment env, ModelLoadContext ctx)
276276
int cbFloat = ctx.Reader.ReadInt32();
277277
env.CheckDecode(cbFloat == sizeof(float));
278278
}
279-
return new PcaTransformer(host, ctx);
279+
return new PrincipalComponentAnalysisTransformer(host, ctx);
280280
}
281281

282282
public override void Save(ModelSaveContext ctx)
@@ -538,10 +538,10 @@ public ColumnSchemaInfo((string outputColumnName, string inputColumnName) column
538538
}
539539
}
540540

541-
private readonly PcaTransformer _parent;
541+
private readonly PrincipalComponentAnalysisTransformer _parent;
542542
private readonly int _numColumns;
543543

544-
public Mapper(PcaTransformer parent, Schema inputSchema)
544+
public Mapper(PrincipalComponentAnalysisTransformer parent, Schema inputSchema)
545545
: base(parent.Host.Register(nameof(Mapper)), parent, inputSchema)
546546
{
547547
_parent = parent;
@@ -607,7 +607,7 @@ private static void TransformFeatures(IExceptionContext ectx, in VBuffer<float>
607607
internal static CommonOutputs.TransformOutput Calculate(IHostEnvironment env, Options input)
608608
{
609609
var h = EntryPointUtils.CheckArgsAndCreateHost(env, "Pca", input);
610-
var view = PcaTransformer.Create(h, input, input.Data);
610+
var view = PrincipalComponentAnalysisTransformer.Create(h, input, input.Data);
611611
return new CommonOutputs.TransformOutput()
612612
{
613613
Model = new TransformModelImpl(h, view, input.Data),
@@ -617,7 +617,7 @@ internal static CommonOutputs.TransformOutput Calculate(IHostEnvironment env, Op
617617
}
618618

619619
/// <include file='doc.xml' path='doc/members/member[@name="PCA"]/*'/>
620-
public sealed class PrincipalComponentAnalysisEstimator : IEstimator<PcaTransformer>
620+
public sealed class PrincipalComponentAnalysisEstimator : IEstimator<PrincipalComponentAnalysisTransformer>
621621
{
622622
[BestFriend]
623623
internal static class Defaults
@@ -640,7 +640,6 @@ public sealed class ColumnInfo
640640
public readonly string Name;
641641
/// <summary>
642642
/// Name of column to transform.
643-
/// If set to <see langword="null"/>, the value of the <see cref="Name"/> will be used as source.
644643
/// </summary>
645644
public readonly string InputColumnName;
646645
/// <summary>
@@ -674,7 +673,7 @@ public sealed class ColumnInfo
674673
/// <param name="rank">The number of components in the PCA.</param>
675674
/// <param name="overSampling">Oversampling parameter for randomized PCA training.</param>
676675
/// <param name="center">If enabled, data is centered to be zero mean.</param>
677-
/// <param name="seed">The seed for random number generation.</param>
676+
/// <param name="seed">The random seed. If unspecified random state will be instead derived from the <see cref="MLContext"/>.</param>
678677
public ColumnInfo(string name,
679678
string inputColumnName = null,
680679
string weightColumn = Defaults.WeightColumn,
@@ -729,9 +728,9 @@ internal PrincipalComponentAnalysisEstimator(IHostEnvironment env, params Column
729728
}
730729

731730
/// <summary>
732-
/// Trains and returns a <see cref="PcaTransformer"/>.
731+
/// Trains and returns a <see cref="PrincipalComponentAnalysisTransformer"/>.
733732
/// </summary>
734-
public PcaTransformer Fit(IDataView input) => new PcaTransformer(_host, input, _columns);
733+
public PrincipalComponentAnalysisTransformer Fit(IDataView input) => new PrincipalComponentAnalysisTransformer(_host, input, _columns);
735734

736735
/// <summary>
737736
/// Returns the <see cref="SchemaShape"/> of the schema which will be produced by the transformer.

src/Microsoft.ML.Transforms/GcnTransform.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ public abstract class ColumnInfoBase
668668
/// </summary>
669669
public readonly string Name;
670670
/// <summary>
671-
/// Name of column to transform. If set to <see langword="null"/>, the value of the <see cref="Name"/> will be used as source.
671+
/// Name of column to transform.
672672
/// </summary>
673673
public readonly string InputColumnName;
674674
/// <summary>
@@ -736,7 +736,8 @@ internal void Save(ModelSaveContext ctx)
736736
}
737737
}
738738

739-
public static class Defaults
739+
[BestFriend]
740+
internal static class Defaults
740741
{
741742
public const NormalizerKind NormKind = NormalizerKind.L2Norm;
742743
public const bool LpSubstractMean = false;

src/Microsoft.ML.Transforms/RandomFourierFeaturizing.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
namespace Microsoft.ML.Transforms.Projections
3333
{
3434
/// <summary>
35-
/// Maps vector columns to a random low-dimensional feature space.
35+
/// Maps vector columns to a low -dimensional feature space.
3636
/// </summary>
3737
public sealed class RandomFourierFeaturizingTransformer : OneToOneTransformerBase
3838
{
@@ -612,7 +612,7 @@ private void TransformFeatures(in VBuffer<float> src, ref VBuffer<float> dst, Tr
612612
}
613613

614614
/// <summary>
615-
/// Maps vector columns to a random low-dimensional feature space.
615+
/// Maps vector columns to a low -dimensional feature space.
616616
/// </summary>
617617
public sealed class RandomFourierFeaturizingEstimator : IEstimator<RandomFourierFeaturizingTransformer>
618618
{
@@ -633,7 +633,7 @@ public sealed class ColumnInfo
633633
/// </summary>
634634
public readonly string Name;
635635
/// <summary>
636-
/// Name of the column to transform. If set to <see langword="null"/>, the value of the <see cref="Name"/> will be used as source.
636+
/// Name of the column to transform.
637637
/// </summary>
638638
public readonly string InputColumnName;
639639
/// <summary>
@@ -678,7 +678,7 @@ public ColumnInfo(string name, int newDim, bool useSin, string inputColumnName =
678678
private readonly ColumnInfo[] _columns;
679679

680680
/// <summary>
681-
/// Convinence constructor for simple one column case
681+
/// Convinence constructor for simple one column case.
682682
/// </summary>
683683
/// <param name="env">Host Environment.</param>
684684
/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>

0 commit comments

Comments
 (0)