Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import numpy as np
|
3 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
4 |
+
from sklearn.model_selection import train_test_split
|
5 |
+
from sklearn.svm import SVC
|
6 |
+
from sklearn.metrics import classification_report
|
7 |
+
from sklearn.pipeline import Pipeline
|
8 |
+
from sklearn.compose import ColumnTransformer
|
9 |
+
from sklearn.preprocessing import StandardScaler
|
10 |
+
import joblib
|
11 |
+
|
12 |
+
# Load Dataset
|
13 |
+
data = pd.read_csv('sarcasm_dataset.csv')
|
14 |
+
data['user_feature'] = data['user_feature'].fillna(0)
|
15 |
+
|
16 |
+
# Preprocessing
|
17 |
+
text_vectorizer = TfidfVectorizer(max_features=5000, stop_words='english')
|
18 |
+
scaler = StandardScaler()
|
19 |
+
preprocessor = ColumnTransformer(
|
20 |
+
transformers=[
|
21 |
+
('text', text_vectorizer, 'text'),
|
22 |
+
('user_features', scaler, ['user_feature']),
|
23 |
+
]
|
24 |
+
)
|
25 |
+
|
26 |
+
# Model
|
27 |
+
|