<jupyter_start><jupyter_text>FEATURE EXTRACTION<jupyter_code>import pandas as pd
from textblob import TextBlob
d = pd.read_csv("processed_tweets.csv")
d = d.drop(["Unnamed: 0","index"],axis=1)
d = d.rename(columns={"0":"Text"})
d.head(10)
d.isna().sum()
d.dropna(inplace=True)
d.info()
n = len(d)
d["Sentiment"]=[None for i in range(n)]
for i in range(n):
    
    s = TextBlob(d["Text"].iloc[i]).sentiment
    if(s[0]>=0):
        d["Sentiment"].iloc[i] = 0
    else:
        d["Sentiment"].iloc[i] = 1
len(d[d["Sentiment"]==0]), len(d[d["Sentiment"]==1])
no = len(d[d["Sentiment"]==1])
t = d[d["Sentiment"]==0][:no]
s = d[d["Sentiment"]==1]
df = pd.concat([s,t],ignore_index="True")
len(df)
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfVectorizer

cv = CountVectorizer()
tf = TfidfVectorizer()
x1 = cv.fit_transform(df["Text"])
x2 = tf.fit_transform(df["Text"])
y = df["Sentiment"]
y=y.astype('int')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21306532663316582, 'fraction_numerical': 0.016080402010050253, 'mean_word_length': 6.114285714285714, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '177629', 'license': 'MIT', 'n_tokens_mistral': 420, 'n_tokens_neox': 414, 'n_words': 69, 'path': 'Feature Extraction.ipynb', 'repo_name': 'SubethaSiva/Sentiment-Analysis-for-Depression-Detection', 'size': '995'}