Plotting the MSE and MAE

Hey friends
hope you are doing well.
I have a question regarding the plotting MSE and MAE.
Here is my code. It works fine but the plotting part is definitely faulty. Thank you.
import app

#Opening the file df = pd.read_csv("/content/gdrive/MyDrive/codecademy training/admissions_data.csv") #Preprocess labels = df.iloc [:,-1] features = df.iloc [:, 1:8] #Data spliting features_training, features_test, label_training, label_test = train_test_split(features, labels, test_size = 0.25, random_state=20) #Scaling sc = StandardScaler() features_training_scaled = sc.fit_transform (features_training) features_test_scaled = sc.transform(features_test) #Model architecture model = Sequential () input = InputLayer (input_shape = (features.shape[1],)) model.add(input) model.add(Dense(24, activation="relu")) model.add(Dense(1)) opt = Adam(learning_rate = 0.01) model.compile (loss = 'mse', metrics = ['mae'], optimizer = opt) model.fit(features_training_scaled,label_training,epochs = 50, batch_size = 1, verbose = 1) res_mse, res_mae = model.evaluate(features_test_scaled, label_test, verbose = 0) print(res_mse, res_mae) **###THIS PART###** fig = plt.figure() ax1 = fig.add_subplot(2, 1, 1) ax1.plot(['mae']) ax1.plot(['res_mae']) ax1.set_title('model mae') ax1.set_ylabel('MAE') ax1.set_xlabel('epoch') ax1.legend(['train', 'validation'], loc='upper left') # Plot loss and val_loss over each epoch ax2 = fig.add_subplot(2, 1, 2) ax2.plot(['loss']) ax2.plot(['res_loss']) ax2.set_title('model loss') ax2.set_ylabel('loss') ax2.set_xlabel('epoch') ax2.legend(['train', 'validation'], loc='upper left') # used to keep plots from overlapping each other fig.tight_layout() plt.show()

Welcome to the forums.

This Codebyte won’t work b/c you’re importing a csv file from your local Google Drive.

You could upload the notebook to a GitHub repo where the csv file is in the same repo. Then, if you view that csv file in raw format, you can copy that link (from the address bar) and then create your df from it.
Ex: df = pd.read_csv("https://raw.githubusercontent.com/...blah, blah, blah")

And then you can share the link from the repo here so we can see it.
Also a link to this particular lesson/module would be helpful.

oh, thank you , I didn’t know that

1 Like

Though, I will say that GH has a limit on file sizes–25mb. So, if your csv file is larger than that you won’t be able to upload it. There are ways of getting around that and you can find those with a basic google search.

Just finished it. Cannot edit the previous post, gonna post it here

Codebytes doesn’t work for importing libraries/modules or for files that are local to only your machine.
I meant that if you upload your work to a github repo and then share that link…

LOL
sorry

is it ok now? are you able to see it?

I can see the notebook, but what is the plotting error/issue that you’re having w/matplotlib?

Good to hear you can see it
and thank you for your time
Actually I don’t understand what those strange code are trying to do.
I use matplot lib in everyday usage for plotting, but this one (which is suggested in the solution of this project, is kind of strange, they are in a and string “” )

ax2.plot([‘mae’])
ax2.plot([‘res_mae’])

hi this courses i have done it but still i didnt get my certificate

Do you have a link to this path/project? Is it in data science?
Maybe a screenshot of the plotting error?

I don’t really understand the issue.