เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Visualizing the dataset

In this exercise you will use ggplot() to visualise the complex dataset you created in the previous exercises. The dataset is available in the dataframe df. You are not required to visualize the decision boundary.

Here you will use coord_fixed() to give the x and y axes the same physical representation on the plot, making the circles appear as circles rather than ellipses.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Support Vector Machines in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Load the required plot library.
  • Set the arguments of the aesthetics parameter.
  • Set the appropriate geom_ function for a scatter plot.
  • Specify equal coordinates by adding coord_fixed() without arguments.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Load ggplot2
library(___)

# Plot x2 vs. x1, colored by y
scatter_plot<- ggplot(data = df, aes(x = ___, y = ___, color = ___)) + 
    # Add a point layer
    geom___() + 
    scale_color_manual(values = c("red", "blue")) +
    # Specify equal coordinates
    coord_fixed()
 
scatter_plot 
แก้ไขและรันโค้ด