Reputation: 1269
I'm trying to get my code to match what the following code does:
var data = new Dictionary<string, object>() {
{ "state", new string[] { "Ohio", "Ohio", "Ohio", "Nevada", "Nevada" } },
{ "year", new int[] { 2000, 2001, 2002, 2001, 2002 } },
{ "pop", new double[] { 1.5, 1.7, 3.6, 2.4, 2.9 } }
};
My current code:
var data = new Dictionary<string, object>() {
{ "targetValue", calc.ListCalculationData.Select(i => i.MRTargetValue).ToArray<decimal>() },
{ "ema12", calc.ListCalculationData.Select(i => i.Ema12).ToArray<decimal>() },
{ "ema26", calc.ListCalculationData.Select(i => i.Ema26).ToArray<decimal>() },
{ "ema", calc.ListCalculationData.Select(i => i.Ema).ToArray<decimal>() }
};
var df1 = DataFrame.FromColumns(data);
var model2 = new LinearRegressionModel(df1, "targetValue ~ ema12 + ema26 + ema"); <= This line gives me the error
I'm getting the following error from the api that I'm using which is the extreme optimization C# api and here is the reference url: http://www.extremeoptimization.com/QuickStart/CSharp/DataFrames.aspx
The variable is not of a kind that is allowed in the group.
Upvotes: 1
Views: 104
Reputation: 542
I do not see any documentation or examples using the decimal
type, but I cannot verify since I do not have access to the library.
There were some examples using the double
type. If precision of 15-16 digits is acceptable, that could be an option. Try defining your data
variable like this, casting to a double
in the Select
, then converting to an array:
var data = new Dictionary<string, object>() {
{ "targetValue", calc.ListCalculationData.Select(i => (double)i.MRTargetValue).ToArray() },
{ "ema12", calc.ListCalculationData.Select(i => (double)i.Ema12).ToArray() },
{ "ema26", calc.ListCalculationData.Select(i => (double)i.Ema26).ToArray() },
{ "ema", calc.ListCalculationData.Select(i => (double)i.Ema).ToArray() }
};
Upvotes: 2