I keep getting this error I don’t know why
Code:
Read the pre-loaded dataset
pre_loaded_df = pd.read_pickle(“df_all_breeds.pkl”)
try:
# Generate the dataset using the graded functions from section 1
df_all_breeds = utils.generate_data(gaussian_generator, binomial_generator, uniform_generator)
except:
# In case of an error
print(“There was an error when generating the dataset using the generator functions.\n\nFalling back to the pre-loaded one.”)
df_all_breeds = pre_loaded_df
else:
# In case that the generated dataset does not match the pre-loaded one
if not df_all_breeds.equals(pre_loaded_df):
print(“The dataset generated from the generator functions is not identical to the expect one.\n\nFalling back to the pre-loaded one.”)
df_all_breeds = pre_loaded_df
Print the first 10 rows of the dataframe
df_all_breeds.head(10)
There was an error when generating the dataset using the generator functions.
Falling back to the pre-loaded one.
next cell:
Define a 70/30 training/testing split
split = int(len(df_all_breeds)*0.7)
Do the split
df_train = df_all_breeds[:split].reset_index(drop=True)
df_test = df_all_breeds[split:].reset_index(drop=True)
NameError Traceback (most recent call last)
Cell In[45], line 2
1 # Define a 70/30 training/testing split
----> 2 split = int(len(df_all_breeds)*0.7)
4 # Do the split
5 df_train = df_all_breeds[:split].reset_index(drop=True)
NameError: name ‘df_all_breeds’ is not defined