ToIntArray - Replacement function

852 views Asked by At

According to http://crsouza.blogspot.com.br/2012/01/decision-trees-in-c.html I use

DataTable symbols = codebook.Apply(data); 
int[][] inputs  = symbols.ToIntArray("Outlook", "Temperature", "Humidity", "Wind"); 
int[]   outputs = symbols.ToIntArray("PlayTennis").GetColumn(0);

But in .net 4.0 and in mono there is no ToIntArray, also I could not find any replacement function for it.

How does ToIntArray convert symbols or, what does ToIntArray look like?

2

There are 2 answers

0
svedmark On

If you don't want to download and add the Accord framework to your project (Note: there is a chance it might have dependencies which are not supported by Xamarin's .NET implementation), then luckily it's open source, so if you want to just see the code it's available to the public.

To answer the specific question, the .ToIntArray extension method (which is just an "alias" method for ToArray<int>()) can be seen here:

https://code.google.com/p/accord/source/browse/trunk/Sources/Accord.Math/Matrix/Matrix.Conversions.cs

However, the .Apply and .GetColumn methods (from your sample code) is also part of the framework, so you'd probably need to look at that code as well. See Matrix.Common and Matrix.Selection.

0
Cesar On

As of the current version, you can use ToInt32(), as well as ToDouble(), ToSingle(), ToBoolean() and others to perform type conversions of arrays.