forked from accord-net/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
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
36 changes: 36 additions & 0 deletions
36
Unit Tests/Accord.Tests.MachineLearning/DecisionTrees/DecisionTreeWriterTest.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.CodeDom.Compiler; | ||
using System.Text; | ||
using Accord.MachineLearning.DecisionTrees; | ||
using Microsoft.CSharp; | ||
using NUnit.Framework; | ||
|
||
namespace Accord.Tests.MachineLearning | ||
{ | ||
[TestFixture] | ||
public class DecisionTreeWriterTest | ||
{ | ||
[Test] | ||
public void WriteTest() | ||
{ | ||
DecisionTree tree; | ||
int[][] inputs; | ||
int[] outputs; | ||
ID3LearningTest.CreateMitchellExample(out tree, out inputs, out outputs); | ||
|
||
var csc = new CSharpCodeProvider(); | ||
var parameters = new CompilerParameters(new[] { "System.dll", "mscorlib.dll" }) {GenerateInMemory = true}; | ||
|
||
var compilerResult = csc.CompileAssemblyFromSource(parameters, tree.ToCode("AccordDecisionTree")); | ||
|
||
Assert.That(compilerResult.Errors.HasErrors, Is.False, ToString(compilerResult.Errors)); | ||
} | ||
|
||
private static string ToString(CompilerErrorCollection compilerErrors) | ||
{ | ||
var builder = new StringBuilder("Compiler errors:\n"); | ||
foreach (var error in compilerErrors) | ||
builder.AppendLine(error.ToString()); | ||
return builder.ToString(); | ||
} | ||
} | ||
} |