- Musa Misto (29996)
- Neda Mohamed (33016)
This project focuses on leveraging social media data to:
- Classification Task: Categorize users into predefined labels based on profile information and posts.
- Regression Task: Predict
like_countfrom user metadata and content.
The primary objectives include handling imbalanced datasets, extracting meaningful features, and building robust machine learning pipelines for both tasks.
The dataset consists of two primary components:
- User Profiles: Metadata such as
username,biography,follower_count,post_count, andengagement_rate. - Posts: Textual content generated by users.
- Number of Users:
- Training: 2741 users.
- Testing: 2674 users.
- Target Variables:
- Classification: Categories such as
food,tech, andsports. - Regression: Continuous variables like
follower_countorengagement_rate.
- Classification: Categories such as
- Text Preprocessing:
- Tokenization and removal of Turkish stop words.
- Vectorization using TF-IDF to convert text data into numerical features.
- Numerical Features:
- Normalized attributes like
follower_countandpost_countusing MinMaxScaler.
- Normalized attributes like
- Categorical Features:
- Encoded using LabelEncoder for classification.
Feature engineering was a critical step in this project, where we transformed raw data into meaningful features to improve model performance for both classification and regression tasks. The following techniques and features were implemented:
-
TF-IDF Vectorization:
- Text data from user posts and biographies was vectorized using Term Frequency-Inverse Document Frequency (TF-IDF).
- This technique emphasized unique and important words while down-weighting common words, providing a robust representation of textual data.
- Separate TF-IDF models were trained for:
- User biographies: Provided insights into user interests and focus areas.
- User posts: Captured the content and themes of user-generated content.
-
Custom Text Features:
- Extracted word counts and character counts from biographies and posts to represent the text's verbosity and complexity.
- Calculated the percentage of stop words to identify the overall structure of user content.
-
Language-Specific Features:
- Turkish-specific stop words were removed to focus on meaningful content.
- Tokenization and case normalization were applied to ensure consistency.
-
Profile Metadata:
- Follower Count: Represents a user’s influence.
- Post Count: Indicates activity level on the platform.
- Engagement Rate: Calculated as the ratio of likes and comments to followers, highlighting interaction levels.
- These features were normalized using MinMaxScaler to prevent scale-related bias in model training.
-
Derived Features:
- Followers-to-Posts Ratio: A proxy for engagement or content impact per post.
- Log-Transformed Follower Count: Applied logarithmic transformation to handle skewness in follower distribution, improving regression model stability.
- Biographical Indicators: Identified specific phrases or keywords in biographies (e.g., "influencer," "business") to infer user category.
- User Type Encoding:
- Features like
is_business_accountandis_privatewere one-hot encoded to indicate account type.
- Features like
- Profile Categories:
- The categorical labels for classification (e.g.,
food,tech,sports) were encoded using LabelEncoder for model compatibility.
- The categorical labels for classification (e.g.,
- Text and Numeric Feature Interaction:
- Integrated text-based features (e.g., TF-IDF vectors) with metadata features like
follower_countto identify correlations between content themes and user influence. - For instance, users posting about "technology" with high engagement rates were more likely to belong to the
techcategory.
- Integrated text-based features (e.g., TF-IDF vectors) with metadata features like
- Cross-Derived Features:
- Created composite features like
follower_growth_rate(using historical data) to predict future engagement trends.
- Created composite features like
- Correlation Analysis:
- Assessed feature correlations to avoid redundancy and improve computational efficiency.
- Retained highly predictive features while discarding those with low information gain.
- Feature Importance:
- Used tree-based models like Random Forest and XGBoost to compute feature importance scores, guiding iterative feature selection and refinement.
By combining text-based, numerical, and interaction features, this feature engineering process significantly enhanced the performance of classification and regression models, enabling them to capture both semantic and quantitative aspects of the data.
For the classification task:
- SMOTE: Synthetic Minority Oversampling Technique generated synthetic samples for underrepresented categories.
- SMOTETomek: Enhanced the dataset by removing overlapping samples.
Several models were evaluated for user classification:
- Baseline Models:
- Logistic Regression.
- Naïve Bayes.
- Advanced Models:
- Random Forest.
- Gradient Boosting.
- XGBoost.
- LightGBM.
- Voting Classifier:
- Combined predictions from multiple models for improved accuracy.
Pipeline Setup:
- Integrated feature preprocessing, data resampling (SMOTE/SMOTETomek), and classification seamlessly.
The regression models aimed to predict numerical targets like follower_count:
- Baseline Model:
- Linear Regression.
- Advanced Models:
- Random Forest Regressor.
- Gradient Boosting Regressor.
- XGBoost Regressor.
- LightGBM Regressor.
Pipeline Setup:
- Feature scaling, transformation, and model training were combined into a streamlined pipeline.
- GridSearchCV was used to optimize hyperparameters for all models.
- Evaluation Metrics:
- Accuracy, Precision, Recall, and F1-Score were used to assess performance.
- Best Model: LightGBM and XGBoost achieved the highest scores across all metrics.
- Imbalance Handling: SMOTE and SMOTETomek significantly improved recall for minority classes.
- Validation Accuracy: 0.683
- Evaluation Metrics:
- Mean Absolute Error (MAE).
- Root Mean Squared Error (RMSE).
- (R^2)-score.
- Best Model: LightGBM Regressor consistently outperformed other models, achieving the lowest RMSE and highest (R^2)-score.
- Insights:
- Non-linear models like Gradient Boosting and XGBoost performed better than Linear Regression due to their ability to capture complex patterns in the data.
- Validation Log MSE: 0.1359
- Classification:
- Bar charts visualizing category distributions pre- and post-resampling.
- Confusion matrices to identify common misclassifications.
- Regression:
- Scatter plots comparing actual vs. predicted values.
- Residual plots to assess model fit and variance.
- Classification:
- Advanced tree-based ensemble models excelled in handling imbalanced datasets.
- SMOTE/SMOTETomek played a crucial role in improving minority class performance.
- Regression:
- Non-linear regression models like LightGBM and XGBoost provided superior performance compared to Linear Regression.
- Proper feature scaling and transformation significantly impacted results.
- Feature Engineering:
- Text-based features (e.g., TF-IDF vectors) were crucial for both tasks.
- Metadata attributes enriched predictive power for regression.