Update src/ProcessOneSingleCampaign.py
Browse files- src/ProcessOneSingleCampaign.py +14 -18
src/ProcessOneSingleCampaign.py
CHANGED
|
@@ -553,21 +553,19 @@ class CampaignProcessor:
|
|
| 553 |
float: The transformed previous funding goal
|
| 554 |
"""
|
| 555 |
try:
|
| 556 |
-
#
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
print(f"No previous_funding_goal in input data, looking for alternative field names")
|
| 562 |
-
previous_goal = 0.0
|
| 563 |
|
| 564 |
-
# Apply logarithmic transformation
|
| 565 |
if previous_goal > 0:
|
| 566 |
-
# Log1p transformation, good for general compression while preserving relative differences
|
| 567 |
transformed_goal = np.log1p(previous_goal)/np.log(10)
|
| 568 |
print(f"Applied log transformation to previous_funding_goal: {previous_goal} β {transformed_goal}")
|
| 569 |
return transformed_goal
|
| 570 |
else:
|
|
|
|
| 571 |
return 0.0
|
| 572 |
|
| 573 |
except Exception as e:
|
|
@@ -589,21 +587,19 @@ class CampaignProcessor:
|
|
| 589 |
float: The transformed previous pledged amount
|
| 590 |
"""
|
| 591 |
try:
|
| 592 |
-
#
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
print(f"No previous_pledged in input data, looking for alternative field names")
|
| 598 |
-
pledged = 0.0
|
| 599 |
|
| 600 |
-
# Apply logarithmic transformation
|
| 601 |
if pledged > 0:
|
| 602 |
-
# Log1p transformation, good for general compression while preserving relative differences
|
| 603 |
transformed_pledge = np.log1p(pledged)/np.log(10)
|
| 604 |
print(f"Applied log transformation to previous_pledged: {pledged} β {transformed_pledge}")
|
| 605 |
return transformed_pledge
|
| 606 |
else:
|
|
|
|
| 607 |
return 0.0
|
| 608 |
|
| 609 |
except Exception as e:
|
|
|
|
| 553 |
float: The transformed previous funding goal
|
| 554 |
"""
|
| 555 |
try:
|
| 556 |
+
# Get the raw value
|
| 557 |
+
previous_goal = float(campaign.get('previous_funding_goal', 0))
|
| 558 |
+
|
| 559 |
+
# Log the source value
|
| 560 |
+
print(f"Previous funding goal raw value: {previous_goal}")
|
|
|
|
|
|
|
| 561 |
|
| 562 |
+
# Apply logarithmic transformation if value is positive
|
| 563 |
if previous_goal > 0:
|
|
|
|
| 564 |
transformed_goal = np.log1p(previous_goal)/np.log(10)
|
| 565 |
print(f"Applied log transformation to previous_funding_goal: {previous_goal} β {transformed_goal}")
|
| 566 |
return transformed_goal
|
| 567 |
else:
|
| 568 |
+
print(f"No transformation applied to previous_funding_goal: value is {previous_goal}")
|
| 569 |
return 0.0
|
| 570 |
|
| 571 |
except Exception as e:
|
|
|
|
| 587 |
float: The transformed previous pledged amount
|
| 588 |
"""
|
| 589 |
try:
|
| 590 |
+
# Get the raw value
|
| 591 |
+
pledged = float(campaign.get('previous_pledged', 0))
|
| 592 |
+
|
| 593 |
+
# Log the source value
|
| 594 |
+
print(f"Previous pledged raw value: {pledged}")
|
|
|
|
|
|
|
| 595 |
|
| 596 |
+
# Apply logarithmic transformation if value is positive
|
| 597 |
if pledged > 0:
|
|
|
|
| 598 |
transformed_pledge = np.log1p(pledged)/np.log(10)
|
| 599 |
print(f"Applied log transformation to previous_pledged: {pledged} β {transformed_pledge}")
|
| 600 |
return transformed_pledge
|
| 601 |
else:
|
| 602 |
+
print(f"No transformation applied to previous_pledged: value is {pledged}")
|
| 603 |
return 0.0
|
| 604 |
|
| 605 |
except Exception as e:
|