Q50.webp
L

Q50.webp

Kizspy | Question: 50
(Choose 1 answer)
You have a dataset customer_data containing information about customers, including their age, income, and
whether they purchased a product (binary classification). You want to train a Support Vector Classifier (SVC)
with a linear kernel to predict whether a new customer will purchase the product based on their age and
income. Which code snippet correctly preprocesses the data, trains the SVC, and makes predictions?
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
# Load the dataset
customer_data = pd.read_csv('customer_data.csv')
# Preprocess the data
X = choose your appropriate preprocess step here
y = customer_data['purchased']
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=42)
# Create an SVC with linear kernel
svc_classifier = SVC (kernel-'linear')
# Fit the classifier to the training data
svc_classifier.fit(X_train, y_train)
# Make predictions on the test data
predictions = svc_classifier.predict(X_test)
A. X= customer_data[['age', 'income']]
B. X = customer_data[['age', 'income', 'purchased']]
C. X = customer_data[['age', 'purchased']].to_numpy()
D. X=customer_data[['age', 'income']].reshape(-1, 2)

Thông tin

Category
DAP391m
Thêm bởi
lanphuong2005
Ngày thêm
Lượt xem
657
Lượt bình luận
3
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom