Skip to content

Cherry-pick bug fixes and samples from master to release/1.0 #3303

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

Closed
wants to merge 16 commits into from
Closed
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
25 changes: 24 additions & 1 deletion THIRD-PARTY-NOTICES.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,27 @@ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

License notice for SharpZipLib
------------------------------

https://github.com/icsharpcode/SharpZipLib

Copyright © 2000-2018 SharpZipLib Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.ML;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
public static class BootstrapSample
{
Expand All @@ -12,7 +13,7 @@ public static void Example()
var mlContext = new MLContext();

// Get a small dataset as an IEnumerable and them read it as ML.NET's data type.
IEnumerable<SamplesUtils.DatasetUtils.BinaryLabelFloatFeatureVectorFloatWeightSample> enumerableOfData = SamplesUtils.DatasetUtils.GenerateBinaryLabelFloatFeatureVectorFloatWeightSamples(5);
IEnumerable<Microsoft.ML.SamplesUtils.DatasetUtils.BinaryLabelFloatFeatureVectorFloatWeightSample> enumerableOfData = Microsoft.ML.SamplesUtils.DatasetUtils.GenerateBinaryLabelFloatFeatureVectorFloatWeightSamples(5);
var data = mlContext.Data.LoadFromEnumerable(enumerableOfData);

// Look at the original dataset
Expand Down Expand Up @@ -43,7 +44,7 @@ public static void Example()
{
var resample = mlContext.Data.BootstrapSample(data, seed: i);

var enumerable = mlContext.Data.CreateEnumerable<SamplesUtils.DatasetUtils.BinaryLabelFloatFeatureVectorFloatWeightSample>(resample, reuseRowObject: false);
var enumerable = mlContext.Data.CreateEnumerable<Microsoft.ML.SamplesUtils.DatasetUtils.BinaryLabelFloatFeatureVectorFloatWeightSample>(resample, reuseRowObject: false);
Console.WriteLine($"Label\tFeatures[0]");
foreach (var row in enumerable)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using Microsoft.ML;
using Microsoft.ML.SamplesUtils;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
public static class Cache
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System.Collections.Generic;
using Microsoft.ML;
using static Microsoft.ML.DataOperationsCatalog;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
/// <summary>
/// Sample class showing how to use CrossValidationSplit.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System.Collections.Generic;
using Microsoft.ML;
using Microsoft.ML.SamplesUtils;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
/// <summary>
/// Sample class showing how to use ShuffleRows.
Expand Down Expand Up @@ -53,8 +54,6 @@ public static void Example()
// 1/4/2012 34 0
// 1/5/2012 35 0
// 1/6/2012 35 0

Console.ReadLine();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.ML;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
/// <summary>
/// Sample class showing how to use FilterRowsByColumn.
Expand All @@ -15,7 +16,7 @@ public static void Example()
var mlContext = new MLContext();

// Get a small dataset as an IEnumerable.
IEnumerable<SamplesUtils.DatasetUtils.SampleTemperatureData> enumerableOfData = SamplesUtils.DatasetUtils.GetSampleTemperatureData(10);
IEnumerable<Microsoft.ML.SamplesUtils.DatasetUtils.SampleTemperatureData> enumerableOfData = Microsoft.ML.SamplesUtils.DatasetUtils.GetSampleTemperatureData(10);
var data = mlContext.Data.LoadFromEnumerable(enumerableOfData);

// Before we apply a filter, examine all the records in the dataset.
Expand All @@ -42,7 +43,7 @@ public static void Example()
var filteredData = mlContext.Data.FilterRowsByColumn(data, columnName: "Temperature", lowerBound: 34, upperBound: 37);

// Look at the filtered data and observe that values outside [34,37) have been dropped.
var enumerable = mlContext.Data.CreateEnumerable<SamplesUtils.DatasetUtils.SampleTemperatureData>(filteredData, reuseRowObject: true);
var enumerable = mlContext.Data.CreateEnumerable<Microsoft.ML.SamplesUtils.DatasetUtils.SampleTemperatureData>(filteredData, reuseRowObject: true);
Console.WriteLine($"Date\tTemperature");
foreach (var row in enumerable)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using Microsoft.ML;
using Microsoft.ML.Data;
using Microsoft.ML.SamplesUtils;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
using MulticlassClassificationExample = DatasetUtils.MulticlassClassificationExample;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using Microsoft.ML;
using Microsoft.ML.SamplesUtils;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
public class FilterRowsByMissingValues
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using Microsoft.ML;
using Microsoft.ML.SamplesUtils;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
/// <summary>
/// Sample class showing how to use ShuffleRows.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
namespace Microsoft.ML.Samples.Dynamic
using Microsoft.ML;

namespace Samples.Dynamic
{
/// <summary>
/// Sample class showing how to use Skip.
Expand All @@ -13,7 +15,7 @@ public static void Example()
var mlContext = new MLContext();

// Get a small dataset as an IEnumerable.
var enumerableOfData = SamplesUtils.DatasetUtils.GetSampleTemperatureData(10);
var enumerableOfData = Microsoft.ML.SamplesUtils.DatasetUtils.GetSampleTemperatureData(10);
var data = mlContext.Data.LoadFromEnumerable(enumerableOfData);

// Before we apply a filter, examine all the records in the dataset.
Expand All @@ -40,7 +42,7 @@ public static void Example()
var filteredData = mlContext.Data.SkipRows(data, 5);

// Look at the filtered data and observe that the first 5 rows have been dropped
var enumerable = mlContext.Data.CreateEnumerable<SamplesUtils.DatasetUtils.SampleTemperatureData>(filteredData, reuseRowObject: true);
var enumerable = mlContext.Data.CreateEnumerable<Microsoft.ML.SamplesUtils.DatasetUtils.SampleTemperatureData>(filteredData, reuseRowObject: true);
Console.WriteLine($"Date\tTemperature");
foreach (var row in enumerable)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
namespace Microsoft.ML.Samples.Dynamic
using Microsoft.ML;

namespace Samples.Dynamic
{
/// <summary>
/// Sample class showing how to use Take.
Expand All @@ -13,7 +15,7 @@ public static void Example()
var mlContext = new MLContext();

// Get a small dataset as an IEnumerable.
var enumerableOfData = SamplesUtils.DatasetUtils.GetSampleTemperatureData(10);
var enumerableOfData = Microsoft.ML.SamplesUtils.DatasetUtils.GetSampleTemperatureData(10);
var data = mlContext.Data.LoadFromEnumerable(enumerableOfData);

// Before we apply a filter, examine all the records in the dataset.
Expand All @@ -40,7 +42,7 @@ public static void Example()
var filteredData = mlContext.Data.TakeRows(data, 5);

// Look at the filtered data and observe that only the first 5 rows are in the resulting dataset.
var enumerable = mlContext.Data.CreateEnumerable<SamplesUtils.DatasetUtils.SampleTemperatureData>(filteredData, reuseRowObject: true);
var enumerable = mlContext.Data.CreateEnumerable<Microsoft.ML.SamplesUtils.DatasetUtils.SampleTemperatureData>(filteredData, reuseRowObject: true);
Console.WriteLine($"Date\tTemperature");
foreach (var row in enumerable)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.ML.Data;
using Microsoft.ML;
using static Microsoft.ML.DataOperationsCatalog;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
/// <summary>
/// Sample class showing how to use TrainTestSplit.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using Microsoft.ML;
using Microsoft.ML.Data;
using Microsoft.ML.SamplesUtils;
using Microsoft.ML.Trainers;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
public static class FeatureContributionCalculationTransform
{
Expand Down Expand Up @@ -76,7 +76,6 @@ public static void Example()

index++;
}
Console.ReadLine();

// The output of the above code is:
// Label Score BiggestFeature Value Weight Contribution
Expand Down
7 changes: 4 additions & 3 deletions docs/samples/Microsoft.ML.Samples/Dynamic/NgramExtraction.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
using System;
using System.Collections.Generic;
using Microsoft.ML;
using Microsoft.ML.Data;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
public static partial class TransformSamples
{
public static void NgramTransform()
public static void Example()
{
// Create a new ML context, for ML.NET operations. It can be used for exception tracking and logging,
// as well as the source of randomness.
var ml = new MLContext();

// Get a small dataset as an IEnumerable and convert to IDataView.
IEnumerable<SamplesUtils.DatasetUtils.SampleSentimentData> data = SamplesUtils.DatasetUtils.GetSentimentData();
IEnumerable<Microsoft.ML.SamplesUtils.DatasetUtils.SampleSentimentData> data = Microsoft.ML.SamplesUtils.DatasetUtils.GetSentimentData();
var trainData = ml.Data.LoadFromEnumerable(data);

// Preview of the data.
Expand Down
9 changes: 5 additions & 4 deletions docs/samples/Microsoft.ML.Samples/Dynamic/Normalizer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System.Collections.Generic;
using Microsoft.ML;
using Microsoft.ML.Data;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
public static class NormalizerTransform
{
Expand All @@ -13,7 +14,7 @@ public static void Example()
var ml = new MLContext();

// Get a small dataset as an IEnumerable and convert it to an IDataView.
IEnumerable<SamplesUtils.DatasetUtils.SampleInfertData> data = SamplesUtils.DatasetUtils.GetInfertData();
IEnumerable<Microsoft.ML.SamplesUtils.DatasetUtils.SampleInfertData> data = Microsoft.ML.SamplesUtils.DatasetUtils.GetInfertData();
var trainData = ml.Data.LoadFromEnumerable(data);

// Preview of the data.
Expand Down Expand Up @@ -56,8 +57,8 @@ public static void Example()

// Composing a different pipeline if we wanted to normalize more than one column at a time.
// Using log scale as the normalization mode.
var multiColPipeline = ml.Transforms.NormalizeMinMax("LogInduced", "Induced")
.Append(ml.Transforms.NormalizeMinMax("LogSpontaneous", "Spontaneous"));
var multiColPipeline = ml.Transforms.NormalizeLogMeanVariance(new[] { new InputOutputColumnPair("LogInduced", "Induced"), new InputOutputColumnPair("LogSpontaneous", "Spontaneous") });

// The transformed data.
var multiColtransformer = multiColPipeline.Fit(trainData);
var multiColtransformedData = multiColtransformer.Transform(trainData);
Expand Down
8 changes: 5 additions & 3 deletions docs/samples/Microsoft.ML.Samples/Dynamic/OnnxTransform.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System.Linq;
using Microsoft.ML;
using Microsoft.ML.Data;
using Microsoft.ML.OnnxRuntime;

namespace Microsoft.ML.Samples.Dynamic
namespace Samples.Dynamic
{
public static class OnnxTransformExample
{
Expand All @@ -13,8 +14,9 @@ public static class OnnxTransformExample
public static void Example()
{
// Download the squeeznet image model from ONNX model zoo, version 1.2
// https://github.com/onnx/models/tree/master/squeezenet
var modelPath = @"squeezenet\model.onnx";
// https://github.com/onnx/models/tree/master/squeezenet or use
// Microsoft.ML.Onnx.TestModels nuget.
var modelPath = @"squeezenet\00000001\model.onnx";

// Inspect the model's inputs and outputs
var session = new InferenceSession(modelPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
using System.Linq;
using Microsoft.ML.Trainers;
using Microsoft.ML.SamplesUtils;
using Microsoft.ML;

namespace Microsoft.ML.Samples.Dynamic.PermutationFeatureImportance
namespace Samples.Dynamic.PermutationFeatureImportance
{
public static class PfiHelper
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System.Linq;
using Microsoft.ML;

namespace Microsoft.ML.Samples.Dynamic.PermutationFeatureImportance
namespace Samples.Dynamic.PermutationFeatureImportance
{
public static class PfiRegression
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System.Linq;
using Microsoft.ML;
using Microsoft.ML.Trainers;

namespace Microsoft.ML.Samples.Dynamic.PermutationFeatureImportance
namespace Samples.Dynamic.PermutationFeatureImportance
{
public static class PfiBinaryClassification
{
Expand Down
Loading