Question: Now, we want to separate the data using ellipsoid. Its equation is: A x 2 + B y 2 + C x + D y

Now, we want to separate the data using ellipsoid.
Its equation is:
Ax2+By2+Cx+Dy+e=0
Based on that equation, construct a mapping function into 4d space, such that the problem will become a linear (
wt(x)+e=0).
After the mapping, learn a linear classifier and print the hyperplane equation.
Note: after getting an output, I would recommend you to plot this equation on desmos, just to "see it".
[] new_features =# Implement here
model = SVC (kernel=' linear', C=10
model.fit(new_features, y_train)
# Get the hyperplane equation coefficients and intercept
coefficients = model.coef_[0]
intercept = model. intercept_
# Print the hyperplane equation
equation_parts =[]
for i in range(len(coefficients)):
equation_parts.append( coefficients {:[i]:.3f}**x{i+1}
equation =+.join(equation_parts) intercept [0]:.3f})"
print("Hyperplane equation:")
print (f"{equation }")
Complete the missing lines to get plots on train and test
train_features = # Implement here
train_preds = # Implement here
train_acc = # Implement here
val_features =# Implement here
val_preds = # Implement here
val_acc = # Implement here
,yy=np. meshgrid . arange(-2,2.2,0.1),np. arange(-2,2.2,0.1)
data =np*c-[*ravel(),yy*ravel()]
new_features = # Implement here the new features on 'data'
z= # Implement here the predictions of data into 2 classes, using w,b you found
Z=Z. reshape (xx.shape)
fig, axs = plt.subplots , figsize =(12,4)
# Plot the training data on the first subplot
axs [0]. contourf , alpha=0.8)
scatter1= axs [0]. scatter(x_train [: ,0], X_train [:,1], c=y_train, cmap='bwr')
axs [0].set_xlabel ('X')
axs [0]. set_ylabel('Y'')
axs[0].set_title(f'Train dataset -{train_acc:.4f} accuracy')
# Plot the validation data on the second subplot
axs [1]. contourf (,yy,z, alpha =0.8)
scatter2= axs[1].scatter(x_val [:,0], X_val [:,1], c=y_val, cmap='bwr')
axs [1].set_xlabel ('x')
axs [1]. set_ylabel('Y'')
axs[1].set_title(f'Validation dataset -{val_acc:.4f} accuracy')
plt.show()
 Now, we want to separate the data using ellipsoid. Its equation

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!