Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more namespace move for transforms #1457

Merged
merged 5 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.ML.Runtime.Ensemble.Selector;
using Microsoft.ML.Runtime.Ensemble.Selector.SubsetSelector;
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Transforms;

[assembly: LoadableClass(typeof(BootstrapSelector), typeof(BootstrapSelector.Arguments),
typeof(SignatureEnsembleDataSelector), BootstrapSelector.UserName, BootstrapSelector.LoadName)]
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.ML.Transforms/CategoricalTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.ML.StaticPipe;
using Microsoft.ML.StaticPipe.Runtime;
using Microsoft.ML.Transforms.Categorical;
using Microsoft.ML.Transforms.Conversions;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
22 changes: 14 additions & 8 deletions src/Microsoft.ML.Transforms/GroupTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Runtime.Internal.Utilities;
using Microsoft.ML.Runtime.Model;
using Microsoft.ML.Transforms;

[assembly: LoadableClass(GroupTransform.Summary, typeof(GroupTransform), typeof(GroupTransform.Arguments), typeof(SignatureDataTransform),
GroupTransform.UserName, GroupTransform.ShortName)]
Expand All @@ -21,21 +22,25 @@

[assembly: EntryPointModule(typeof(GroupingOperations))]

namespace Microsoft.ML.Runtime.Data
namespace Microsoft.ML.Transforms
{
/// <summary>
/// This transform essentially performs the following SQL-like operation:
/// SELECT GroupKey1, GroupKey2, ... GroupKeyK, LIST(Value1), LIST(Value2), ... LIST(ValueN)
/// A Trasforms that groups values of a scalar column into a vector, by a contiguous group ID.
/// </summary>
/// <remarks>
/// <p>This transform essentially performs the following SQL-like operation:</p>
/// <p>SELECT GroupKey1, GroupKey2, ... GroupKeyK, LIST(Value1), LIST(Value2), ... LIST(ValueN)
/// FROM Data
/// GROUP BY GroupKey1, GroupKey2, ... GroupKeyK.
/// GROUP BY GroupKey1, GroupKey2, ... GroupKeyK.</p>
///
/// It assumes that the group keys are contiguous (if a new group key sequence is encountered, the group is over).
/// <p>It assumes that the group keys are contiguous (if a new group key sequence is encountered, the group is over).
/// The GroupKeyN and ValueN columns can be of any primitive types. The code requires that every raw type T of the group key column
/// is an <see cref="IEquatable{T}"/>, which is currently true for all existing primitive types.
/// The produced ValueN columns will be variable-length vectors of the original value column types.
/// The produced ValueN columns will be variable-length vectors of the original value column types.</p>
///
/// The order of ValueN entries in the lists is preserved.
/// <p>The order of ValueN entries in the lists is preserved.</p>
///
/// <example><code>
/// Example:
/// User Item
/// Pete Book
Expand All @@ -49,7 +54,8 @@ namespace Microsoft.ML.Runtime.Data
/// Pete [Book]
/// Tom [Table, Kitten]
/// Pete [Chair, Cup]
/// </summary>
/// </code></example>
/// </remarks>
public sealed class GroupTransform : TransformBase
{
public const string Summary = "Groups values of a scalar column into a vector, by a contiguous group ID";
Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.ML.Transforms/KeyToBinaryVectorTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.ML.StaticPipe;
using Microsoft.ML.StaticPipe.Runtime;
using Microsoft.ML.Transforms.Categorical;
using Microsoft.ML.Transforms.Conversions;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -28,7 +29,7 @@
[assembly: LoadableClass(typeof(IRowMapper), typeof(KeyToBinaryVectorTransform), null, typeof(SignatureLoadRowMapper),
KeyToBinaryVectorTransform.UserName, KeyToBinaryVectorTransform.LoaderSignature)]

namespace Microsoft.ML.Runtime.Data
namespace Microsoft.ML.Transforms.Conversions
{
public sealed class KeyToBinaryVectorTransform : OneToOneTransformerBase
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.Transforms/LearnerFeatureSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[assembly: LoadableClass(LearnerFeatureSelectionTransform.Summary, typeof(IDataTransform), typeof(LearnerFeatureSelectionTransform), typeof(LearnerFeatureSelectionTransform.Arguments), typeof(SignatureDataTransform),
"Learner Feature Selection Transform", "LearnerFeatureSelectionTransform", "LearnerFeatureSelection")]

namespace Microsoft.ML.Runtime.Data
namespace Microsoft.ML.Transforms
{
/// <summary>
/// Selects the slots for which the absolute value of the corresponding weight in a linear learner
Expand Down
9 changes: 5 additions & 4 deletions src/Microsoft.ML.Transforms/LoadTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.ML.Runtime;
using Microsoft.ML.Runtime.CommandLine;
using Microsoft.ML.Runtime.Data;
using Microsoft.ML.Runtime.Internal.Utilities;
using Microsoft.ML.Runtime.Model;
using Microsoft.ML.Transforms;
using System;
using System.Collections.Generic;
using System.IO;

[assembly: LoadableClass(LoadTransform.Summary, typeof(IDataTransform), typeof(LoadTransform), typeof(LoadTransform.Arguments), typeof(SignatureDataTransform),
"Load Transform", "LoadTransform", "Load")]

namespace Microsoft.ML.Runtime.Data
namespace Microsoft.ML.Transforms
{
/// <summary>
/// Load specific transforms from the specified model file. Allows one to 'cherry pick' transforms from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
using Microsoft.ML.Runtime.Data;
using Microsoft.ML.Runtime.Internal.Utilities;
using Microsoft.ML.Runtime.Model;
using Microsoft.ML.Transforms;

[assembly: LoadableClass(typeof(MissingValueIndicatorTransform), typeof(MissingValueIndicatorTransform.Arguments), typeof(SignatureDataTransform),
"", "MissingValueIndicatorTransform", "MissingValueTransform", "MissingTransform", "Missing")]

[assembly: LoadableClass(typeof(MissingValueIndicatorTransform), null, typeof(SignatureLoadDataTransform),
"Missing Value Indicator Transform", MissingValueIndicatorTransform.LoaderSignature, "MissingFeatureFunction")]

namespace Microsoft.ML.Runtime.Data
namespace Microsoft.ML.Transforms
{
public sealed class MissingValueIndicatorTransform : OneToOneTransformBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[assembly: LoadableClass(MutualInformationFeatureSelectionTransform.Summary, typeof(IDataTransform), typeof(MutualInformationFeatureSelectionTransform), typeof(MutualInformationFeatureSelectionTransform.Arguments), typeof(SignatureDataTransform),
MutualInformationFeatureSelectionTransform.UserName, "MutualInformationFeatureSelection", "MutualInformationFeatureSelectionTransform", MutualInformationFeatureSelectionTransform.ShortName)]

namespace Microsoft.ML.Runtime.Data
namespace Microsoft.ML.Transforms
{
/// <include file='doc.xml' path='doc/members/member[@name="MutualInformationFeatureSelection"]/*' />
public static class MutualInformationFeatureSelectionTransform
Expand Down Expand Up @@ -647,7 +647,7 @@ private void FillTable(ref VBuffer<int> features, int offset, int numFeatures)
/// </summary>
private static ValueMapper<VBuffer<T>, VBuffer<int>> BinKeys<T>(ColumnType colType)
{
var conv = Conversion.Conversions.Instance.GetStandardConversion<T, uint>(colType, NumberType.U4, out bool identity);
var conv = Runtime.Data.Conversion.Conversions.Instance.GetStandardConversion<T, uint>(colType, NumberType.U4, out bool identity);
ValueMapper<T, int> mapper;
if (identity)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.ML.Transforms/OptionalColumnTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Microsoft.ML.Runtime.CommandLine;
using Microsoft.ML.Runtime.Data;
using Microsoft.ML.Runtime.Data.IO;
using Microsoft.ML.Runtime.DataPipe;
using Microsoft.ML.Transforms;
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Runtime.Internal.Utilities;
using Microsoft.ML.Runtime.Model;
Expand All @@ -24,7 +24,7 @@

[assembly: EntryPointModule(typeof(OptionalColumnTransform))]

namespace Microsoft.ML.Runtime.DataPipe
namespace Microsoft.ML.Transforms
{
/// <include file='doc.xml' path='doc/members/member[@name="OptionalColumnTransform"]/*' />
public class OptionalColumnTransform : RowToRowMapperTransformBase
Expand Down
11 changes: 5 additions & 6 deletions src/Microsoft.ML.Transforms/TermLookupTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
using Microsoft.ML.Runtime;
using Microsoft.ML.Runtime.CommandLine;
using Microsoft.ML.Runtime.Data;
using Microsoft.ML.Runtime.Data.Conversion;
using Microsoft.ML.Runtime.Data.IO;
using Microsoft.ML.Runtime.Internal.Utilities;
using Microsoft.ML.Runtime.Model;
using Microsoft.ML.Transforms;
using Microsoft.ML.Transforms.Categoricals;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -22,7 +21,7 @@
[assembly: LoadableClass(TermLookupTransform.Summary, typeof(TermLookupTransform), null, typeof(SignatureLoadDataTransform),
"Term Lookup Transform", TermLookupTransform.LoaderSignature)]

namespace Microsoft.ML.Runtime.Data
namespace Microsoft.ML.Transforms.Categoricals
{
using Conditional = System.Diagnostics.ConditionalAttribute;

Expand Down Expand Up @@ -223,7 +222,7 @@ public OneValueMap(PrimitiveType type)
// We should probably have a mapping from type to its bad value somewhere, perhaps in Conversions.
bool identity;
ValueMapper<ReadOnlyMemory<char>, TRes> conv;
if (Conversions.Instance.TryGetStandardConversion<ReadOnlyMemory<char>, TRes>(TextType.Instance, type,
if (Runtime.Data.Conversion.Conversions.Instance.TryGetStandardConversion<ReadOnlyMemory<char>, TRes>(TextType.Instance, type,
out conv, out identity))
{
//Empty string will map to NA for R4 and R8, the only two types that can
Expand Down Expand Up @@ -386,7 +385,7 @@ private static IComponentFactory<IMultiStreamSource, IDataLoader> GetLoaderFacto
// Try to parse the text as a key value between 1 and ulong.MaxValue. If this succeeds and res>0,
// we update max and min accordingly. If res==0 it means the value is missing, in which case we ignore it for
// computing max and min.
if (Conversions.Instance.TryParseKey(in txt, 1, ulong.MaxValue, out res))
if (Runtime.Data.Conversion.Conversions.Instance.TryParseKey(in txt, 1, ulong.MaxValue, out res))
{
if (res < min && res != 0)
min = res;
Expand All @@ -395,7 +394,7 @@ private static IComponentFactory<IMultiStreamSource, IDataLoader> GetLoaderFacto
}
// If parsing as key did not succeed, the value can still be 0, so we try parsing it as a ulong. If it succeeds,
// then the value is 0, and we update min accordingly.
else if (Conversions.Instance.TryParse(in txt, out res))
else if (Runtime.Data.Conversion.Conversions.Instance.TryParse(in txt, out res))
{
ch.Assert(res == 0);
min = 0;
Expand Down
7 changes: 4 additions & 3 deletions src/Microsoft.ML.Transforms/UngroupTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Runtime.Internal.Utilities;
using Microsoft.ML.Runtime.Model;
using Microsoft.ML.Transforms;

[assembly: LoadableClass(UngroupTransform.Summary, typeof(UngroupTransform), typeof(UngroupTransform.Arguments), typeof(SignatureDataTransform),
UngroupTransform.UserName, UngroupTransform.ShortName)]

[assembly: LoadableClass(UngroupTransform.Summary, typeof(UngroupTransform), null, typeof(SignatureLoadDataTransform),
UngroupTransform.UserName, UngroupTransform.LoaderSignature)]

namespace Microsoft.ML.Runtime.Data
namespace Microsoft.ML.Transforms
{

// This can be thought of as an inverse of GroupTransform. For all specified vector columns
Expand Down Expand Up @@ -267,7 +268,7 @@ public SchemaImpl(IExceptionContext ectx, Schema inputSchema, UngroupMode mode,
_pivotIndex[info.Index] = i;
}

AsSchema = Data.Schema.Create(this);
AsSchema = Runtime.Data.Schema.Create(this);
}

private static void CheckAndBind(IExceptionContext ectx, ISchema inputSchema,
Expand Down Expand Up @@ -613,7 +614,7 @@ private ValueGetter<T> MakeGetter<T>(int col, PrimitiveType itemType)
// cachedIndex == row.Count || _pivotColPosition <= row.Indices[cachedIndex].
int cachedIndex = 0;
VBuffer<T> row = default(VBuffer<T>);
T naValue = Conversions.Instance.GetNAOrDefault<T>(itemType);
T naValue = Runtime.Data.Conversion.Conversions.Instance.GetNAOrDefault<T>(itemType);
return
(ref T value) =>
{
Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.ML.Transforms/WhiteningTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
using Microsoft.ML.Runtime.Internal.Utilities;
using Microsoft.ML.Runtime.Model;
using Microsoft.ML.Runtime.Internal.Internallearn;
using Microsoft.ML.Transforms;

[assembly: LoadableClass(WhiteningTransform.Summary, typeof(WhiteningTransform), typeof(WhiteningTransform.Arguments), typeof(SignatureDataTransform),
"Whitening Transform", "WhiteningTransform", "Whitening")]

[assembly: LoadableClass(WhiteningTransform.Summary, typeof(WhiteningTransform), null, typeof(SignatureLoadDataTransform),
"Whitening Transform", WhiteningTransform.LoaderSignature, WhiteningTransform.LoaderSignatureOld)]

namespace Microsoft.ML.Runtime.Data
namespace Microsoft.ML.Transforms
{
public enum WhiteningKind
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Microsoft.ML.StaticPipe.Runtime;
using System.Collections.Generic;
using System.Linq;
using static Microsoft.ML.Runtime.Data.MutualInformationFeatureSelectionTransform;
using static Microsoft.ML.Transforms.MutualInformationFeatureSelectionTransform;

namespace Microsoft.ML.Transforms
{
Expand Down
Loading