-1

I'm new to AI and ML.

I am attempting to write code that will generate a decision tree given a random set of integers 0 - 9 as opposed to giving the code the choice between 0 and 1. Ideally, the code will output the likelihood (probability) of a pair of any two integers between 0 - 9.

the code is as follows:

from sklearn import tree
import random

num1 = random.randint (0, 9)
num2 = random.randint (0, 9)

X = [[num1, num1], [num2, num2]]
Y = [num1, num2]
clf = tree.DecisionTreeClassifier()
clf = clf.fit(X, Y)

the program still outputs a decision tree from set of [0,1] and not random integers between 0 - 9.

what am i doing wrong?

1
  • import random Commented Dec 16, 2022 at 2:23

1 Answer 1

0

The code is correct.

when you run the whole code along with clf.predict(X) the values in the set changes when you execute repeatedly, as you gave random function

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.