[1 / 1 / 1]
Quoted By:
using matplotlib to generate a graph:
<code>
import pandas as pd
import matplotlib.pyplot as plt
# Load the data
data = pd.read_csv('moon_dataset.csv')
boundary = pd.read_csv('decision_boundary.csv')
# Create the plot
plt.figure(figsize=(10, 8))
# Unique values for the transformed decision boundary
x_unique = boundary['x'].unique()
y_unique = boundary['y'].unique()
# Reshape z values for contour plot
z_values = boundary['z'].values.reshape(len(y_unique), len(x_unique))
# Plot the rotated decision boundary
plt.contourf(x_unique, y_unique, z_values,
levels=0, cmap='RdBu_r', alpha=0.8)
# Plot the data points
plt.scatter(data[data['y'] == -1]['x1'], data[data['y'] == -1]['x2'],
c='blue', label='Class -1')
plt.scatter(data[data['y'] == 1]['x1'], data[data['y'] == 1]['x2'],
c='red', label='Class 1')
plt.legend()
plt.title('MLP Decision Boundary on Moon Dataset')
plt.xlabel('X')
plt.ylabel('Y')
plt.show()
</code>
want to swap the coordinates for the decision boundary data, but it's just not doing it? have tried changing the headers of the csv (y->x, x->y), changing it inside the code also doesn't work
<code>
import pandas as pd
import matplotlib.pyplot as plt
# Load the data
data = pd.read_csv('moon_dataset.csv')
boundary = pd.read_csv('decision_boundary.csv')
# Create the plot
plt.figure(figsize=(10, 8))
# Unique values for the transformed decision boundary
x_unique = boundary['x'].unique()
y_unique = boundary['y'].unique()
# Reshape z values for contour plot
z_values = boundary['z'].values.reshape(len(y_unique), len(x_unique))
# Plot the rotated decision boundary
plt.contourf(x_unique, y_unique, z_values,
levels=0, cmap='RdBu_r', alpha=0.8)
# Plot the data points
plt.scatter(data[data['y'] == -1]['x1'], data[data['y'] == -1]['x2'],
c='blue', label='Class -1')
plt.scatter(data[data['y'] == 1]['x1'], data[data['y'] == 1]['x2'],
c='red', label='Class 1')
plt.legend()
plt.title('MLP Decision Boundary on Moon Dataset')
plt.xlabel('X')
plt.ylabel('Y')
plt.show()
</code>
want to swap the coordinates for the decision boundary data, but it's just not doing it? have tried changing the headers of the csv (y->x, x->y), changing it inside the code also doesn't work
