Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
96ac1ea
same as last commit message
Jun 13, 2022
88eb579
using xiaoyun\'s .rows.gropy() implementation method for the ByGroup(…
Jun 15, 2022
6dad117
adding the regression catalog
Jun 21, 2022
f76e866
added the fairlearn extension
Jun 21, 2022
61956ab
Fixed the dataframe column adding bug; added unit testing
jordi1215 Jun 22, 2022
56ea872
Added a Metric Test; Added difference between groups in regression
jordi1215 Jun 23, 2022
bac073d
Added more metrics to the regression
jordi1215 Jun 23, 2022
16aedd8
RMS and MSE support
jordi1215 Jun 23, 2022
b626f67
Moment and UtilityParity
jordi1215 Jul 6, 2022
707cfdc
Demographic Parity initial unit tests passed
jordi1215 Jul 7, 2022
99a0f4c
update
LittleLittleCloud Jul 8, 2022
9681062
Merge pull request #2 from LittleLittleCloud/u/xiaoyun/addBinaryClass…
jordi1215 Jul 9, 2022
77db51c
Added the rest of the binary metrics at byGroup()
jordi1215 Jul 14, 2022
cc383e7
Fixed a typo in the comment
jordi1215 Jul 19, 2022
e0d4769
Started on GridSearch, finished implementing the first approach to ca…
jordi1215 Jul 19, 2022
048eaa8
Turned the moment class to an abstract class
jordi1215 Jul 27, 2022
e2e0352
Added signed weights, fixed ordering in Gamma
jordi1215 Jul 27, 2022
be1919d
Added assembly reference for the AutoML to gain access to different m…
jordi1215 Jul 27, 2022
c690290
fix sensitive feature column name bug, change default value for grid …
jordi1215 Jul 27, 2022
426385f
Created a trail runner for grid search
jordi1215 Jul 27, 2022
a9f07a9
Added AutoMLExperimentExtension to enable AutoML methods on gridsearch
jordi1215 Jul 27, 2022
168a808
Added row item lookup by columnname
jordi1215 Aug 3, 2022
4514678
Revert "Added AutoMLExperimentExtension to enable AutoML methods on g…
jordi1215 Aug 3, 2022
328f718
made serviceCollection internal to be accessed by AutoML extension in…
jordi1215 Aug 3, 2022
07e2cb0
Updated IMonitor for fairlearn
jordi1215 Aug 3, 2022
b857dc1
added FairnessTrialResulst for fairnessMetric
jordi1215 Aug 3, 2022
debd1e6
Revert "made serviceCollection internal to be accessed by AutoML exte…
jordi1215 Aug 3, 2022
373463e
Added an extension for AutoML experiment
jordi1215 Aug 3, 2022
edf913f
Added a Fairlearn AutoMLTuner
jordi1215 Aug 3, 2022
c633360
updated Project reference
jordi1215 Aug 3, 2022
e21f3f0
added a gridSearch test
jordi1215 Aug 3, 2022
2f4e111
Update BranchInfo.props
jordi1215 Aug 3, 2022
5d297ee
Fixed documentation
jordi1215 Aug 4, 2022
86b9ca4
Update abstract methods
jordi1215 Aug 4, 2022
ecb3ec2
Updated documentation and added the Bound method
jordi1215 Aug 4, 2022
c046e7f
Moved metric related files into the metric folder
jordi1215 Aug 4, 2022
0e0c015
Added user's gridLimit support
jordi1215 Aug 5, 2022
7e34554
Delete GridSearch.cs
jordi1215 Aug 5, 2022
918fdf7
added include Fairlearn.metric
jordi1215 Aug 5, 2022
7c65edb
added binary classification metric tests
jordi1215 Aug 5, 2022
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions Microsoft.ML.sln
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.CpuMath.Perfor
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.CpuMath.UnitTests", "test\Microsoft.ML.CpuMath.UnitTests\Microsoft.ML.CpuMath.UnitTests.csproj", "{E97D8B5A-3035-4D41-9B0D-77FF8FB8D132}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Microsoft.ML.FSharp.Tests", "test\Microsoft.ML.FSharp.Tests\Microsoft.ML.FSharp.Tests.fsproj", "{802233D6-8CC0-46AD-9F23-FEE1E9AED9B3}"
Copy link
Contributor

Choose a reason for hiding this comment

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

We need this and the associated Release/Debug info back for FSharp Tests

EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.ImageAnalytics", "src\Microsoft.ML.ImageAnalytics\Microsoft.ML.ImageAnalytics.csproj", "{00E38F77-1E61-4CDF-8F97-1417D4E85053}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.Mkl.Components", "src\Microsoft.ML.Mkl.Components\Microsoft.ML.Mkl.Components.csproj", "{A7222F41-1CF0-47D9-B80C-B4D77B027A61}"
Expand Down Expand Up @@ -153,7 +151,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.SearchSpace",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.SearchSpace.Tests", "test\Microsoft.ML.SearchSpace.Tests\Microsoft.ML.SearchSpace.Tests.csproj", "{A3E9F25F-2718-4FF9-A35A-54C232A847AB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.ML.AutoML.SourceGenerator", "tools-local\Microsoft.ML.AutoML.SourceGenerator\Microsoft.ML.AutoML.SourceGenerator.csproj", "{C804B990-390E-41D7-8FF1-6774495D70E2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.AutoML.SourceGenerator", "tools-local\Microsoft.ML.AutoML.SourceGenerator\Microsoft.ML.AutoML.SourceGenerator.csproj", "{C804B990-390E-41D7-8FF1-6774495D70E2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.Fairlearn", "src\Microsoft.ML.Fairlearn\Microsoft.ML.Fairlearn.csproj", "{2FB7A5CB-B41A-4A89-9B81-AFF24576DE99}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.ML.Fairlearn.Tests", "test\Microsoft.ML.Fairlearn.Tests\Microsoft.ML.Fairlearn.Tests.csproj", "{416E682A-3958-49B9-8693-14EA96967AD3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -379,14 +381,6 @@ Global
{E97D8B5A-3035-4D41-9B0D-77FF8FB8D132}.Release|Any CPU.Build.0 = Release|Any CPU
{E97D8B5A-3035-4D41-9B0D-77FF8FB8D132}.Release|x64.ActiveCfg = Release|Any CPU
{E97D8B5A-3035-4D41-9B0D-77FF8FB8D132}.Release|x64.Build.0 = Release|Any CPU
{802233D6-8CC0-46AD-9F23-FEE1E9AED9B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{802233D6-8CC0-46AD-9F23-FEE1E9AED9B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{802233D6-8CC0-46AD-9F23-FEE1E9AED9B3}.Debug|x64.ActiveCfg = Debug|Any CPU
{802233D6-8CC0-46AD-9F23-FEE1E9AED9B3}.Debug|x64.Build.0 = Debug|Any CPU
{802233D6-8CC0-46AD-9F23-FEE1E9AED9B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{802233D6-8CC0-46AD-9F23-FEE1E9AED9B3}.Release|Any CPU.Build.0 = Release|Any CPU
{802233D6-8CC0-46AD-9F23-FEE1E9AED9B3}.Release|x64.ActiveCfg = Release|Any CPU
{802233D6-8CC0-46AD-9F23-FEE1E9AED9B3}.Release|x64.Build.0 = Release|Any CPU
{00E38F77-1E61-4CDF-8F97-1417D4E85053}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00E38F77-1E61-4CDF-8F97-1417D4E85053}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00E38F77-1E61-4CDF-8F97-1417D4E85053}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -727,6 +721,22 @@ Global
{C804B990-390E-41D7-8FF1-6774495D70E2}.Release|Any CPU.Build.0 = Release|Any CPU
{C804B990-390E-41D7-8FF1-6774495D70E2}.Release|x64.ActiveCfg = Release|Any CPU
{C804B990-390E-41D7-8FF1-6774495D70E2}.Release|x64.Build.0 = Release|Any CPU
{2FB7A5CB-B41A-4A89-9B81-AFF24576DE99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2FB7A5CB-B41A-4A89-9B81-AFF24576DE99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FB7A5CB-B41A-4A89-9B81-AFF24576DE99}.Debug|x64.ActiveCfg = Debug|Any CPU
{2FB7A5CB-B41A-4A89-9B81-AFF24576DE99}.Debug|x64.Build.0 = Debug|Any CPU
{2FB7A5CB-B41A-4A89-9B81-AFF24576DE99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FB7A5CB-B41A-4A89-9B81-AFF24576DE99}.Release|Any CPU.Build.0 = Release|Any CPU
{2FB7A5CB-B41A-4A89-9B81-AFF24576DE99}.Release|x64.ActiveCfg = Release|Any CPU
{2FB7A5CB-B41A-4A89-9B81-AFF24576DE99}.Release|x64.Build.0 = Release|Any CPU
{416E682A-3958-49B9-8693-14EA96967AD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{416E682A-3958-49B9-8693-14EA96967AD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{416E682A-3958-49B9-8693-14EA96967AD3}.Debug|x64.ActiveCfg = Debug|Any CPU
{416E682A-3958-49B9-8693-14EA96967AD3}.Debug|x64.Build.0 = Debug|Any CPU
{416E682A-3958-49B9-8693-14EA96967AD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{416E682A-3958-49B9-8693-14EA96967AD3}.Release|Any CPU.Build.0 = Release|Any CPU
{416E682A-3958-49B9-8693-14EA96967AD3}.Release|x64.ActiveCfg = Release|Any CPU
{416E682A-3958-49B9-8693-14EA96967AD3}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -759,7 +769,6 @@ Global
{3E4ABF07-7970-4BE6-B45B-A13D3C397545} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4}
{7333EDEF-4144-405C-A5EC-6F42201857D8} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4}
{E97D8B5A-3035-4D41-9B0D-77FF8FB8D132} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4}
{802233D6-8CC0-46AD-9F23-FEE1E9AED9B3} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4}
{00E38F77-1E61-4CDF-8F97-1417D4E85053} = {09EADF06-BE25-4228-AB53-95AE3E15B530}
{A7222F41-1CF0-47D9-B80C-B4D77B027A61} = {09EADF06-BE25-4228-AB53-95AE3E15B530}
{570A0B8A-5463-44D2-8521-54C0CA4CACA9} = {09EADF06-BE25-4228-AB53-95AE3E15B530}
Expand Down Expand Up @@ -803,6 +812,8 @@ Global
{A8F4F08F-1F9D-4AAE-8C8D-502CDBBDE7D3} = {09EADF06-BE25-4228-AB53-95AE3E15B530}
{A3E9F25F-2718-4FF9-A35A-54C232A847AB} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4}
{C804B990-390E-41D7-8FF1-6774495D70E2} = {7F13E156-3EBA-4021-84A5-CD56BA72F99E}
{2FB7A5CB-B41A-4A89-9B81-AFF24576DE99} = {09EADF06-BE25-4228-AB53-95AE3E15B530}
{416E682A-3958-49B9-8693-14EA96967AD3} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {41165AF1-35BB-4832-A189-73060F82B01D}
Expand Down
4 changes: 2 additions & 2 deletions eng/BranchInfo.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
<PropertyGroup Condition="'$(IsStableProject)' == 'true'">
<MajorVersion>2</MajorVersion>
<MinorVersion>0</MinorVersion>
<PatchVersion>0</PatchVersion>
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty sure this was already said, but this file change needs to be reverted.

<PatchVersion>1</PatchVersion>
Copy link
Member

Choose a reason for hiding this comment

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

Can you exclude the change of BranchInfo.

</PropertyGroup>
<PropertyGroup Condition="'$(IsStableProject)' != 'true'">
<MajorVersion>0</MajorVersion>
<MinorVersion>20</MinorVersion>
<PatchVersion>0</PatchVersion>
<PatchVersion>1</PatchVersion>
</PropertyGroup>
</Project>
17 changes: 17 additions & 0 deletions src/Microsoft.Data.Analysis/DataFrameRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ public object this[int index]
}
}

/// <summary>
/// An indexer to return the value at <paramref name="columnName"/>.
/// </summary>
/// <param name="columnName">The name of the column that corresponds to the return value</param>
/// <returns>The value at this <paramref name="columnName"/>.</returns>
public object this[string columnName]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this just to have a way to get the data without needing to specify the type?

{
get
{
return _dataFrame[columnName][_rowIndex];
}
set
{
_dataFrame[columnName][_rowIndex] = value;
}
}

/// <summary>
/// A simple string representation of the values in this row
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.ML.AutoML/Assembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
[assembly: InternalsVisibleTo("mlnet.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb")]
[assembly: InternalsVisibleTo("Benchmark, PublicKey=00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb")]
[assembly: InternalsVisibleTo("Microsoft.ML.CodeGenerator, PublicKey=00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb")]
[assembly: InternalsVisibleTo("Microsoft.ML.Fairlearn, PublicKey=00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb")]
[assembly: InternalsVisibleTo("Microsoft.ML.CodeGenerator.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb")]
[assembly: InternalsVisibleTo("Microsoft.ML.ModelBuilder, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("Microsoft.ML.ModelBuilder.AutoMLService, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public AutoMLExperiment SetEvaluateMetric(RegressionMetric metric, string labelC
return this;
}

internal IServiceCollection ServiceCollection { get => _serviceCollection; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Please include a space between this and the comments below.

/// <summary>
/// Run experiment and return the best trial result synchronizely.
/// </summary>
Expand Down
9 changes: 8 additions & 1 deletion src/Microsoft.ML.AutoML/AutoMLExperiment/IMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ public void ReportBestTrial(TrialResult result)

public void ReportCompletedTrial(TrialResult result)
{
_logger.Info($"Update Completed Trial - Id: {result.TrialSettings.TrialId} - Metric: {result.Metric} - Pipeline: {result.TrialSettings.Pipeline} - Duration: {result.DurationInMilliseconds}");
if (result is FairnessTrialResult fResult)
{ //TODO: now we are assuming the higher the raw metric the better and the lower the fairness metric the better. If we have a raw metric that needs to be minimized then this should change
_logger.Info($"Update Completed Trial - Id: {result.TrialSettings.TrialId} - Raw Metric: {result.Metric + fResult.FairnessMetric} - Fairness Metric: {-fResult.FairnessMetric} - Total Metric: {result.Metric} - Pipeline: {result.TrialSettings.Pipeline} - Duration: {result.DurationInMilliseconds}");
}
else
{
_logger.Info($"Update Completed Trial - Id: {result.TrialSettings.TrialId} - Metric: {result.Metric} - Pipeline: {result.TrialSettings.Pipeline} - Duration: {result.DurationInMilliseconds}");
}
_completedTrials.Add(result);
}

Expand Down
5 changes: 5 additions & 0 deletions src/Microsoft.ML.AutoML/AutoMLExperiment/TrialResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ public class TrialResult

public double DurationInMilliseconds { get; set; }
}

public class FairnessTrialResult : TrialResult
{
public double FairnessMetric { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/Microsoft.ML.AutoML/AutoMLExperiment/TrialRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public TrialResult Run(TrialSettings settings, IServiceProvider provider)
var eval = model.Transform(datasetSettings.TestDataset);
var metrics = _context.BinaryClassification.EvaluateNonCalibrated(eval, metricSettings.LabelColumn, predictedLabelColumnName: metricSettings.PredictedColumn);

// now we just randomly pick a model, but a better way is to provide option to pick a model which score is the cloest to average or the best.
// now we just randomly pick a model, but a better way is to provide option to pick a model which score is the closest to average or the best.
var metric = metricSettings.Metric switch
{
BinaryClassificationMetric.PositivePrecision => metrics.PositivePrecision,
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.AutoML/AutoMLExperiment/TunerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ITuner CreateTuner(TrialSettings settings)
}
}

internal class GridSearchTunerFactory : ITunerFactory
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, what is the reason for the change?

public class GridSearchTunerFactory : ITunerFactory
{
private readonly IServiceProvider _provider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public AzureAttachModelCodeGenerator(Pipeline pipeline, ColumnInferenceResults c
OnnxRuntimePackageVersion = _settings.OnnxRuntimePackageVersion,
Target = _settings.Target,
}.TransformText(),
Name = $"{ _settings.OutputName }.Model.csproj",
Name = $"{_settings.OutputName}.Model.csproj",
};

ConsumeModel = new CSharpCodeFile()
Expand Down
45 changes: 45 additions & 0 deletions src/Microsoft.ML.Fairlearn/AutoML/AutoMLExperimentExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.ML.AutoML;
using Microsoft.ML.Fairlearn.reductions;

namespace Microsoft.ML.Fairlearn.AutoML
{
/// <summary>
/// An internal class that holds the gridLimit value to conduct gridsearch.
/// Needed to pass the value into the AutoMLExperiment as a singleton
/// </summary>
internal class GridLimit
{
public float Value { get; set; }
}
/// <summary>
/// An extension class used to add more options to the Fairlearn girdsearch experiment
/// </summary>
public static class AutoMLExperimentExtension
{
public static AutoMLExperiment SetBinaryClassificationMoment(this AutoMLExperiment experiment, ClassificationMoment moment)
{
experiment.ServiceCollection.AddSingleton(moment);
experiment.SetTunerFactory<CostFrugalWithLambdaTunerFactory>();

return experiment;
}

public static AutoMLExperiment SetGridLimit(this AutoMLExperiment experiment, float gridLimit)
Copy link
Member

Choose a reason for hiding this comment

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

Other than gridLimit, can you add other control parameters as well, for example

  • isNegativeAllowed
{
var gridLimitObject = new GridLimit();
gridLimitObject.Value = gridLimit;
experiment.ServiceCollection.AddSingleton(gridLimitObject);
experiment.SetTunerFactory<CostFrugalWithLambdaTunerFactory>();

return experiment;
}
}
}
43 changes: 43 additions & 0 deletions src/Microsoft.ML.Fairlearn/AutoML/TunerFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.ML;
using Microsoft.ML.AutoML;
using Microsoft.ML.Fairlearn.reductions;

namespace Microsoft.ML.Fairlearn.AutoML
{
internal class CostFrugalWithLambdaTunerFactory : ITunerFactory
{
private readonly IServiceProvider _provider;
private readonly ClassificationMoment _moment;
private readonly MLContext _context;
private readonly float _gridLimit = 10f;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a need to set this when you override it in the constructor on line 27?


public CostFrugalWithLambdaTunerFactory(IServiceProvider provider)
{
_provider = provider;
_moment = provider.GetService<ClassificationMoment>();
_context = provider.GetService<MLContext>();
_gridLimit = provider.GetService<GridLimit>().Value;
}

public ITuner CreateTuner(TrialSettings settings)
{
var experimentSetting = _provider.GetService<AutoMLExperiment.AutoMLExperimentSettings>();
var searchSpace = settings.Pipeline.SearchSpace;
var isMaximize = experimentSetting.IsMaximizeMetric;

var lambdaSearchSpace = Utilities.GenerateBinaryClassificationLambdaSearchSpace(_context, _moment, gridLimit: _gridLimit);
searchSpace["_lambda_search_space"] = lambdaSearchSpace;
var initParameter = searchSpace.SampleFromFeatureSpace(searchSpace.Default);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need this line? Doesn't look like initParameter is being used anywhere.


return new RandomSearchTuner(searchSpace);
}
}
}
24 changes: 24 additions & 0 deletions src/Microsoft.ML.Fairlearn/FairlearnCatalog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.Text;
using Microsoft.ML.AutoML;

namespace Microsoft.ML.Fairlearn
{
public sealed class FairlearnCatalog
{
private readonly MLContext _context;
public FairlearnMetricCatalog Metric;

internal FairlearnCatalog(MLContext context)
{
this._context = context;
this.Metric = new FairlearnMetricCatalog(context);
}

}
}
23 changes: 23 additions & 0 deletions src/Microsoft.ML.Fairlearn/MLContextExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.ML;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: space between comment and first using.


namespace Microsoft.ML.Fairlearn
{
/// <summary>
/// Class containing AutoML extension methods to <see cref="MLContext"/>
/// </summary>
public static class MLContextExtension
{
/// <summary>
/// Returns a catalog of all possible Fairlearn operations.
/// </summary>
/// <param name="mlContext"><see cref="MLContext"/> instance.</param>
/// <returns>A catalog of all possible AutoML operations.</returns>
public static FairlearnCatalog Fairlearn(this MLContext mlContext)
{
return new FairlearnCatalog(mlContext);
}
}
}
27 changes: 27 additions & 0 deletions src/Microsoft.ML.Fairlearn/Microsoft.ML.Fairlearn.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tested building the nuget and using it just to make sure it works?

<Import Project="$(RepoRoot)eng/pkg/Pack.props" />

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IncludeInPackage>Microsoft.ML.Fairlearn</IncludeInPackage>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.Data.Analysis\Microsoft.Data.Analysis.csproj" />
<ProjectReference Include="..\Microsoft.ML.AutoML\Microsoft.ML.AutoML.csproj" />
<ProjectReference Include="..\Microsoft.ML.Core\Microsoft.ML.Core.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
<ProjectReference Include="..\Microsoft.ML.SearchSpace\Microsoft.ML.SearchSpace.csproj">
<PrivateAssets>all</PrivateAssets>
<IncludeInNuget>true</IncludeInNuget>
</ProjectReference>
<ProjectReference Include="..\Microsoft.ML\Microsoft.ML.csproj" />

<ProjectReference Include="..\Microsoft.ML.Data\Microsoft.ML.Data.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>

</ItemGroup>

</Project>
Loading