Skip to content
Permalink
Browse files

bugfixes

  • Loading branch information...
DXSdata committed Nov 28, 2017
1 parent 160a32f commit 15162e171d68685d1496b30c4ceafef851942cb9
Showing with 15 additions and 5 deletions.
  1. +7 −2 nBayes/Analyzer.cs
  2. +6 −1 nBayes/FileIndex.cs
  3. +2 −2 nBayes/nBayes.csproj
@@ -7,13 +7,15 @@ public class Analyzer
private float I = 0;
private float invI = 0;

private float _prediction = float.NaN;
private float _prediction;

private Entry item;
private Index first;
private Index second;
private float tolerance;

bool calculated = false;

public Analyzer(Entry item, Index first, Index second, float tolerance = .05f)
{
this.item = item;
@@ -26,7 +28,7 @@ public float Prediction
{
get
{
if (float.IsNaN(_prediction))
if (!calculated)
_prediction = GetPrediction();

return _prediction;
@@ -69,6 +71,9 @@ private float GetPrediction()
}

float prediction = CombineProbability();

calculated = true;

return prediction;
}

@@ -33,7 +33,12 @@ public void Open()
using (Stream stream = File.OpenRead(this.filePath))
{
XmlSerializer serializer = new XmlSerializer(typeof(IndexTable<string, int>));
index.table = serializer.Deserialize(stream) as IndexTable<string, int>;
try
{
index.table = serializer.Deserialize(stream) as IndexTable<string, int>;
}
catch(InvalidOperationException) //e.g. if file empty
{}
}
}
}
@@ -8,7 +8,7 @@
<StartupObject />

<PackageId>nBayes.DXSdata</PackageId>
<PackageVersion>3.0.0</PackageVersion>
<PackageVersion>3.0.1</PackageVersion>
<Authors>DXSdata</Authors>
<Description>Fork of joelmartinez/nBayes, ported for usage with .NET Core / .NET Standard</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
@@ -19,7 +19,7 @@ Changed framework for the sample project back from netstandard to netcoreapp, ot
<PackageTags>Bayes nBayes classifier .NET Core Standard DXSdata</PackageTags>
<PackageProjectUrl>http://www.dxsdata.com/2017/07/bayes-classifier-library-for-net-core/</PackageProjectUrl>
<Title>nBayes for .NET Core</Title>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageIconUrl></PackageIconUrl>
<RepositoryUrl>https://github.com/DXSdata/nBayes</RepositoryUrl>

0 comments on commit 15162e1

Please sign in to comment.
You can’t perform that action at this time.