i am trying to write a code based on Predict, which does the following:

  1. import some external data
  2. define Predict on those data (setting of training and test data)
  3. define PredictorMeasurements (setting of testset data)
  4. define a function, which based on points 2 and 3, can make a predictive trend as a function of
  5. plot the function at number 4

Here some parts of the code:

    data1 = Dataset[data[[1]][[All, {2, 6}]]];
    {test1, training1} = TakeDrop[data1[[All, {1, 2}]], 100];
    testSet1 = {Normal[#[[]]] -> Normal[#[[2]]]} & /@ test1
    RandomSample[testSet1, 1]
    pm1 = PredictorMeasurements[p1, 
    testSet1, {"ComparisonPlot", "ResidualPlot", "ResidualHistogram", 

unfortunately i am stuck at point 3 and get the following error message:

PredictorMeasurements::bdfmt: Argument Dataset [<<100>>] should be a rule or a list of rules.

i have tried to define testSet1 in every possible way, but i always get an error message. Do you have any idea of where the problem is?


  • $\begingroup$ As I understand it, testset should be a plain list of rules. What is the format of testset in your code? It would be helpful if you could show its contents from your current code. $\endgroup$
    – MarcoB
    Dec 19, 2020 at 15:01
  • $\begingroup$ testSet1 = {Normal[#[[]]] -> Normal[#[[2]]]} & /@ test1 i can't paste the whole output of testSet1 (it is very long) but it looks like this: {DateObject[], 71.}-> 71., {DateObject[], 69.}-> 69., {DateObject[], 70.}-> 70., $\endgroup$
    – Pinco
    Dec 19, 2020 at 16:33
  • $\begingroup$ What is p1? From the error message, it seems like testSet1 is a Dataset, not a list. Also, you should RandomSample the data before the test/train split. $\endgroup$ Dec 19, 2020 at 21:18
  • $\begingroup$ p1 = Predict[training1 -> training1[[All, 2]], Method -> "GradientBoostedTrees"] i tried to convert Dataset simple to List with the following: data1 = data[[1]][[All, {2, 6}]]; ut i still get this error message PredictorMeasurements::bdfmt: Argument {{{Date,Hardness [N]}->Hardness [N]},{{{DateObject[{2004,6,28,0,0,0.},Instant,Gregorian,1.],70.}->70.},{{DateObject[{2004,6,28,0,0,0.},Instant,Gregorian,1.],71.}->71.},<<50>>} should be a rule or a list of rules. do you know how i can fix this thanks $\endgroup$
    – Pinco
    Dec 20, 2020 at 14:59
  • $\begingroup$ i was finally able to get the code working , here it is : data=Import@; data0 = data[[1]][[All, {2, 6}]]; data1 = Rest[data0]; {test1, training1} = TakeDrop[data1[[All, {1, 2}]], 100]; p1 = Predict[training1[[All, 1]] -> training1[[All, 2]], Method -> "GradientBoostedTrees"]; testSet1 = test1[[All, 1]] -> test1[[All, 2]]; pm1 = PredictorMeasurements[p1, testSet1, {"ComparisonPlot", "ResidualPlot", "ResidualHistogram", "StandardDeviation"}] Information[p1, "MethodOption"] p1[DateObject[]] interesting, the best prediction are achieved by using GradientBoostedTrees $\endgroup$
    – Pinco
    Dec 21, 2020 at 16:14


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.