Skip to content

Commit fa95c00

Browse files
authored
Towards #3204 - documentation for ApproximatedKernelMappingEstimator (#3377)
* Documentation for ApproximatedKernelMappingEstimator * Address code review comments * Address Shahab's comments
1 parent 0a90bbb commit fa95c00

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

src/Microsoft.ML.Transforms/KernelCatalog.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@ namespace Microsoft.ML
1313
public static class KernelExpansionCatalog
1414
{
1515
/// <summary>
16-
/// Takes column filled with a vector of floats and maps its to a random low-dimensional feature space.
16+
/// Create an <see cref="ApproximatedKernelMappingEstimator"/> that maps input vectors to a low dimensional
17+
/// feature space where inner products approximate a shift-invariant kernel function.
1718
/// </summary>
1819
/// <param name="catalog">The transform's catalog.</param>
1920
/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
20-
/// <param name="inputColumnName">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
21-
/// <param name="rank">The number of random Fourier features to create.</param>
22-
/// <param name="useCosAndSinBases">If <see langword="true"/>, use both of cos and sin basis functions to create two features for every random Fourier frequency.
23-
/// Otherwise, only cos bases would be used.</param>
24-
/// <param name="generator">Which fourier generator to use.</param>
21+
/// <param name="inputColumnName">Name of column to transform. If set to <see langword="null"/>,
22+
/// the value of the <paramref name="outputColumnName"/> will be used as source.
23+
/// The data type on this column should be a known-sized vector of <see cref="System.Single"/>.</param>
24+
/// <param name="rank">The dimension of the feature space to map the input to.</param>
25+
/// <param name="useCosAndSinBases">If <see langword="true"/>, use both of cos and sin basis functions to create
26+
/// two features for every random Fourier frequency. Otherwise, only cos bases would be used. Note that if set
27+
/// to <see langword="true"/>, the dimension of the output feature space will be 2*<paramref name="rank"/>.</param>
28+
/// <param name="generator">The argument that indicates which kernel to use. The two available implementations
29+
/// are <see cref="GaussianKernel"/> and <see cref="LaplacianKernel"/>.</param>
2530
/// <param name="seed">The seed of the random number generator for generating the new features (if unspecified, the global random is used).</param>
2631
/// <example>
2732
/// <format type="text/markdown">
@@ -41,7 +46,8 @@ public static ApproximatedKernelMappingEstimator ApproximatedKernelMap(this Tran
4146
new[] { new ApproximatedKernelMappingEstimator.ColumnOptions(outputColumnName, rank, useCosAndSinBases, inputColumnName, generator, seed) });
4247

4348
/// <summary>
44-
/// Takes columns filled with a vector of floats and maps its to a random low-dimensional feature space.
49+
/// Create an <see cref="ApproximatedKernelMappingEstimator"/> that maps input vectors to a low dimensional
50+
/// feature space where inner products approximate a shift-invariant kernel function.
4551
/// </summary>
4652
/// <param name="catalog">The transform's catalog.</param>
4753
/// <param name="columns">The input columns to use for the transformation.</param>

src/Microsoft.ML.Transforms/RandomFourierFeaturizing.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@
2929
namespace Microsoft.ML.Transforms
3030
{
3131
/// <summary>
32-
/// Maps vector columns to a feature space where the inner products approximate a user specified shift-invariant kernel.
33-
/// The kernel is indicated by specifying a <see cref="KernelBase"/> instance. The available implementations
34-
/// are <see cref="GaussianKernel"/> and <see cref="LaplacianKernel"/>.
35-
/// This transformation is based on this paper by
36-
/// <a href="http://pages.cs.wisc.edu/~brecht/papers/07.rah.rec.nips.pdf">Rahimi and Recht</a>.
32+
/// <see cref="ITransformer"/> resulting from fitting an <see cref="ApproximatedKernelMappingEstimator"/>.
3733
/// </summary>
3834
public sealed class ApproximatedKernelTransformer : OneToOneTransformerBase
3935
{
@@ -605,6 +601,27 @@ private void TransformFeatures(in VBuffer<float> src, ref VBuffer<float> dst, Tr
605601
/// <summary>
606602
/// Maps vector columns to a low -dimensional feature space.
607603
/// </summary>
604+
/// <remarks>
605+
/// <format type="text/markdown"><![CDATA[
606+
///
607+
/// ### Estimator Characteristics
608+
/// | | |
609+
/// | -- | -- |
610+
/// | Does this estimator need to look at the data to train its parameters? | Yes |
611+
/// | Input column data type | Known-sized vector of <xref:System.Single> |
612+
/// | Output column data type | Known-sized vector of <xref:System.Single> |
613+
///
614+
/// The resulting <xref:Microsoft.ML.Transforms.ApproximatedKernelTransformer> creates a new column, named as specified in
615+
/// the output column name parameters, where each input vector is mapped to a feature space where inner products
616+
/// approximate one of two shift-invariant kernel functions: The Gaussian kernel, or the Laplacian kernel.
617+
/// By mapping features to a space that approximate non-linear kernels, linear methods can be used to approximate
618+
/// more complex kernel SVM models.
619+
/// This mapping is based on the paper [Random Features for Large-Scale Kernel Machines](http://pages.cs.wisc.edu/~brecht/papers/07.rah.rec.nips.pdf)
620+
/// by Rahimi and Recht.
621+
/// ]]></format>
622+
/// </remarks>
623+
/// <seealso cref="KernelExpansionCatalog.ApproximatedKernelMap(TransformsCatalog, ColumnOptions[])"/>
624+
/// <seealso cref="KernelExpansionCatalog.ApproximatedKernelMap(TransformsCatalog, string, string, int, bool, KernelBase, int?)"/>
608625
public sealed class ApproximatedKernelMappingEstimator : IEstimator<ApproximatedKernelTransformer>
609626
{
610627
[BestFriend]

0 commit comments

Comments
 (0)