I want to convert a dataset to a list of features and a list of target values, for use in Predict
and also more generally. I know Predict
can accept datasets natively but there are some "features" with Predict
in V10.1, that require dropping back to lists and rules. The dataset is :
ds =
{<|"age" -> 4, "weight" -> 10, "gender" -> "M",
"comment" -> "mummy says I eat like a horse", "result" -> 1.4|>,
<|"age" -> 4, "weight" -> 8, "gender" -> "M",
"comment" -> "throws his porridge on the floor", "result" -> 2.3|>,
<|"age" -> 5, "weight" -> 15, "gender" -> "F",
"comment" -> "loves green vegetables", "result" -> 3.5|>,
<|"age" -> 7, "weight" -> 30, "gender" -> "F",
"comment" -> "Thinks chocolate is fantastic", "result" -> 5.1|>} //
Dataset
I thought MapThread
might work :
MapThread[Rule, {Values[Normal[ds[All, {"age", "weight"}]]],
Values[Normal[ds[All, {"result"}]]]}, 2]
The end result I am Looking for is of the form
{{4, 10} -> 1.4}, {4, 8} -> 2.3} ... }