Mutual information feature selection scores
@rogancarr @asthana86 From 0.7 the MutualInformationFeatureSelectionUtils.Train is removed, i was using to understand the score for the columns in the Mutual feature selection.
Can you please include the same in upcoming releases i need to understand the scores for the columns in the Mutual feature selection. Something similar to what i see in Azure ML below.

Hi @Vijay27anand! Can you give some sample code to show me what you were doing? I will try to find a workaround.
@rogancarr find below the sample code what i am trying to do, i need to find all the columns names that has the mutual information on the selected column label, and order them accordingly.
string dataFilePath = $"C:\\Application.csv";
int index = comboBox1.SelectedIndex; //Column index for the selected label column.
List<string[]> lines = File.ReadAllLines(dataFilePath).Select(a => a.Split(',')).ToList();
var header = lines[0];
var ml = new MLContext();
TextLoader reader = null;
reader = ml.Data.TextReader(new TextLoader.Arguments()
{
Separator = ",",
HasHeader = true,
Column = new[]
{
new TextLoader.Column("Label", DataKind.R4, index),
new TextLoader.Column("Features", DataKind.R4, new [] { new TextLoader.Range(1, index - 1),new TextLoader.Range(index + 1, header.Count()-1) })
}
});
var data = reader.Read(dataFilePath);
var mlContext = new MLContext();
Microsoft.ML.Runtime.IHostEnvironment host = null;
host = new ConsoleEnvironment(seed: 1);
float[][] output = MutualInformationFeatureSelectionUtils.Train(host.Register("host"), data, "Label", new string[] { "Features" }, 5);
float[] result = output[0]; // output gets all the columns with score that has mutual information scores
Applications app = new Applications();
List<ApplicationColumn> columnlist = new List<ApplicationColumn>();
int j = 0;
for (int i = 1; i < header.Count(); i++)
{
if (i != comboBox1.SelectedIndex)
{
ApplicationColumn column = new ApplicationColumn();
column.ColumnName = header[i]; //Get the columns names and score
column.Score = result[(i - 1) - j];
columnlist.Add(column);
}
else
{
j = 1;
}
}
List<ApplicationColumn> SortedList = columnlist.OrderByDescending(o => o.Score).ToList(); //Sort the columns names and score that has mutual information with label.
dataGridView1.DataSource = SortedList; //display the columns that has higher score of mutual informations with the selected column label.
Hi @Vijay27anand ,
The APIs for MutualInformationFeatureSelectionUtils were made internal because they aren't part of the supported APIs for ML.NET 1.0. However, the Mutual InformationFeatureSelectionTransform can be used to select the top K features based on mutual information (see this sample). Is this enough to do what you need, or do you actually need a sorted list and / or the scores? If it's the latter, we can file an issue to get this information out.
@rogancarr : I would like use of the raw scores.
I'm looking to automate the detection of Label leakage in datasets & as featurized in ML.NET pipelines. There are few methods of this; I'm hoping to run simple correlation with the raw dataset features and also the features after the ML pipeline. This could be done w/ the MutualInformationFeatureSelection. Another route is producing the full feature importance using the various explainability tools in ML.NET.
Hi @Vijay27anand ,
The APIs for
MutualInformationFeatureSelectionUtilswere madeinternalbecause they aren't part of the supported APIs for ML.NET 1.0. However, theMutual InformationFeatureSelectionTransformcan be used to select the top K features based on mutual information (see this sample). Is this enough to do what you need, or do you actually need a sorted list and / or the scores? If it's the latter, we can file an issue to get this information out.
@rogancarr i actually need a sorted list and the scores the top K features might not help me, can you please file an issue to get this information.
I opened #2328 and I'm going to close this issue. Thanks @Vijay27anand and @justinormont !