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 1 commit
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
88 changes: 0 additions & 88 deletions src/Microsoft.ML.Legacy/CSharpApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,18 +1582,6 @@ public void Add(Microsoft.ML.Legacy.Transforms.Scorer input, Microsoft.ML.Legacy
_jsonNodes.Add(Serialize("Transforms.Scorer", input, output));
}

public Microsoft.ML.Legacy.Transforms.Segregator.Output Add(Microsoft.ML.Legacy.Transforms.Segregator input)
{
var output = new Microsoft.ML.Legacy.Transforms.Segregator.Output();
Add(input, output);
return output;
}

public void Add(Microsoft.ML.Legacy.Transforms.Segregator input, Microsoft.ML.Legacy.Transforms.Segregator.Output output)
{
_jsonNodes.Add(Serialize("Transforms.Segregator", input, output));
}

public Microsoft.ML.Legacy.Transforms.SentimentAnalyzer.Output Add(Microsoft.ML.Legacy.Transforms.SentimentAnalyzer input)
{
var output = new Microsoft.ML.Legacy.Transforms.SentimentAnalyzer.Output();
Expand Down Expand Up @@ -16431,82 +16419,6 @@ public sealed class Output
}
}

namespace Legacy.Transforms
{
public enum UngroupTransformUngroupMode
{
Inner = 0,
Outer = 1,
First = 2
}


/// <include file='../Microsoft.ML.Transforms/doc.xml' path='doc/members/member[@name="Ungroup"]/*' />
/// <include file='../Microsoft.ML.Transforms/doc.xml' path='doc/members/example[@name="Ungroup"]/*' />
public sealed partial class Segregator : Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITransformInput, Microsoft.ML.Legacy.ILearningPipelineItem
{


/// <summary>
/// Columns to unroll, or 'pivot'
/// </summary>
public string[] Column { get; set; }

/// <summary>
/// Specifies how to unroll multiple pivot columns of different size.
/// </summary>
public UngroupTransformUngroupMode Mode { get; set; } = UngroupTransformUngroupMode.Inner;

/// <summary>
/// Input dataset
/// </summary>
public Var<Microsoft.ML.Runtime.Data.IDataView> Data { get; set; } = new Var<Microsoft.ML.Runtime.Data.IDataView>();


public sealed class Output : Microsoft.ML.Runtime.EntryPoints.CommonOutputs.ITransformOutput
{
/// <summary>
/// Transformed dataset
/// </summary>
public Var<Microsoft.ML.Runtime.Data.IDataView> OutputData { get; set; } = new Var<Microsoft.ML.Runtime.Data.IDataView>();

/// <summary>
/// Transform model
/// </summary>
public Var<Microsoft.ML.Runtime.EntryPoints.ITransformModel> Model { get; set; } = new Var<Microsoft.ML.Runtime.EntryPoints.ITransformModel>();

}
public Var<IDataView> GetInputData() => Data;

public ILearningPipelineStep ApplyStep(ILearningPipelineStep previousStep, Experiment experiment)
{
if (previousStep != null)
{
if (!(previousStep is ILearningPipelineDataStep dataStep))
{
throw new InvalidOperationException($"{ nameof(Segregator)} only supports an { nameof(ILearningPipelineDataStep)} as an input.");
}

Data = dataStep.Data;
}
Output output = experiment.Add(this);
return new SegregatorPipelineStep(output);
}

private class SegregatorPipelineStep : ILearningPipelineDataStep
{
public SegregatorPipelineStep(Output output)
{
Data = output.OutputData;
Model = output.Model;
}

public Var<IDataView> Data { get; }
public Var<ITransformModel> Model { get; }
}
}
}

namespace Legacy.Transforms
{

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
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.Text;
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.Text
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Oct 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be in same namespace as Term transform.
Which is right now is Microsoft.ML.Transforms.Categorical. #Resolved

{
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