Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
| 3 |
-
import json
|
| 4 |
from sklearn.model_selection import train_test_split
|
| 5 |
from sklearn.linear_model import LinearRegression, LogisticRegression
|
| 6 |
from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
|
|
@@ -20,31 +19,9 @@ import logging
|
|
| 20 |
# Set up logging
|
| 21 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 22 |
|
| 23 |
-
# Load
|
| 24 |
-
logging.info("Loading
|
| 25 |
-
data = pd.read_csv('
|
| 26 |
-
|
| 27 |
-
# Load Instagram secrets book
|
| 28 |
-
logging.info("Loading Instagram secrets book...")
|
| 29 |
-
with open('Instagram_Secrets_Full.json', 'r') as f:
|
| 30 |
-
instagram_secrets = json.load(f)
|
| 31 |
-
|
| 32 |
-
# Extract tips and tricks from the book
|
| 33 |
-
logging.info("Extracting tips and tricks from the book...")
|
| 34 |
-
tips = []
|
| 35 |
-
for section in instagram_secrets.values():
|
| 36 |
-
if isinstance(section, dict):
|
| 37 |
-
for key, value in section.items():
|
| 38 |
-
if isinstance(value, str):
|
| 39 |
-
tips.append(value)
|
| 40 |
-
elif isinstance(value, list):
|
| 41 |
-
tips.extend(value)
|
| 42 |
-
elif isinstance(section, list):
|
| 43 |
-
tips.extend(section)
|
| 44 |
-
|
| 45 |
-
# Preprocess tips (e.g., remove duplicates, clean text)
|
| 46 |
-
tips = list(set(tips)) # Remove duplicates
|
| 47 |
-
logging.info(f"Extracted {len(tips)} unique tips from the book.")
|
| 48 |
|
| 49 |
# Feature Engineering
|
| 50 |
logging.info("Performing feature engineering...")
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
|
|
|
| 3 |
from sklearn.model_selection import train_test_split
|
| 4 |
from sklearn.linear_model import LinearRegression, LogisticRegression
|
| 5 |
from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
|
|
|
|
| 19 |
# Set up logging
|
| 20 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 21 |
|
| 22 |
+
# Load data
|
| 23 |
+
logging.info("Loading data...")
|
| 24 |
+
data = pd.read_csv('processed_instagram_data.csv')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# Feature Engineering
|
| 27 |
logging.info("Performing feature engineering...")
|