4
$\begingroup$
$Version

12.1.0 for Microsoft Windows (64-bit) (March 14, 2020)

trainingset = ExampleData[{"MachineLearning", "Mushroom"}, "TrainingData"];
testset = ExampleData[{"MachineLearning", "Mushroom"}, "TestData"];
samples = testset[[All, 1]];

trainingData = RandomSample[trainingset, 1000];
c = Classify[trainingData, Method -> "DecisionTree", FeatureExtractor -> "DimensionReducedVector"]

enter image description here

c[samples[[79]], "Probabilities"]

<|"edible" -> 0.975, "poisonous" -> 0.025|>

c[samples[[{1, 2, 79}]], "Probabilities"][[-1]]

<|"edible" -> 0.975, "poisonous" -> 0.025|>

No difference.

c = Classify[trainingData, Method -> "GradientBoostedTrees", FeatureExtractor -> "DimensionReducedVector"]

enter image description here

c[samples[[79]], "Probabilities"]

<|"edible" -> 0.998383, "poisonous" -> 0.00161739|>

c[samples[[{1, 2, 79}]], "Probabilities"][[-1]]

<|"edible" -> 0.99807, "poisonous" -> 0.00193042|>

0.998383 vs 0.99807

c = Classify[trainingData, Method -> "RandomForest", FeatureExtractor -> "DimensionReducedVector"]

enter image description here

c[samples[[79]], "Probabilities"]

<|"edible" -> 0.855689, "poisonous" -> 0.144311|>

c[samples[[{1, 2, 79}]], "Probabilities"][[-1]]

<|"edible" -> 0.875449, "poisonous" -> 0.124551|>

0.855689 vs 0.875449 - significant difference

The original version of the question

Tested at 12.1, the problem seems to be existed a long time...

trainingset = ExampleData[{"MachineLearning", "Mushroom"}, "TrainingData"];
testset = ExampleData[{"MachineLearning", "Mushroom"}, "TestData"];
samples = testset[[All, 1]];

trainingData = RandomSample[trainingset, 1000];

c = Classify[trainingData, Method -> "DecisionTree"]

also happen in GradientBoostedTrees method, you can try several times to re-train the model to make this happen.

Since the batch predict is extremely important in speed aspect, I think this problem is very serious...

Batch Predict means use a trained model to predict several examples like this way: model[{example1,example2,}], something like listable attributes in some function, which is much faster

enter image description here

$\endgroup$
8
  • 1
    $\begingroup$ This really should state explicitly what the problem is. The term "batch predict" is nebulous. $\endgroup$ Commented Jun 10, 2020 at 15:40
  • $\begingroup$ I was able to reproduce. Upvoted and edited your question. $\endgroup$ Commented Jun 10, 2020 at 18:16
  • 2
    $\begingroup$ @AlexeyGolyshev OK, thanks for confirming that. This problem destroy my enthusiasm of playing Classify, since tree method is extremely important. $\endgroup$ Commented Jun 11, 2020 at 6:55
  • 1
    $\begingroup$ To restate the original question: If you use the trained classifier, c, to evaluate a single example , e.g., c[ samples[[79]], "Probabilities" ], you get a different answer than if you use the trained classifier to evaluate a list of examples, e.g., c[samples[[{1, 2, 79}]], "Probabilities"]. In fact, the problem is even worse than this: If you evaluate a list of examples of the same point one gets different answers, e.g., c[ {samples[[79]], samples[[79]] }, "Probabilities"] returns the two different probability values, even though it is a list of the same examples. $\endgroup$ Commented Jun 11, 2020 at 13:41
  • 1
    $\begingroup$ Random speculation: A similar non-deterministic prediction occurred in the older versions of SciKit-Learn (see:[ github.com/scikit-learn/scikit-learn/issues/10065]. It appears to be fixed by a change to make the accumulation of the results of each tree thread safe (see: [github.com/scikit-learn/scikit-learn/pull/9830 ]) $\endgroup$ Commented Jun 11, 2020 at 13:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.