Skip to content

Commit

Permalink
Armemon/insights2 (#1012)
Browse files Browse the repository at this point in the history
* max and min insightsperslice, and tests

* got rid of unneccesssary function

* get indexes

* learn for stringinputtyype

* add learn implentation

Co-authored-by: Arslan Memon <armemon@microsoft.com>
  • Loading branch information
arslan9955 and Arslan Memon authored Jul 29, 2020
1 parent e58135b commit b59d447
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 4 deletions.
63 changes: 59 additions & 4 deletions src/Microsoft.InsightsGenerator/SigGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,81 @@ public SignatureGeneratorResult Learn()

for (var i = 0; i < Table.TransformedColumnNames.Length; i++)
{
if (Table.TransformedColumnNames.Contains("input_g"))
if (Table.TransformedColumnNames[i].Contains("input_g"))
{
stringInputIndexes.Add(i);
}
if (Table.TransformedColumnNames.Contains("input_t"))
if (Table.TransformedColumnNames[i].Contains("input_t"))
{
timeInputIndexes.Add(i);
}
if (Table.TransformedColumnNames.Contains("slicer"))
if (Table.TransformedColumnNames[i].Contains("slicer"))
{
slicerIndexes.Add(i);
}
if (Table.TransformedColumnNames.Contains("output"))
if (Table.TransformedColumnNames[i].Contains("output"))
{
outputIndexes.Add(i);
}
}

foreach (int stringIndex in stringInputIndexes)
{
foreach (int outputIndex in outputIndexes)
{
ExecuteStringInputInsights(stringIndex, outputIndex);
foreach (int slicerIndex in slicerIndexes)
{
ExecuteStringInputSlicerInsights(stringIndex, outputIndex, slicerIndex);
}
}
}

return Result;
}


public void ExecuteStringInputInsights(int inputCol, int outputCol)
{
var n = Table.Cells.Length;
if (Table.Cells.Length >8) {
n = 3;
}
if (Table.Cells.Length > 50)
{
n=5;
}

OverallAverageInsights(outputCol);
OverallBottomInsights(n, inputCol, outputCol);
OverallMaxInsights(outputCol);
OverallMinInsights(outputCol);
OverallSumInsights(outputCol);
OverallTopInsights(n, inputCol, outputCol);
}

public void ExecuteStringInputSlicerInsights(int inputCol, int outputCol, int slicerCol)
{
var n = Table.Cells.Length;
if (Table.Cells.Length > 8)
{
n = 3;
}
if (Table.Cells.Length > 50)
{
n = 5;
}

SlicedMaxInsights(slicerCol, outputCol);
SlicedAverageInsights(slicerCol, outputCol);
SlicedBottomInsights(n, inputCol, slicerCol, outputCol);
SlicedSumInsights(slicerCol, outputCol);
SlicedPercentageInsights(slicerCol, outputCol);
SlicedSumInsights(slicerCol, outputCol);
SlicedMinInsights(slicerCol, outputCol);
SlicedTopInsights(n, inputCol, slicerCol, outputCol);
}

public void OverallTopInsights(long n, int inputColumn, int outputColumn)
{
List<string> insight = new List<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ public void MaxAndMinSlicedInsightsTest()
}
}

[Fact]
public void LearnTest()
{
SignatureGenerator sigGen = new SignatureGenerator(sampleDataArray(false));
sigGen.Learn();
foreach (List<string> list in sigGen.Result.Insights)
{
foreach (string str in list)
{
Console.WriteLine(str);
}
}
}
public DataArray sampleDataArray(bool timeinput)
{
DataArray sample = new DataArray();
Expand Down Expand Up @@ -251,7 +264,9 @@ Japan 1 Category5
sampleRowList.Add(row.Split(" "));
}

var columnTypes = new string[] { "input_g_1", "output_1", "slicer_1" };
sample.Cells = sampleRowList.ToArray();
sample.TransformedColumnNames = columnTypes;
return sample;
}
}
Expand Down

0 comments on commit b59d447

Please sign in to comment.