Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4db51df
Update editor config
mdabros Feb 15, 2025
1993737
Fix naming violations
mdabros Feb 15, 2025
c38e972
Rename
mdabros Feb 15, 2025
5387e1d
Use nameof
mdabros Feb 15, 2025
e471f1a
Use collection expression
mdabros Feb 15, 2025
6a6530b
Use IsEmpty
mdabros Feb 15, 2025
9851422
collection expression
mdabros Feb 15, 2025
978e859
Fix
mdabros Feb 15, 2025
0c4d86d
Simplify
mdabros Feb 15, 2025
439ffac
Fix
mdabros Feb 15, 2025
24fe10e
Fix
mdabros Feb 15, 2025
436854c
Add roslyn analyzers and formatting.Analyzers
mdabros Feb 15, 2025
3106962
Add braces
mdabros Feb 15, 2025
ea7b049
Use collection expression
mdabros Feb 15, 2025
50506a0
Simplify
mdabros Feb 15, 2025
fbff8f3
Remove blank lines
mdabros Feb 15, 2025
9abbf29
Use trailing comma
mdabros Feb 15, 2025
6cb49e9
Remove empty statement
mdabros Feb 15, 2025
6423b72
Use elemental acess
mdabros Feb 15, 2025
1073bc1
Use elemental access
mdabros Feb 15, 2025
36ec05e
Simplify
mdabros Feb 15, 2025
8a8579c
Conditional acess
mdabros Feb 15, 2025
32a71d3
Combine
mdabros Feb 15, 2025
0662105
Use compund
mdabros Feb 15, 2025
b29db0b
Simplify
mdabros Feb 15, 2025
15e8aa7
Remove blank line
mdabros Feb 15, 2025
37a6f1a
Add
mdabros Feb 15, 2025
ba82ccb
Remove trainling white space
mdabros Feb 15, 2025
5698f2d
REmove
mdabros Feb 15, 2025
ebc418d
Properties
mdabros Feb 15, 2025
59062c6
Use operatpr
mdabros Feb 15, 2025
fbac096
Simplify
mdabros Feb 15, 2025
eec7d5e
Simplify
mdabros Feb 15, 2025
31f5f06
Remove empty summary
mdabros Feb 15, 2025
6265608
Remove braces
mdabros Feb 15, 2025
acc29a9
Remove unecesarry
mdabros Feb 15, 2025
3d8cc83
Use appendformat
mdabros Feb 15, 2025
cd39b2f
Simplify
mdabros Feb 15, 2025
bf4c21e
Refactor
mdabros Feb 15, 2025
d3ab4c1
Simplify
mdabros Feb 15, 2025
9261258
Summary
mdabros Feb 15, 2025
28f37fd
Trailing comma
mdabros Feb 15, 2025
a7457d6
Simplify
mdabros Feb 15, 2025
90266dc
Join string expressions
mdabros Feb 15, 2025
bba366d
Disable warning
mdabros Feb 15, 2025
b6fdbf0
Line after usings
mdabros Feb 15, 2025
f5e4b6f
Simplify
mdabros Feb 15, 2025
c3f77a8
usings
mdabros Feb 15, 2025
7b80f18
Simplify
mdabros Feb 15, 2025
201257d
supress
mdabros Feb 15, 2025
67f5285
Fix tests
mdabros Feb 15, 2025
8f22aac
Disable data
mdabros Feb 15, 2025
334a6ac
Try reducing requirements during optimization to get results further …
mdabros Feb 15, 2025
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
Prev Previous commit
Next Next commit
Fix
  • Loading branch information
mdabros committed Feb 15, 2025
commit 24fe10ed27702eb20f57472a39ebe834f8b20801
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public abstract class ClassificationImpurityCalculator
/// </summary>
protected double m_weightedRight = 0.0;

internal TargetCounts m_weightedTargetCount = new();
internal TargetCounts m_weightedTargetCountLeft = new();
internal TargetCounts m_weightedTargetCountRight = new();
internal TargetCounts WeightedTargetCount = new();
internal TargetCounts WeightedTargetCountLeft = new();
internal TargetCounts WeightedTargetCountRight = new();

/// <summary>
///
Expand Down Expand Up @@ -96,9 +96,9 @@ public void Init(double[] targetNames, double[] targets, double[] weights, Inter
m_targetIndexOffSet *= -1;
}

m_weightedTargetCount.Reset(m_maxTargetNameIndex, m_targetIndexOffSet);
m_weightedTargetCountLeft.Reset(m_maxTargetNameIndex, m_targetIndexOffSet);
m_weightedTargetCountRight.Reset(m_maxTargetNameIndex, m_targetIndexOffSet);
WeightedTargetCount.Reset(m_maxTargetNameIndex, m_targetIndexOffSet);
WeightedTargetCountLeft.Reset(m_maxTargetNameIndex, m_targetIndexOffSet);
WeightedTargetCountRight.Reset(m_maxTargetNameIndex, m_targetIndexOffSet);

var w = 1.0;
var weightsPresent = m_weights.Length != 0;
Expand All @@ -113,7 +113,7 @@ public void Init(double[] targetNames, double[] targets, double[] weights, Inter
w = weights[i];

var targetIndex = (int)targets[i];
m_weightedTargetCount[targetIndex] += w;
WeightedTargetCount[targetIndex] += w;

m_weightedTotal += w;
}
Expand All @@ -132,8 +132,8 @@ public void Reset()
m_weightedLeft = 0.0;
m_weightedRight = m_weightedTotal;

m_weightedTargetCountLeft.Clear();
m_weightedTargetCountRight.SetCounts(m_weightedTargetCount);
WeightedTargetCountLeft.Clear();
WeightedTargetCountRight.SetCounts(WeightedTargetCount);
}

/// <summary>
Expand Down Expand Up @@ -168,8 +168,8 @@ public void UpdateIndex(int newPosition)
w = m_weights[i];

var targetIndex = (int)m_targets[i];
m_weightedTargetCountLeft[targetIndex] += w;
m_weightedTargetCountRight[targetIndex] -= w;
WeightedTargetCountLeft[targetIndex] += w;
WeightedTargetCountRight[targetIndex] -= w;

w_diff += w;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public override ChildImpurities ChildImpurities()
foreach (var targetValue in m_targetNames)
{
var targetIndex = (int)targetValue;
var leftCount = m_weightedTargetCountLeft[targetIndex];
var rightCount = m_weightedTargetCountRight[targetIndex];
var leftCount = WeightedTargetCountLeft[targetIndex];
var rightCount = WeightedTargetCountRight[targetIndex];

giniLeft += leftCount * leftCount;
giniRight += rightCount * rightCount;
Expand All @@ -52,7 +52,7 @@ public override double NodeImpurity()

foreach (var targetValue in m_targetNames)
{
var value = m_weightedTargetCount[(int)targetValue];
var value = WeightedTargetCount[(int)targetValue];
gini += value * value;
}

Expand Down Expand Up @@ -86,7 +86,7 @@ public override double LeafValue()

foreach (var targetValue in m_targetNames)
{
var value = m_weightedTargetCount[(int)targetValue];
var value = WeightedTargetCount[(int)targetValue];
if (value > maxWeight)
{
maxWeight = value;
Expand All @@ -110,7 +110,7 @@ public override double[] LeafProbabilities()
for (var i = 0; i < m_targetNames.Length; i++)
{
var targetValue = (int)m_targetNames[i];
var targetProbability = (m_weightedTargetCount[targetValue] + 1) * probabilityFactor;
var targetProbability = (WeightedTargetCount[targetValue] + 1) * probabilityFactor;
probabilities[i] = targetProbability;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public double[] Predict(F64Matrix observations)
/// <returns></returns>
public Dictionary<string, double> GetVariableImportance(Dictionary<string, int> featureNameToIndex)
{
var m_rawVariableImportance = GetRawVariableImportance();
var max = m_rawVariableImportance.Max();
var rawVariableImportance = GetRawVariableImportance();
var max = rawVariableImportance.Max();

var scaledVariableImportance = m_rawVariableImportance
var scaledVariableImportance = rawVariableImportance
.Select(v => (v / max) * 100.0)
.ToArray();

Expand Down
7 changes: 4 additions & 3 deletions src/SharpLearning.Neural/Layers/BatchNormalizationLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public Matrix<float> Backward(Matrix<float> delta)
var diff_src = m_delta;
var diff_scaleshift = m_scaleGradients;

#pragma warning disable IDE1006 // Naming Styles
var N = diff_src.RowCount;
var C = Depth;
var H = Height;
Expand Down Expand Up @@ -136,7 +137,7 @@ public Matrix<float> Backward(Matrix<float> delta)
diff_src.Data()[diffSrcIndex] *= gamma * variance;
}
});

#pragma warning restore IDE1006 // Naming Styles
return m_delta;
}

Expand All @@ -151,7 +152,7 @@ public Matrix<float> Forward(Matrix<float> input)

var src = input;
var dst = OutputActivations.Data();

#pragma warning disable IDE1006 // Naming Styles
var N = input.RowCount; // number of items in mini batch
var C = Depth;
var H = Height;
Expand Down Expand Up @@ -197,7 +198,7 @@ public Matrix<float> Forward(Matrix<float> input)
var bias = Bias[c];
dst[d_off] = scale * (src.Data()[d_off] - mean) * variance + bias;
}

#pragma warning restore IDE1006 // Naming Styles
if (is_training)
{
MovingAverageMeans[c] = MovingAverage(MovingAverageMeans[c], mean);
Expand Down