# Attach proper audio file name to file path wav_file_path = os.path.join(file_dir, file) file_array.append(wav_file_path) try: # Read the audio file afile, sample_rate = load(wav_file_path) # Get the average mel function of the audio files mfcc_a = mfcc(y=audio_array, sr=sample_rate, n_mfcc=40) mfcc_mean = np.mean(mfcc_a.T, axis=0) except Exception as e: print("Error encountered while parsing file: ", file_dir) return None, None feature = mfcc_mean label = str(os.path.splitext(file_dir)[0]) return [feature, label] parser() temp = train.apply(parser, axis=1) temp.columns = ['feature', 'label'] X = np.array(temp.feature.to_list()) y = np.array(temp.feature.to_list()) lb = LabelEncoder() y = np_utils.to_categorical(lb.fit_tranform(y))
df.isnull().sum() # In[27]: df.drop("Embarked", axis=1, inplace=True) # In[30]: df["Age"].hist(bins=4) # we can observe that there most of the people on ship are in age group of 20 to 40. # In[31]: le = LabelEncoder() df["Sex"] = le.fit_tranform(df["Age"]) # In[38]: from sklearn.preprocessing import LabelEncoder # In[43]: le = LabelEncoder() df_new = le.fit_transform(df["Sex"]) # In[34]: df["Sex"] # In[35]: