Sam Fred commited on
Commit
827161e
·
1 Parent(s): 6bc84bd
scripts/train_engagement_rate.py CHANGED
@@ -4,6 +4,8 @@ from sklearn.model_selection import train_test_split
4
  from sklearn.metrics import mean_absolute_error
5
  import joblib
6
  from utils.preprocessing import preprocess_data
 
 
7
 
8
  def train_engagement_rate():
9
  """Train the engagement rate prediction model."""
@@ -22,6 +24,16 @@ def train_engagement_rate():
22
  mae = mean_absolute_error(y_test, y_pred)
23
  print(f"Engagement Rate Prediction Model - MAE: {mae:.4f}")
24
 
25
- # Save the model
26
- joblib.dump(engagement_model, "models/engagement_rate_model.pkl")
27
- print("Engagement Rate Model saved to models/engagement_rate_model.pkl")
 
 
 
 
 
 
 
 
 
 
 
4
  from sklearn.metrics import mean_absolute_error
5
  import joblib
6
  from utils.preprocessing import preprocess_data
7
+ from huggingface_hub import HfApi, login
8
+ import os
9
 
10
  def train_engagement_rate():
11
  """Train the engagement rate prediction model."""
 
24
  mae = mean_absolute_error(y_test, y_pred)
25
  print(f"Engagement Rate Prediction Model - MAE: {mae:.4f}")
26
 
27
+ # Save the model locally
28
+ joblib.dump(engagement_model, "engagement_rate_model.pkl")
29
+
30
+ # Upload the model to Hugging Face Hub
31
+ login(token=os.environ.get("HF_TOKEN")) # Use your Hugging Face token
32
+ api = HfApi()
33
+ api.upload_file(
34
+ path_or_fileobj="engagement_rate_model.pkl",
35
+ path_in_repo="engagement_rate_model.pkl",
36
+ repo_id="Fred808/Insta-8084", # Replace with your repo
37
+ repo_type="model",
38
+ )
39
+ print("Engagement Rate Model uploaded to Hugging Face Hub!")
scripts/train_promotion_strategy.py CHANGED
@@ -4,6 +4,8 @@ from sklearn.model_selection import train_test_split
4
  from sklearn.metrics import accuracy_score
5
  import joblib
6
  from utils.preprocessing import preprocess_data
 
 
7
 
8
  def train_promotion_strategy():
9
  """Train the promotion strategy model."""
@@ -25,6 +27,16 @@ def train_promotion_strategy():
25
  accuracy = accuracy_score(y_test, y_pred)
26
  print(f"Promotion Prediction Model Accuracy: {accuracy:.4f}")
27
 
28
- # Save the model
29
- joblib.dump(promotion_model, "models/promotion_strategy_model.pkl")
30
- print("Promotion Strategy Model saved to models/promotion_strategy_model.pkl")
 
 
 
 
 
 
 
 
 
 
 
4
  from sklearn.metrics import accuracy_score
5
  import joblib
6
  from utils.preprocessing import preprocess_data
7
+ from huggingface_hub import HfApi, login
8
+ import os
9
 
10
  def train_promotion_strategy():
11
  """Train the promotion strategy model."""
 
27
  accuracy = accuracy_score(y_test, y_pred)
28
  print(f"Promotion Prediction Model Accuracy: {accuracy:.4f}")
29
 
30
+ # Save the model locally
31
+ joblib.dump(promotion_model, "promotion_strategy_model.pkl")
32
+
33
+ # Upload the model to Hugging Face Hub
34
+ login(token=os.environ.get("HF_TOKEN")) # Use your Hugging Face token
35
+ api = HfApi()
36
+ api.upload_file(
37
+ path_or_fileobj="promotion_strategy_model.pkl",
38
+ path_in_repo="promotion_strategy_model.pkl",
39
+ repo_id="Fred808/Insta-8084", # Replace with your repo
40
+ repo_type="model",
41
+ )
42
+ print("Promotion Strategy Model uploaded to Hugging Face Hub!")
scripts/train_time_series.py CHANGED
@@ -3,6 +3,8 @@ from prophet import Prophet
3
  from sklearn.metrics import mean_absolute_error
4
  import joblib
5
  from utils.preprocessing import preprocess_data
 
 
6
 
7
  def train_time_series():
8
  """Train the time-series model for optimal posting times."""
@@ -18,6 +20,16 @@ def train_time_series():
18
  prophet_model = Prophet()
19
  prophet_model.fit(time_series_data)
20
 
21
- # Save the model
22
- joblib.dump(prophet_model, "models/prophet_model.pkl")
23
- print("Prophet Model saved to models/prophet_model.pkl")
 
 
 
 
 
 
 
 
 
 
 
3
  from sklearn.metrics import mean_absolute_error
4
  import joblib
5
  from utils.preprocessing import preprocess_data
6
+ from huggingface_hub import HfApi, login
7
+ import os
8
 
9
  def train_time_series():
10
  """Train the time-series model for optimal posting times."""
 
20
  prophet_model = Prophet()
21
  prophet_model.fit(time_series_data)
22
 
23
+ # Save the model locally
24
+ joblib.dump(prophet_model, "prophet_model.pkl")
25
+
26
+ # Upload the model to Hugging Face Hub
27
+ login(token=os.environ.get("HF_TOKEN")) # Use your Hugging Face token
28
+ api = HfApi()
29
+ api.upload_file(
30
+ path_or_fileobj="prophet_model.pkl",
31
+ path_in_repo="prophet_model.pkl",
32
+ repo_id="Fred808/Insta-8084", # Replace with your repo
33
+ repo_type="model",
34
+ )
35
+ print("Prophet Model uploaded to Hugging Face Hub!")
scripts/train_viral_potential.py CHANGED
@@ -4,6 +4,8 @@ from sklearn.model_selection import train_test_split
4
  from sklearn.metrics import accuracy_score
5
  import joblib
6
  from utils.preprocessing import preprocess_data
 
 
7
 
8
  def train_viral_potential():
9
  """Train the viral potential prediction model."""
@@ -25,6 +27,16 @@ def train_viral_potential():
25
  accuracy = accuracy_score(y_test, y_pred)
26
  print(f"Viral Potential Model Accuracy: {accuracy:.4f}")
27
 
28
- # Save the model
29
- joblib.dump(viral_model, "models/viral_potential_model.pkl")
30
- print("Viral Potential Model saved to models/viral_potential_model.pkl")
 
 
 
 
 
 
 
 
 
 
 
4
  from sklearn.metrics import accuracy_score
5
  import joblib
6
  from utils.preprocessing import preprocess_data
7
+ from huggingface_hub import HfApi, login
8
+ import os
9
 
10
  def train_viral_potential():
11
  """Train the viral potential prediction model."""
 
27
  accuracy = accuracy_score(y_test, y_pred)
28
  print(f"Viral Potential Model Accuracy: {accuracy:.4f}")
29
 
30
+ # Save the model locally
31
+ joblib.dump(viral_model, "viral_potential_model.pkl")
32
+
33
+ # Upload the model to Hugging Face Hub
34
+ login(token=os.environ.get("HF_TOKEN")) # Use your Hugging Face token
35
+ api = HfApi()
36
+ api.upload_file(
37
+ path_or_fileobj="viral_potential_model.pkl",
38
+ path_in_repo="viral_potential_model.pkl",
39
+ repo_id="Fred808/Insta-8084", # Replace with your repo
40
+ repo_type="model",
41
+ )
42
+ print("Viral Potential Model uploaded to Hugging Face Hub!")