Lesson 1 self attempt on Titanic dataset

I have been trying to solve the Titanic prediction problem on Kaggle using the method of Lesson 1, I used the Random Forest Classifier instead of Regressor. I have been having problem using the proc_df function on the test data set.
I get the following error when I try to query the shape of the test data frame after doing proc_df on it:

AttributeError Traceback (most recent call last)
in ()
1 X_test_actual = proc_df(df_test)
----> 2 X_test_actual.shape

AttributeError: ‘list’ object has no attribute ‘shape’

Using predict method of the previously generated classifier doesn’t work either.
My kernel is available at https://www.kaggle.com/dtrikkadeeri/fastai-ml1-on-titanic
I can add more details if required to trace my issue. Help to solve this would be greatly appreciated.

I can‘t run your code as I am on mobile right now, but from your kernel it is clear that you run proc_df(test) and assign it to only one ‚Receiving‘ variable. but it returns at least 3 (x,y,nas). nas might be a list and I think in python the last variable gets stored/overwrites the first if not enough variables are assigned. Then of course the Xtest does not contain what you would expect which is why shape fails. Always simply print the variable, then it should be obvious.

Also related but not this error: you should pass the nas back in that you received when doing procdf of the trainingset (na_dict=nas or similar) when using the function on the test set. hope this helps!

2 Likes

Thank you very much for your help! I got my kernel working based on storing the results of the proc_df into three separate items and then using only the first one.