Skip to content

Commit 8a516f9

Browse files
committed
Review comments
1 parent 481a5d6 commit 8a516f9

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

src/Microsoft.ML.Data/Evaluators/BinaryClassifierEvaluator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,8 +897,8 @@ public sealed class CalibratedResult : Result
897897
/// The log-loss reduction is scaled relative to a classifier that predicts the prior for every example:
898898
/// (LL(prior) - LL(classifier)) / LL(prior)
899899
/// This metric can be interpreted as the advantage of the classifier over a random prediction.
900-
/// E.g., if the RIG equals 20, it can be interpreted as "the probability of a correct prediction is
901-
/// 20% better than random guessing".
900+
/// E.g., if the RIG equals 20, it can be interpreted as "the probability of a correct prediction is
901+
/// 20% better than random guessing."
902902
/// </remarks>
903903
public double LogLossReduction { get; }
904904

src/Microsoft.ML.Data/Evaluators/RegressionEvaluator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public sealed class Result
166166
/// </summary>
167167
/// <remarks>
168168
/// The absolute loss is defined as
169-
/// L1 = (1/m) * sum( abs( yi - y'i))
169+
/// L1 = (1/m) * sum( abs( yi - y&apos;i))
170170
/// where m is the number of instances in the test set.
171171
/// y'i are the predicted labels for each instance.
172172
/// yi are the correct labels of each instance.
@@ -178,7 +178,7 @@ public sealed class Result
178178
/// </summary>
179179
/// <remarks>
180180
/// The squared loss is defined as
181-
/// L2 = (1/m) * sum(( yi - y'i)^2)
181+
/// L2 = (1/m) * sum(( yi - y&apos;i)^2)
182182
/// where m is the number of instances in the test set.
183183
/// y'i are the predicted labels for each instance.
184184
/// yi are the correct labels of each instance.

src/Microsoft.ML.Data/StaticPipe/StaticPipeInternalUtils.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,23 @@ public static KeyValuePair<string, Type>[] GetNamesTypes<T, TLeaf>(ParameterInfo
161161
return retVal;
162162
}
163163

164+
/// <summary>
165+
/// Given a schema shape defining instance, return the pairs of names and values, based on a recursive
166+
/// traversal of the value-tuple. If in that list the value <c>a.b.c</c> is paired with an item <c>x</c>,
167+
/// then programmatically <paramref name="record"/> when accessed as <paramref name="record"/><c>.a.b.c</c>
168+
/// would be that item <c>x</c>.
169+
/// </summary>
170+
/// <typeparam name="T">The schema shape defining type.</typeparam>
171+
/// <param name="record">The instance of that schema shape defining type, whose items will
172+
/// populate the <see cref="KeyValuePair{TKey, TValue}.Value"/> fields of the returned items.</param>
173+
/// <param name="pInfo">It is an implementation detail of the value-tuple type that the names
174+
/// are not associated with the type at all, but there is instead an illusion propagated within
175+
/// Visual Studio, that works via attributes. Programmatic access to this is limited, except that
176+
/// a <see cref="TupleElementNamesAttribute"/> is attached to the type in appropriate places, e.g.,
177+
/// in a delegate one of the parameters, or the return parameter, or somesuch. If present, the names
178+
/// will be extracted from that structure, and if not the default names of <c>Item1</c>, <c>Item2</c>,
179+
/// etc. will be used.
180+
/// <returns>The set of names and corresponding values.</returns>
164181
public static KeyValuePair<string, PipelineColumn>[] GetNamesValues<T>(T record, ParameterInfo pInfo)
165182
=> GetNamesValues<T, PipelineColumn>(record, pInfo);
166183

src/Microsoft.ML.Data/StaticPipe/StaticPipeUtils.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace Microsoft.ML.Data.StaticPipe.Runtime
1515
/// <summary>
1616
/// Utility methods for components that want to expose themselves in the idioms of the statically-typed pipelines.
1717
/// These utilities are meant to be called by and useful to component authors, not users of those components. The
18-
/// purpose is not to keep them hidden per se, but rather out of the face of users that are just trying to use the
19-
/// library without the details of how this library is written.
18+
/// purpose is not to keep them hidden per se, but rather in a place less conspicuous to users that are just trying
19+
/// to use the library without writing additional components of their own.
2020
/// </summary>
2121
public static class StaticPipeUtils
2222
{
@@ -447,14 +447,16 @@ public string Get(PipelineColumn key, IExceptionContext ectx = null)
447447
internal IndexHelper(SchemaBearing<T> schematized)
448448
{
449449
Indices = StaticPipeInternalUtils.MakeAnalysisInstance<T>(out var rec);
450-
// We don't really care about this, but we need to work over something.
451-
// The names will not be useful, but we will be getting those from the object's shape anyway.
450+
// We define this delegate just to get its return parameter, so the name extractor has something
451+
// to work over. Because this is defined without the names the names will be default, which is not
452+
// useful, except we can get the "real" names from the schematized object's shape.
452453
Func<T> dummyFunc = () => default;
453454
var pairs = StaticPipeInternalUtils.GetNamesValues(Indices, dummyFunc.Method.ReturnParameter);
454455
Contracts.Assert(pairs.Length == schematized.Shape.Pairs.Length);
455456

456457
var builder = ImmutableDictionary.CreateBuilder<PipelineColumn, string>();
457458
for (int i = 0; i < pairs.Length; ++i)
459+
// Each "index" come from the analysis of the indices object, but we get the names from the shape.
458460
builder.Add(pairs[i].Value, schematized.Shape.Pairs[i].Key);
459461
Map = builder.ToImmutable();
460462
}

0 commit comments

Comments
 (0)