Deep learning example code with text data # Searching letters df['column'][df['column'].str.contains('[^a-z ]')].sum() # Replace letters df['column'] = df['column'].str.replace('[^a-z ]','') # delete sentence's head and tail's empty word df['column'] = df['column'].str.strip() # search duplicate data df['column'].duplicated().sum() # drop duplicate data df.drop_duplicates(subset=['column'], inplace=True) # Graph using value_counts() df['column'].value_counts().plot(kind='bar') # Split X and Y features = df['column'].values labels = df['column'].values # TF-IDF from sklearn.feature_extraction.text import TfidfVectorizer tfidf = TfidfVectorizer() x_train_v = tfidf.fit_transform(x_train) x_test_v = tfidf.transform(x_test) # Tokenizing from tensorflow.keras.preprocessing.text import Tokenizer from tensorflow.keras.preprocessing.sequence import pad_se...
Several modules that will work with Python offer a variety of functions. Among them, I drew and compared graphs using the matplotlib library that helps me draw graphs efficiently and Pandas' own plot function. # default bar graph df['column'].value_counts().plot(kind='bar') # sub graph plt.subplot(100) df['column1'].plot(kind='hist') plt.subplot(150) plt.hist(df['column2']) plt.show() # seaborn histogram graph sns.histplot(data=df, x='column') # seaborn histogram graph with hue color sns.histplot(data=df, x='column', hue='column color') # seaborn histogram with round end sns.kdeplot(data=df, x='column', hue='column color')
Comments
Post a Comment