Z47
Z47

Reputation: 67

How to plot the loss curve

Trying to plot the training and testing sets vs loss to come up with a plot similar to the one attached (epoch vs. loss). How can I do this using mlxtend (https://rasbt.github.io/mlxtend/user_guide/plotting/plot_learning_curves/)?

from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(X_normalized, y_for_normalized, test_size=0.20,random_state=0)
from sklearn.linear_model import LinearRegression

lin_regressor = LinearRegression()

# pass the order of your polynomial here  
poly = PolynomialFeatures(1)

# convert to be used further to linear regression
X_transform = poly.fit_transform(x_train)

# fit this to Linear Regressor
linear_regg=lin_regressor.fit(X_transform,y_train) 


from mlxtend.plotting import plot_learning_curves

plot_learning_curves(x_train, y_train, x_test, y_test, lin_regressor, scoring=mean_squared_error)

plt.show()

#Error

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

enter image description here

Upvotes: 0

Views: 250

Answers (0)

Related Questions