Untitled

Anonymous
Plain Text
10/18/2025 9:00 AM
2.9 KB
16
Indexable
Never
from sklearn import tree

features = [
    [150, 0],  # apple
    [170, 0],  # apple
    [140, 1],  # orange
    [130, 1],  # orange
    [120, 0],  # apple
    [180, 1],  # orange
    [160, 0],  # apple
    [110, 1],  # orange
]

labels = ["apple", "apple", "orange", "orange", "apple", "orange", "apple", "orange"]

clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)

print("Let's see what fruit your AI thinks it is!")
weight = int(input("Enter weight (grams): "))
texture = input("Is it bumpy or smooth? ").lower()

if "bumpy" in texture:
    texture_value = 1
else:
    texture_value = 0

prediction = clf.predict([[weight, texture_value]])

print("The AI thinks your fruit is a:", prediction[0])

from sklearn import tree

features = [
    [150, 0],  # apple
    [170, 0],  # apple
    [140, 1],  # orange
    [130, 1],  # orange
    [120, 0],  # apple
    [180, 1],  # orange
    [160, 0],  # apple
    [110, 1],  # orange
]

labels = ["apple", "apple", "orange", "orange", "apple", "orange", "apple", "orange"]

clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)

print("Let's see what fruit your AI thinks it is!")
weight = int(input("Enter weight (grams): "))
texture = input("Is it bumpy or smooth? ").lower()

if "bumpy" in texture:
    texture_value = 1
else:
    texture_value = 0

prediction = clf.predict([[weight, texture_value]])

print("The AI thinks your fruit is a:", prediction[0])

from sklearn import tree

features = [
    [150, 0],  # apple
    [170, 0],  # apple
    [140, 1],  # orange
    [130, 1],  # orange
    [120, 0],  # apple
    [180, 1],  # orange
    [160, 0],  # apple
    [110, 1],  # orange
]

labels = ["apple", "apple", "orange", "orange", "apple", "orange", "apple", "orange"]

clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)

print("Let's see what fruit your AI thinks it is!")
weight = int(input("Enter weight (grams): "))
texture = input("Is it bumpy or smooth? ").lower()

if "bumpy" in texture:
    texture_value = 1
else:
    texture_value = 0

prediction = clf.predict([[weight, texture_value]])

print("The AI thinks your fruit is a:", prediction[0])

from sklearn import tree

features = [
    [150, 0],  # apple
    [170, 0],  # apple
    [140, 1],  # orange
    [130, 1],  # orange
    [120, 0],  # apple
    [180, 1],  # orange
    [160, 0],  # apple
    [110, 1],  # orange
]

labels = ["apple", "apple", "orange", "orange", "apple", "orange", "apple", "orange"]

clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)

print("Let's see what fruit your AI thinks it is!")
weight = int(input("Enter weight (grams): "))
texture = input("Is it bumpy or smooth? ").lower()

if "bumpy" in texture:
    texture_value = 1
else:
    texture_value = 0

prediction = clf.predict([[weight, texture_value]])

print("The AI thinks your fruit is a:", prediction[0])

Editor is loading...
Leave a Comment