-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from bonsai-rx/visualizers-refactor
Refactor visualizers package to improve separation between package specific visualizers and reusable visualizers
- Loading branch information
Showing
23 changed files
with
380 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 2 additions & 8 deletions
10
....Visualizers/Bonsai.ML.Visualizers.csproj → src/Bonsai.ML.Design/Bonsai.ML.Design.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Title>Bonsai.ML.Visualizers</Title> | ||
<Title>Bonsai.ML.Design</Title> | ||
<Description>A package for the Bonsai visual programming language.</Description> | ||
<PackageTags>Bonsai Rx ML Machine Learning Visualizers</PackageTags> | ||
<PackageTags>Bonsai Rx ML Machine Learning Design</PackageTags> | ||
<TargetFrameworks>net472</TargetFrameworks> | ||
<UseWindowsForms>true</UseWindowsForms> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Bonsai.Core" Version="2.8.1" /> | ||
<PackageReference Include="Bonsai.Design" Version="2.8.0" /> | ||
<PackageReference Include="Bonsai.Vision.Design" Version="2.8.1" /> | ||
<PackageReference Include="MathNet.Numerics" Version="5.0.0" /> | ||
<PackageReference Include="OxyPlot.Core" Version="2.1.2" /> | ||
<PackageReference Include="OxyPlot.WindowsForms" Version="2.1.2" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Bonsai.ML.LinearDynamicalSystems\Bonsai.ML.LinearDynamicalSystems.csproj" /> | ||
<ProjectReference Include="..\Bonsai.ML.HiddenMarkovModels\Bonsai.ML.HiddenMarkovModels.csproj" /> | ||
</ItemGroup> | ||
</Project> |
2 changes: 1 addition & 1 deletion
2
src/Bonsai.ML.Visualizers/ColorPalette.cs → src/Bonsai.ML.Design/ColorPalette.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Bonsai.ML.Visualizers | ||
namespace Bonsai.ML.Design | ||
{ | ||
internal enum ColorPalette | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using MathNet.Numerics.LinearAlgebra; | ||
using System; | ||
|
||
namespace Bonsai.ML.Design | ||
{ | ||
/// <summary> | ||
/// Provides helper methods to compute ellipse parameters from a covariance matrix. | ||
/// </summary> | ||
public static class EllipseHelper | ||
{ | ||
/// <summary> | ||
/// Computes the ellipse parameters from the specified covariance matrix. | ||
/// </summary> | ||
/// <param name="xVar">The variance of the x axis.</param> | ||
/// <param name="yVar">The variance of the y axis.</param> | ||
/// <param name="xyCov">The covariance between the x and y axes.</param> | ||
public static EllipseParameters GetEllipseParameters(double xVar, double yVar, double xyCov) | ||
{ | ||
var covariance = Matrix<double>.Build.DenseOfArray(new double[,] { | ||
{ | ||
xVar, | ||
xyCov | ||
}, | ||
{ | ||
xyCov, | ||
yVar | ||
}, | ||
}); | ||
|
||
var evd = covariance.Evd(); | ||
var evals = evd.EigenValues.Real(); | ||
evals = evals.PointwiseAbsoluteMaximum(0); | ||
var evecs = evd.EigenVectors; | ||
|
||
double angle = Math.Atan2(evecs[1, 0], evecs[0, 0]); | ||
|
||
return new EllipseParameters | ||
{ | ||
Angle = angle, | ||
MajorAxis = Math.Sqrt(evals[0]), | ||
MinorAxis = Math.Sqrt(evals[1]), | ||
}; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Represents the parameters of an ellipse. | ||
/// </summary> | ||
public class EllipseParameters | ||
{ | ||
/// <summary> | ||
/// Gets or sets the angle of the ellipse. | ||
/// </summary> | ||
public double Angle { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the major axis of the ellipse. | ||
/// </summary> | ||
public double MajorAxis { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the minor axis of the ellipse. | ||
/// </summary> | ||
public double MinorAxis { get; set; } | ||
} | ||
} |
Oops, something went wrong.