Input: The dataset contains 4 features: Length, Width, Height and Weight.
Output: # Load the dataset
import pandas as pd
csv_url = ‘http://test.test/test.csv’
df = pd.read_csv(csv_url)
# Split the dataset into features and label
X = df.iloc[:, 0:4].values
y = df.iloc[:, 4].values
# Import the ML model
from sklearn.tree import DecisionTreeClassifier
# Create and fit the model
model = DecisionTreeClassifier()
model.fit(X, y)
# Predict the label
def predict(data):
predicted_label = model.predict([data])
return predicted_label
Prompt: Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
Develop a Python function to predict the class labels of a given set of data.
### Input:
The dataset contains 4 features: Length, Width, Height and Weight.
### Output:
# Load the dataset
import pandas as pd
csv_url = ‘http://test.test/test.csv’
df = pd.read_csv(csv_url)
# Split the dataset into features and label
X = df.iloc[:, 0:4].values
y = df.iloc[:, 4].values
# Import the ML model
from sklearn.tree import DecisionTreeClassifier
# Create and fit the model
model = DecisionTreeClassifier()
model.fit(X, y)
# Predict the label
def predict(data):
predicted_label = model.predict([data])
return predicted_label