diff --git a/.gitignore b/.gitignore
index 8ccd396f..aea143bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,7 @@ encog-core-cs/bin/
encog-core-cs/obj/
encog-core-test/bin/
encog-core-test/obj/
+_NCrunch_encog-core-cs/
encog-core-cs.5.1.ReSharper.user
EncogCmd/VSdoc/EncogCmd.hhc
diff --git a/ConsoleExamples/ConsoleExamples.v2.ncrunchproject b/ConsoleExamples/ConsoleExamples.v2.ncrunchproject
new file mode 100644
index 00000000..ad562c2d
--- /dev/null
+++ b/ConsoleExamples/ConsoleExamples.v2.ncrunchproject
@@ -0,0 +1,25 @@
+
+ 1000
+ false
+ false
+ false
+ true
+ false
+ false
+ false
+ false
+ false
+ true
+ true
+ false
+ true
+ true
+ true
+ 60000
+
+
+
+ AutoDetect
+ STA
+ x86
+
\ No newline at end of file
diff --git a/encog-core-cs.sln b/encog-core-cs.sln
index e3a192d1..adc9fb7b 100644
--- a/encog-core-cs.sln
+++ b/encog-core-cs.sln
@@ -1,6 +1,8 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.30501.0
+MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "encog-core-cs", "encog-core-cs\encog-core-cs.csproj", "{AC6FADF9-0904-4EBD-B22C-1C787C7E7A95}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleExamples", "ConsoleExamples\ConsoleExamples.csproj", "{A65A5878-6336-4ACF-9C40-540F8FAF2CC7}"
@@ -15,9 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProjectSection
EndProject
Global
- GlobalSection(TestCaseManagementSettings) = postSolution
- CategoryFile = encog-core-cs.vsmdi
- EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
@@ -61,4 +60,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(TestCaseManagementSettings) = postSolution
+ CategoryFile = encog-core-cs.vsmdi
+ EndGlobalSection
EndGlobal
diff --git a/encog-core-cs.v2.ncrunchsolution b/encog-core-cs.v2.ncrunchsolution
new file mode 100644
index 00000000..f8e4ffac
--- /dev/null
+++ b/encog-core-cs.v2.ncrunchsolution
@@ -0,0 +1,14 @@
+
+ 1
+ false
+ true
+ true
+ UseDynamicAnalysis
+ UseStaticAnalysis
+ UseStaticAnalysis
+ UseStaticAnalysis
+ UseStaticAnalysis
+ Run all tests automatically:BFRydWU=;Run all tests manually:BUZhbHNl;Run impacted tests automatically, others manually (experimental!):CklzSW1wYWN0ZWQ=;Run pinned tests automatically, others manually:CElzUGlubmVk
+
+
+
\ No newline at end of file
diff --git a/encog-core-cs/ML/Data/Basic/BasicMLData.cs b/encog-core-cs/ML/Data/Basic/BasicMLData.cs
index 5d9d210e..20bfaced 100644
--- a/encog-core-cs/ML/Data/Basic/BasicMLData.cs
+++ b/encog-core-cs/ML/Data/Basic/BasicMLData.cs
@@ -32,7 +32,7 @@ namespace Encog.ML.Data.Basic
/// data in an array.
///
[Serializable]
- public class BasicMLData: IMLDataModifiable
+ public class BasicMLData : IMLDataModifiable, IHasArithimeticOperations
{
protected double[] _data;
@@ -42,12 +42,12 @@ public class BasicMLData: IMLDataModifiable
/// The data to construct this object with.
public BasicMLData(double[] d, bool copy = true)
{
- if(copy)
- {
- _data = new double[d.Length];
- EngineArray.ArrayCopy(d, _data);
- }
- else _data = d;
+ if (copy)
+ {
+ _data = new double[d.Length];
+ EngineArray.ArrayCopy(d, _data);
+ }
+ else _data = d;
}
@@ -178,9 +178,15 @@ public IMLData Minus(IMLData o)
return result;
}
- public void CopyTo(double[] target, int targetIndex, int count)
- {
- EngineArray.ArrayCopy(_data, 0, target, targetIndex, count);
- }
- }
+ ///
+ /// Copies the source data to the target array at the specified index.
+ ///
+ ///
+ ///
+ /// The maximum number of items to copy.
+ public void CopyTo(double[] target, int targetIndex, int count)
+ {
+ EngineArray.ArrayCopy(_data, 0, target, targetIndex, count);
+ }
+ }
}
diff --git a/encog-core-cs/ML/Data/Basic/BasicMLDataCentroid.cs b/encog-core-cs/ML/Data/Basic/BasicMLDataCentroid.cs
index 143d93b6..d427f230 100644
--- a/encog-core-cs/ML/Data/Basic/BasicMLDataCentroid.cs
+++ b/encog-core-cs/ML/Data/Basic/BasicMLDataCentroid.cs
@@ -33,7 +33,7 @@ public class BasicMLDataCentroid : ICentroid
///
/// The value this centroid is based on.
///
- private readonly BasicMLData _value;
+ private readonly IMLDataModifiable _value;
///
/// How many items have been added to the centroid.
@@ -46,7 +46,7 @@ public class BasicMLDataCentroid : ICentroid
/// The object to base the centroid on.
public BasicMLDataCentroid(IMLData o)
{
- this._value = (BasicMLData)o.Clone();
+ this._value = (IMLDataModifiable)o.Clone();
_size = 1;
}
@@ -54,7 +54,7 @@ public BasicMLDataCentroid(IMLData o)
public void Add(IMLData d)
{
for (int i = 0; i < _value.Count; i++)
- _value.Data[i] = ((_value.Data[i] * _size + d[i]) / (_size + 1));
+ _value[i] = ((_value[i] * _size + d[i]) / (_size + 1));
_size++;
}
@@ -70,7 +70,7 @@ public void Remove(IMLData d)
///
public double Distance(IMLData d)
{
- IMLData diff = _value.Minus(d);
+ IMLData diff = Minus(_value, d);
double sum = 0.0;
for (int i = 0; i < diff.Count; i++)
@@ -78,5 +78,20 @@ public double Distance(IMLData d)
return Math.Sqrt(sum);
}
+
+ private static IMLData Minus(IMLDataModifiable a, IMLData b)
+ {
+ if (a.Count != b.Count)
+ {
+ throw new EncogError("Counts must match.");
+ }
+
+ var result = (IMLDataModifiable)Activator.CreateInstance(a.GetType(), a.Count);
+
+ for (int i = 0; i < a.Count; i++)
+ result[i] = a[i] - b[i];
+
+ return result;
+ }
}
}
diff --git a/encog-core-cs/ML/Data/Basic/BasicMLDataPair.cs b/encog-core-cs/ML/Data/Basic/BasicMLDataPair.cs
index fbf579f8..4d1f9203 100644
--- a/encog-core-cs/ML/Data/Basic/BasicMLDataPair.cs
+++ b/encog-core-cs/ML/Data/Basic/BasicMLDataPair.cs
@@ -23,6 +23,7 @@
using System;
using System.Text;
using Encog.Util.KMeans;
+using Encog.ML.Data.Sparse;
namespace Encog.ML.Data.Basic
{
@@ -174,10 +175,6 @@ public double Significance
///
public ICentroid CreateCentroid()
{
- if (!(Input is BasicMLData))
- {
- throw new EncogError("The input data type of " + Input.GetType().Name + " must be BasicMLData.");
- }
return new BasicMLDataPairCentroid(this);
}
}
diff --git a/encog-core-cs/ML/Data/Basic/BasicMLDataPairCentroid.cs b/encog-core-cs/ML/Data/Basic/BasicMLDataPairCentroid.cs
index 19e84774..f9aa91ae 100644
--- a/encog-core-cs/ML/Data/Basic/BasicMLDataPairCentroid.cs
+++ b/encog-core-cs/ML/Data/Basic/BasicMLDataPairCentroid.cs
@@ -33,7 +33,7 @@ public class BasicMLDataPairCentroid : ICentroid
///
/// The value the centroid is based on.
///
- private readonly BasicMLData _value;
+ private readonly IMLDataModifiable _value;
///
/// How many items have been added to the centroid.
@@ -44,9 +44,15 @@ public class BasicMLDataPairCentroid : ICentroid
/// Construct the centroid.
///
/// The pair to base the centroid on.
- public BasicMLDataPairCentroid(BasicMLDataPair o)
+ public BasicMLDataPairCentroid(IMLDataPair o)
{
- _value = (BasicMLData)o.Input.Clone();
+ if(!(o.Input is IHasArithimeticOperations))
+ {
+ throw new ArgumentException(string.Format("It is not possible to base a data pair centroid on data structures which don't have arithmetic operations. The failed type is {0}",
+ o.Input.GetType().FullName));
+ }
+
+ _value = (IMLDataModifiable)o.Input.Clone();
_size = 1;
}
@@ -61,7 +67,7 @@ public void Remove(IMLDataPair d)
///
public double Distance(IMLDataPair d)
{
- IMLData diff = _value.Minus(d.Input);
+ IMLData diff = ((IHasArithimeticOperations)_value).Minus(d.Input);
double sum = 0.0;
for (int i = 0; i < diff.Count; i++)
@@ -78,6 +84,5 @@ public void Add(IMLDataPair d)
((_value[i] * _size) + d.Input[i]) / (_size + 1);
_size++;
}
-
}
}
diff --git a/encog-core-cs/ML/Data/IHasArithimeticOperations.cs b/encog-core-cs/ML/Data/IHasArithimeticOperations.cs
new file mode 100644
index 00000000..35bb536a
--- /dev/null
+++ b/encog-core-cs/ML/Data/IHasArithimeticOperations.cs
@@ -0,0 +1,10 @@
+using System;
+namespace Encog.ML.Data
+{
+ public interface IHasArithimeticOperations
+ {
+ IMLData Minus(IMLData o);
+ IMLData Plus(IMLData o);
+ IMLData Times(double d);
+ }
+}
diff --git a/encog-core-cs/ML/Data/IMLData.cs b/encog-core-cs/ML/Data/IMLData.cs
index 0c5f7a34..58956181 100644
--- a/encog-core-cs/ML/Data/IMLData.cs
+++ b/encog-core-cs/ML/Data/IMLData.cs
@@ -47,12 +47,20 @@ public interface IMLData : ICloneable, ICentroidFactory
void CopyTo(double[] target, int targetIndex, int count);
}
- public interface IMLDataModifiable: IMLData
+ ///
+ /// Used when it is possible to change the value of the underlying IMLData.
+ ///
+ public interface IMLDataModifiable : IMLData
{
///
/// Set the specified index.
///
/// The index to access.
new double this[int x] { get; set; }
+
+ ///
+ /// Constructs an array of the data which is used to construct the object.
+ ///
+ double[] Data { get; }
}
}
diff --git a/encog-core-cs/ML/Data/Sparse/SparseMLData.cs b/encog-core-cs/ML/Data/Sparse/SparseMLData.cs
new file mode 100644
index 00000000..620ad363
--- /dev/null
+++ b/encog-core-cs/ML/Data/Sparse/SparseMLData.cs
@@ -0,0 +1,324 @@
+//
+// Encog(tm) Core v3.3 - .Net Version
+// http://www.heatonresearch.com/encog/
+//
+// Copyright 2008-2014 Heaton Research, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// For more information on Heaton Research copyrights, licenses
+// and trademarks visit:
+// http://www.heatonresearch.com/copyright
+//
+using System;
+using System.Text;
+using Encog.Util;
+using Encog.Util.KMeans;
+using System.Collections.Generic;
+using System.Linq;
+using System.Collections;
+using Encog.ML.Data.Basic;
+
+namespace Encog.ML.Data.Sparse
+{
+ ///
+ /// Basic implementation of the NeuralData interface that stores the
+ /// data in an sparse vector.
+ ///
+ [Serializable]
+ public class SparseMLData : IMLDataModifiable, IEnumerable, IHasArithimeticOperations
+ {
+ ///
+ /// Stores the data, but looked up in a dictionary instead of an array.
+ /// For arrays where most of the values are default, this will save RAM.
+ ///
+ protected Dictionary SparseData = new Dictionary();
+
+ ///
+ public int Count { get; set; }
+
+ ///
+ /// The default value of the sparse vector (defaults to 1.0d). Data which has this
+ /// value is not stored, so the correct choice is whichever value is most common
+ /// in the data set.
+ ///
+ protected double DefaultValue { get; set; }
+
+ ///
+ /// A measure of how sparse the vector is, lower values mean that it is sparser.
+ /// For example, if there are 4 values in the vector, but 2 are the default value,
+ /// 0.5 will be returned. If there are 4 values in the vector, but 3 are the default
+ /// value, 0.25 will be returned.
+ ///
+ public double FillPercentage
+ {
+ get
+ {
+ return this.Count == 0 ? 0d : this.SparseData.Count / (double)this.Count;
+ }
+ }
+
+ ///
+ /// Creates an instance of the SparseML data type, initializing the underling data
+ /// and optionally specifiying the default value for data. Data which has the default value is not stored.
+ ///
+ public SparseMLData(IEnumerable data, double defaultValue = 0d)
+ : this(defaultValue)
+ {
+ this.DefaultValue = defaultValue;
+ this.AddRange(data);
+ }
+
+ ///
+ /// Creates an instance of the SparseML data type, specifiying the default value for
+ /// data. Data which has the default value is not stored.
+ ///
+ public SparseMLData(double defaultValue)
+ : this()
+ {
+ this.DefaultValue = defaultValue;
+ }
+
+ ///
+ /// Creates a default instance of the SparseML data type.
+ ///
+ public SparseMLData()
+ {
+ }
+
+ ///
+ /// Construct this object with blank data and a specified size.
+ ///
+ /// The amount of data to store.
+ public SparseMLData(int size, double defaultValue = 0d)
+ : this(defaultValue)
+ {
+ this.Count = size;
+ }
+
+ ///
+ /// Add data to the underlying dictionary.
+ ///
+ ///
+ public void Add(double item)
+ {
+ if (item != this.DefaultValue)
+ {
+ this.SparseData.Add(this.Count, item);
+ }
+ this.Count++;
+ }
+
+ ///
+ /// Add data to the underlying dictionary.
+ ///
+ ///
+ public void Add(params double[] items)
+ {
+ AddRange(items);
+ }
+
+ ///
+ /// Add data to the underlying dictionary.
+ ///
+ ///
+ public void AddRange(IEnumerable items)
+ {
+ foreach (var item in items)
+ {
+ this.Add(item);
+ }
+ }
+
+ ///
+ /// Access the data by index.
+ ///
+ /// The index to access.
+ ///
+ public double this[int index]
+ {
+ get
+ {
+ if (this.SparseData.ContainsKey(index))
+ {
+ return this.SparseData[index];
+ }
+ else
+ {
+ return this.DefaultValue;
+ }
+ }
+ set
+ {
+ if (this.SparseData.ContainsKey(index))
+ {
+ this.SparseData[index] = value;
+ }
+ else
+ {
+ this.SparseData.Add(index, value);
+ }
+ }
+ }
+
+ ///
+ /// Enumerates through the values.
+ ///
+ ///
+ public IEnumerator GetEnumerator()
+ {
+ return this.Enumerate().GetEnumerator();
+ }
+
+ ///
+ /// Enumerates through the values.
+ ///
+ ///
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ private IEnumerable Enumerate()
+ {
+ for (int i = 0; i < this.Count; i++)
+ {
+ yield return this[i];
+ }
+ }
+
+ ///
+ /// Get the data as an array.
+ ///
+ public virtual double[] Data
+ {
+ get { return this.ToArray(); }
+ }
+
+ ///
+ /// Convert the object to a string.
+ ///
+ /// The object as a string.
+ public override string ToString()
+ {
+ var result = new StringBuilder("[");
+ foreach (var iv in this.Select((value, index) => new { value, index }))
+ {
+ if (iv.index > 0)
+ {
+ result.Append(',');
+ }
+ result.Append(iv.value);
+ }
+ result.Append(']');
+ return result.ToString();
+ }
+
+ ///
+ /// Clone this object.
+ ///
+ /// A clone of this object.
+ public object Clone()
+ {
+ var result = new SparseMLData(this, this.DefaultValue);
+ return result;
+ }
+
+ ///
+ /// Clear to zero.
+ ///
+ public void Clear()
+ {
+ this.SparseData.Clear();
+ this.Count = 0;
+ }
+
+ ///
+ public ICentroid CreateCentroid()
+ {
+ return new BasicMLDataCentroid(this);
+ }
+
+ ///
+ /// Add one data element to another. This does not modify the object.
+ ///
+ /// The other data element
+ /// The result.
+ public IMLData Plus(IMLData o)
+ {
+ if (Count != o.Count)
+ throw new EncogError("Lengths must match.");
+
+ var result = new SparseMLData(this.Count, this.DefaultValue);
+ for (int i = 0; i < Count; i++)
+ result[i] = this[i] + o[i];
+
+ return result;
+ }
+
+ ///
+ /// Multiply one data element with another. This does not modify the object.
+ ///
+ /// The other data element
+ /// The result.
+ public IMLData Times(double d)
+ {
+ var result = new SparseMLData(this.Count, this.DefaultValue);
+
+ for (int i = 0; i < Count; i++)
+ result[i] = this[i] * d;
+
+ return result;
+ }
+
+ ///
+ /// Subtract one data element from another. This does not modify the object.
+ ///
+ /// The other data element
+ /// The result.
+ public IMLData Minus(IMLData o)
+ {
+ if (Count != o.Count)
+ throw new EncogError("Counts must match.");
+
+ var result = new SparseMLData(this.Count, this.DefaultValue);
+ for (int i = 0; i < Count; i++)
+ result[i] = this[i] - o[i];
+
+ return result;
+ }
+
+ ///
+ /// Copies the source data to the target array at the specified index.
+ ///
+ ///
+ ///
+ /// The maximum number of items to copy.
+ public void CopyTo(double[] target, int targetIndex, int count)
+ {
+ int position = targetIndex;
+ int copyCount = 0;
+ foreach (var d in this)
+ {
+ target[position] = d;
+ position++;
+ copyCount++;
+
+ if (copyCount == count)
+ {
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/encog-core-cs/ML/KMeans/BasicCluster.cs b/encog-core-cs/ML/KMeans/BasicCluster.cs
index b89198ac..037a82f5 100644
--- a/encog-core-cs/ML/KMeans/BasicCluster.cs
+++ b/encog-core-cs/ML/KMeans/BasicCluster.cs
@@ -42,7 +42,7 @@ public class BasicCluster : IMLCluster
/// Construct a cluster from another.
///
/// The other cluster.
- public BasicCluster(Cluster cluster)
+ public BasicCluster(Cluster cluster)
{
Centroid = (BasicMLDataPairCentroid) cluster.Centroid();
foreach (IMLDataPair pair in cluster.Contents)
diff --git a/encog-core-cs/ML/KMeans/KMeansClustering.cs b/encog-core-cs/ML/KMeans/KMeansClustering.cs
index 05a23692..661c44f6 100644
--- a/encog-core-cs/ML/KMeans/KMeansClustering.cs
+++ b/encog-core-cs/ML/KMeans/KMeansClustering.cs
@@ -46,7 +46,7 @@ public class KMeansClustering : IMLClustering
///
/// The kmeans utility.
///
- private readonly KMeansUtil _kmeans;
+ private readonly KMeansUtil _kmeans;
///
/// The clusters
@@ -60,13 +60,13 @@ public class KMeansClustering : IMLClustering
/// The dataset to cluster.
public KMeansClustering(int theK, IMLDataSet theSet)
{
- IList list = new List();
+ var list = new List();
foreach (IMLDataPair pair in theSet)
{
- list.Add((BasicMLDataPair) pair);
+ list.Add(pair);
}
_k = theK;
- _kmeans = new KMeansUtil(_k, list as IList);
+ _kmeans = new KMeansUtil(_k, list as IList);
}
#region IMLClustering Members
@@ -96,7 +96,6 @@ public void Iteration(int count)
}
}
-
///
/// The clusters.
///
diff --git a/encog-core-cs/encog-core-cs.csproj b/encog-core-cs/encog-core-cs.csproj
index bfc3558a..e196208b 100644
--- a/encog-core-cs/encog-core-cs.csproj
+++ b/encog-core-cs/encog-core-cs.csproj
@@ -333,6 +333,7 @@
+
@@ -376,6 +377,7 @@
+
diff --git a/encog-core-cs/encog-core-cs.v2.ncrunchproject b/encog-core-cs/encog-core-cs.v2.ncrunchproject
new file mode 100644
index 00000000..ad562c2d
--- /dev/null
+++ b/encog-core-cs/encog-core-cs.v2.ncrunchproject
@@ -0,0 +1,25 @@
+
+ 1000
+ false
+ false
+ false
+ true
+ false
+ false
+ false
+ false
+ false
+ true
+ true
+ false
+ true
+ true
+ true
+ 60000
+
+
+
+ AutoDetect
+ STA
+ x86
+
\ No newline at end of file
diff --git a/encog-core-test/App/Analyst/TestAnalystRegression.cs b/encog-core-test/App/Analyst/TestAnalystRegression.cs
index d3a329e7..b30892c7 100644
--- a/encog-core-test/App/Analyst/TestAnalystRegression.cs
+++ b/encog-core-test/App/Analyst/TestAnalystRegression.cs
@@ -38,6 +38,7 @@ public class TestAnalystRegression
public TempDir TEMP_DIR = new TempDir();
[TestMethod]
+ [TestCategory("Integration")]
public void TestRegression()
{
FileInfo rawFile = TEMP_DIR.CreateFile("simple.csv");
diff --git a/encog-core-test/App/Analyst/TestEncogAnalyst.cs b/encog-core-test/App/Analyst/TestEncogAnalyst.cs
index 2e7acae4..b9499629 100644
--- a/encog-core-test/App/Analyst/TestEncogAnalyst.cs
+++ b/encog-core-test/App/Analyst/TestEncogAnalyst.cs
@@ -29,6 +29,7 @@ namespace Encog.App.Analyst
public class TestEncogAnalyst
{
[TestMethod]
+ [TestCategory("Integration")]
public void TestIrisClassificationFF()
{
var test = new AnalystTestingUtility("Encog.Resources.iris.csv");
@@ -52,6 +53,7 @@ public void TestIrisClassificationFF()
}
[TestMethod]
+ [TestCategory("Integration")]
public void TestEuroIrisClassificationFF()
{
var test = new AnalystTestingUtility("Encog.Resources.iris-euro.csv");
@@ -76,6 +78,7 @@ public void TestEuroIrisClassificationFF()
}
[TestMethod]
+ [TestCategory("Integration")]
public void TestIrisRegressionFF()
{
var test = new AnalystTestingUtility("Encog.Resources.iris.csv");
@@ -99,6 +102,7 @@ public void TestIrisRegressionFF()
}
[TestMethod]
+ [TestCategory("Integration")]
public void TestIrisClassificationSVM()
{
var test = new AnalystTestingUtility("Encog.Resources.iris.csv");
@@ -122,6 +126,7 @@ public void TestIrisClassificationSVM()
}
[TestMethod]
+ [TestCategory("Integration")]
public void TestIrisClassificationPNN()
{
var test = new AnalystTestingUtility("Encog.Resources.iris.csv");
@@ -145,6 +150,7 @@ public void TestIrisClassificationPNN()
}
[TestMethod]
+ [TestCategory("Integration")]
public void TestIrisClassificationBayes()
{
var test = new AnalystTestingUtility("Encog.Resources.iris.csv");
@@ -168,6 +174,7 @@ public void TestIrisClassificationBayes()
}
[TestMethod]
+ [TestCategory("Integration")]
public void TestIrisSOM()
{
var test = new AnalystTestingUtility("Encog.Resources.iris.csv");
diff --git a/encog-core-test/App/CSV/TestBalanceCSV.cs b/encog-core-test/App/CSV/TestBalanceCSV.cs
index cc341287..99248e12 100644
--- a/encog-core-test/App/CSV/TestBalanceCSV.cs
+++ b/encog-core-test/App/CSV/TestBalanceCSV.cs
@@ -54,6 +54,7 @@ public void GenerateTestFile(bool header)
file.Close();
}
+ [TestCategory("Integration")]
[TestMethod]
public void TestBalanceCSVHeaders()
{
@@ -79,6 +80,7 @@ public void TestBalanceCSVHeaders()
OutputName.Delete();
}
+ [TestCategory("Integration")]
[TestMethod]
public void TestBalanceCSVNoHeaders()
{
diff --git a/encog-core-test/App/CSV/TestNinjaFileConvert.cs b/encog-core-test/App/CSV/TestNinjaFileConvert.cs
index d04b4500..8be24f6f 100644
--- a/encog-core-test/App/CSV/TestNinjaFileConvert.cs
+++ b/encog-core-test/App/CSV/TestNinjaFileConvert.cs
@@ -53,6 +53,7 @@ public void GenerateTestFileHeadings(bool header)
}
[TestMethod]
+ [TestCategory("Integration")]
public void TestConvert()
{
GenerateTestFileHeadings(true);
diff --git a/encog-core-test/App/CSV/TestNinjaStreamWriter.cs b/encog-core-test/App/CSV/TestNinjaStreamWriter.cs
index d68e0d15..1e1979ff 100644
--- a/encog-core-test/App/CSV/TestNinjaStreamWriter.cs
+++ b/encog-core-test/App/CSV/TestNinjaStreamWriter.cs
@@ -35,6 +35,7 @@ public class TestNinjaStreamWriter
public static readonly TempDir TempDir = new TempDir();
public readonly FileInfo OutputName = TempDir.CreateFile("test2.csv");
+ [TestCategory("Integration")]
[TestMethod]
public void TestWrite()
{
diff --git a/encog-core-test/App/CSV/TestSegregateCSV.cs b/encog-core-test/App/CSV/TestSegregateCSV.cs
index 8548c5c8..73f7739e 100644
--- a/encog-core-test/App/CSV/TestSegregateCSV.cs
+++ b/encog-core-test/App/CSV/TestSegregateCSV.cs
@@ -55,6 +55,7 @@ public void GenerateTestFileHeadings(bool header)
}
[TestMethod]
+ [TestCategory("Integration")]
public void TestFilterCSVHeaders()
{
GenerateTestFileHeadings(true);
@@ -84,6 +85,7 @@ public void TestFilterCSVHeaders()
}
[TestMethod]
+ [TestCategory("Integration")]
public void TestFilterCSVNoHeaders()
{
GenerateTestFileHeadings(false);
diff --git a/encog-core-test/ML/Data/Market/TestMarketData.cs b/encog-core-test/ML/Data/Market/TestMarketData.cs
index 25a894e3..497b15ea 100644
--- a/encog-core-test/ML/Data/Market/TestMarketData.cs
+++ b/encog-core-test/ML/Data/Market/TestMarketData.cs
@@ -32,6 +32,7 @@ namespace Encog.ML.Data.Market
public class TestMarketData
{
[TestMethod]
+ [TestCategory("Integration")]
public void MarketData()
{
IMarketLoader loader = new YahooFinanceLoader();
diff --git a/encog-core-test/ML/Data/Sparse/SparseMLDataTests.cs b/encog-core-test/ML/Data/Sparse/SparseMLDataTests.cs
new file mode 100644
index 00000000..c53b89fe
--- /dev/null
+++ b/encog-core-test/ML/Data/Sparse/SparseMLDataTests.cs
@@ -0,0 +1,210 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Encog.ML.Data.Sparse
+{
+ [TestClass]
+ public class SparseMLDataTests
+ {
+ [TestMethod]
+ public void TheConstructorCopiesDataToTheObject()
+ {
+ var data = new double[] { 1.0d, 2.0d, 3.0d, 0d };
+ var vector = new SparseMLData(data);
+
+ ShouldContainInOrder(vector, data);
+ Assert.AreEqual(vector.Count, 4, "there are 4 items in the array");
+ }
+
+ [TestMethod]
+ public void OnlyNonDefaultValuesAreStored()
+ {
+ var expected = new double[] { 1.0d, 2.0d, 3.0d, 4.0d, 0d, 0d, 0d, 0d };
+ var vector = new SparseMLData();
+ vector.AddRange(expected);
+ Assert.AreEqual(vector.FillPercentage, 0.5d);
+
+ ShouldContainInOrder(vector, expected);
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToAddItemsToASparseMLData()
+ {
+ var vector = new SparseMLData();
+ Assert.AreEqual(vector.Count, 0);
+ vector.Add(1.0d);
+ Assert.AreEqual(vector.Count(), 1);
+ Assert.AreEqual(vector.First(), 1.0d);
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToClearASparseMLData()
+ {
+ var vector = new SparseMLData();
+ vector.Add(1.0d);
+ vector.Clear();
+ Assert.AreEqual(vector.Count, 0);
+ vector.Add(2.0d);
+ Assert.AreEqual(vector.Count(), 1);
+ Assert.AreEqual(vector.First(), 2.0d);
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToCheckTheContentsOfASparseMLData()
+ {
+ var vector = new SparseMLData();
+ vector.Add(1.0d, 2.0d, 3.0d);
+ Assert.IsTrue(vector.Contains(1.0d));
+ Assert.IsTrue(vector.Contains(2.0d));
+ Assert.IsTrue(vector.Contains(3.0d));
+ Assert.IsFalse(vector.Contains(4.0d));
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToCopyTheSparseMLDataToAnArray()
+ {
+ var expected = new double[] { 0d, 1.0d, 0d, 2.0d, 0d, 3.0d, 0d };
+
+ var vector = new SparseMLData();
+ vector.AddRange(expected.Skip(1));
+
+ var actual = new double[7];
+
+ vector.CopyTo(actual, 1, vector.Count);
+
+ // we copied the 6 elements from the vector over to the array, starting at index 1
+ ShouldContainInOrder(actual, expected);
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToUpdateDataUsingTheIndexer()
+ {
+ var vector = new SparseMLData();
+ vector.Add(1.0d);
+ vector[0] = 2.0d;
+ Assert.AreEqual(vector[0], 2.0d);
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToUpdateSparseDataUsingTheIndexer()
+ {
+ var vector = new SparseMLData();
+ vector.Add(1.0d, 0.0d);
+ Assert.AreEqual(vector.FillPercentage, 0.5d);
+ vector[1] = 2.0d;
+ Assert.AreEqual(vector.FillPercentage, 1d);
+ Assert.AreEqual(vector[1], 2.0d);
+ }
+
+ private void ShouldContainInOrder(IEnumerable actual, IEnumerable expected)
+ {
+ var arrayActual = actual.ToArray();
+ var arrayExpected = expected.ToArray();
+
+ Assert.AreEqual(arrayExpected.Length, arrayActual.Length, "Expected the array to contain {0} items, but it actually contained {1} items",
+ arrayExpected.Length,
+ arrayActual.Length);
+
+ var stringActual = CreateArrayString(arrayActual);
+ var stringExpected = CreateArrayString(arrayExpected);
+
+ Assert.AreEqual(stringExpected, stringActual, "Expected {0} but found {1}", stringExpected, stringActual);
+ }
+
+ public string CreateArrayString(IEnumerable data)
+ {
+ return "{ " + string.Join(", ", data.Select(a => a.ToString())) + " }";
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToCreateAnEmptySparseMLData()
+ {
+ var data = new SparseMLData(20, 1.4d);
+ Assert.AreEqual(data.Count, 20);
+ Assert.IsTrue(data.All(d => d == 1.4d));
+ }
+
+ [TestMethod]
+ public void DataIsAccessible()
+ {
+ var data = new SparseMLData(new double[] { 1.0d, 2.0d });
+ Assert.AreEqual(data.Data.Length, 2);
+ Assert.AreEqual(data.Data[0], 1.0d);
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToCloneAnObject()
+ {
+ var a = new SparseMLData(new double[] { 1.0d, 2.0d });
+ var b = a.Clone() as SparseMLData;
+
+ ShouldContainInOrder(a.Data, b.Data);
+
+ Assert.AreNotSame(a, b);
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToEnumerateTheDataUsingTheNonGenericEnumerator()
+ {
+ var a = new SparseMLData(new double[] { 1.0d, 2.0d });
+
+ var enumerator = ((IEnumerable)a).GetEnumerator();
+ enumerator.MoveNext();
+ Assert.AreEqual(enumerator.Current.GetType(), typeof(double));
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToCreateACentroid()
+ {
+ var a = new SparseMLData(new double[] { 1.0d, 2.0d });
+ a.CreateCentroid();
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToAddTwoSetsOfDataTogether()
+ {
+ var a = new SparseMLData(new double[] { 1.0d, 2.0d });
+ var b = new SparseMLData(new double[] { 1.0d, 3.0d });
+
+ var expected = new double[] { 2.0d, 5.0d };
+ var actual = (a.Plus(b) as SparseMLData).ToArray();
+
+ ShouldContainInOrder(actual, expected);
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToMultiplyData()
+ {
+ var a = new SparseMLData(new double[] { 1.0d, 2.0d });
+
+ var expected = new double[] { 2.0d, 4.0d };
+ var actual = (a.Times(2) as SparseMLData).ToArray();
+
+ ShouldContainInOrder(actual, expected);
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToSubtractTwoSetsOfDataTogether()
+ {
+ var a = new SparseMLData(new double[] { 1.0d, 3.0d });
+ var b = new SparseMLData(new double[] { 1.0d, 2.0d });
+
+ var expected = new double[] { 0.0d, 1.0d };
+ var actual = (a.Minus(b) as SparseMLData).ToArray();
+
+ ShouldContainInOrder(actual, expected);
+ }
+
+ [TestMethod]
+ public void ItIsPossibleToGetAStringRepresentationOfTheData()
+ {
+ var a = new SparseMLData(new double[] { 1.1d, 3.1d });
+ var expected = "[1.1,3.1]";
+ Assert.AreEqual(expected, a.ToString());
+ }
+ }
+}
diff --git a/encog-core-test/ML/Data/Specific/TestSQLDataSet.cs b/encog-core-test/ML/Data/Specific/TestSQLDataSet.cs
index 90e925ea..e5de651e 100644
--- a/encog-core-test/ML/Data/Specific/TestSQLDataSet.cs
+++ b/encog-core-test/ML/Data/Specific/TestSQLDataSet.cs
@@ -30,6 +30,7 @@ namespace Encog.ML.Data.Specific
public class TestSQLDataSet
{
[TestMethod]
+ [TestCategory("Integration")]
public void SQLDataSet()
{
int bits = IntPtr.Size*8;
diff --git a/encog-core-test/Persist/TestPersistEPLPopulation.cs b/encog-core-test/Persist/TestPersistEPLPopulation.cs
index b93545b7..f5ce2cfa 100644
--- a/encog-core-test/Persist/TestPersistEPLPopulation.cs
+++ b/encog-core-test/Persist/TestPersistEPLPopulation.cs
@@ -61,6 +61,7 @@ private PrgPopulation Create()
}
[TestMethod]
+ [TestCategory("Integration")]
public void TestPersistEG()
{
PrgPopulation pop = Create();
@@ -70,6 +71,7 @@ public void TestPersistEG()
}
[TestMethod]
+ [TestCategory("Integration")]
public void testPersistSerial()
{
PrgPopulation pop = Create();
diff --git a/encog-core-test/encog-core-test.csproj b/encog-core-test/encog-core-test.csproj
index 55d0bc06..0eb86658 100644
--- a/encog-core-test/encog-core-test.csproj
+++ b/encog-core-test/encog-core-test.csproj
@@ -85,6 +85,7 @@
+
diff --git a/encog-core-test/encog-core-test.v2.ncrunchproject b/encog-core-test/encog-core-test.v2.ncrunchproject
new file mode 100644
index 00000000..bd9766d8
--- /dev/null
+++ b/encog-core-test/encog-core-test.v2.ncrunchproject
@@ -0,0 +1,69 @@
+
+ 1000
+ false
+ false
+ false
+ true
+ false
+ false
+ false
+ false
+ false
+ true
+ true
+ false
+ true
+ true
+ true
+ 60000
+
+
+
+ AutoDetect
+ STA
+ x86
+
+
+ Encog.ML.Data.Market.TestMarketData.MarketData
+
+
+ Encog.ML.Data.Specific.TestSQLDataSet.SQLDataSet
+
+
+ Encog.App.Analyst.TestAnalystRegression.TestRegression
+
+
+ Encog.App.Analyst.TestEncogAnalyst.TestEuroIrisClassificationFF
+
+
+ Encog.App.Analyst.TestEncogAnalyst.TestIrisClassificationBayes
+
+
+ Encog.App.Analyst.TestEncogAnalyst.TestIrisClassificationFF
+
+
+ Encog.App.Analyst.TestEncogAnalyst.TestIrisClassificationPNN
+
+
+ Encog.App.Analyst.TestEncogAnalyst.TestIrisClassificationSVM
+
+
+ Encog.App.Analyst.TestEncogAnalyst.TestIrisRegressionFF
+
+
+ Encog.App.Analyst.TestEncogAnalyst.TestIrisSOM
+
+
+ Encog.App.CSV.TestBalanceCSV.TestBalanceCSVHeaders
+
+
+ Encog.App.CSV.TestBalanceCSV.TestBalanceCSVNoHeaders
+
+
+ Encog.App.CSV.TestNinjaFileConvert.TestConvert
+
+
+ Encog.App.CSV.TestNinjaStreamWriter.TestWrite
+
+
+
\ No newline at end of file