2
$\begingroup$

I want to generate a simple model and classify it with decision tree.

The idea is if numbers in an array are increasing then what I need is that.

eg.

[1,2,3]
[2,4.2,5.6]

these paterns like increasing will be predicted as true

and other then those will be predicted as false

How can I achieve this with decision trees?

$\endgroup$
1
  • 1
    $\begingroup$ Why do you think that you need ml for this? Is there something more to your question? $\endgroup$ Feb 13, 2020 at 4:12

2 Answers 2

1
$\begingroup$

Machine learning is not needed to solve that problem. This deterministic code tests if numbers in an array are increasing:

def strictly_increasing(nums):
    "Deterministically check for only increasing values"
    return all(x2 > x1 for x1, x2 in zip(nums, nums[1:]))

assert strictly_increasing([1, 2, 3])
assert strictly_increasing([2, 4.2, 5.6])
assert not strictly_increasing([1, 1, 1])
assert not strictly_increasing([3, 2, 1])
$\endgroup$
0
$\begingroup$

Simple:

  1. Write a function which returns TRUE if the values in the input array are always increasing, FALSE otherwise.
  2. Optional: give the value returned by the function as feature to the classifier. The training requires only two examples, one true and one false.

Sorry I'm messing with you :)

Seriously, the point is: there's no interest at all to train a ML model for a problem which can easily be solved with an efficient deterministic algorithm. Use ML for problems which cannot be solved (or not as efficiently) without it.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.