Spaces:
Paused
Paused
Update src/peri/value_chains.py
Browse files- src/peri/value_chains.py +6 -6
src/peri/value_chains.py
CHANGED
|
@@ -61,9 +61,9 @@ def analyze_budget_trend(data:pd.DataFrame):
|
|
| 61 |
|
| 62 |
# 3. Apply numpy.select with a default fallback value
|
| 63 |
df["trend"] = np.select(conditions, choices, default=np.nan)
|
| 64 |
-
return df
|
| 65 |
|
| 66 |
-
def get_scores(data:pd.DataFrame):
|
| 67 |
df = data.copy()
|
| 68 |
results = df[["value_chain", "trend"]].reset_index(drop=True)
|
| 69 |
|
|
@@ -79,9 +79,9 @@ def get_scores(data:pd.DataFrame):
|
|
| 79 |
results["strategic_importance_score"] = (0.8*df[strat_imp_cols].sum(axis=1))+(0.2*results["breadth"]).reset_index(drop=True)
|
| 80 |
results["institutional_committment_score"] = df[[c for c in df.columns if "value" in c and "institutional_commitment" in c]].sum(axis=1)
|
| 81 |
|
| 82 |
-
return normalize_committment_scores(results)
|
| 83 |
|
| 84 |
-
def normalize_committment_scores(results:pd.DataFrame):
|
| 85 |
|
| 86 |
results["trend_normalized"] = (results["trend"]-min(1, results["trend"].min()))/max(len(conditions), results["trend"].max())
|
| 87 |
results["strategic_importance_normalized"] = results["strategic_importance_score"]/3.4
|
|
@@ -97,5 +97,5 @@ def analyze_vc_committment(llm_outputs:Dict):
|
|
| 97 |
c2vc_df = c2vc_df.replace("NOT_FOUND", 0)
|
| 98 |
c2vc_df = c2vc_df.replace("NO", 0)
|
| 99 |
|
| 100 |
-
trend = analyze_budget_trend(c2vc_df)
|
| 101 |
-
return get_scores(trend)
|
|
|
|
| 61 |
|
| 62 |
# 3. Apply numpy.select with a default fallback value
|
| 63 |
df["trend"] = np.select(conditions, choices, default=np.nan)
|
| 64 |
+
return df, conditions
|
| 65 |
|
| 66 |
+
def get_scores(data:pd.DataFrame, conditions:List):
|
| 67 |
df = data.copy()
|
| 68 |
results = df[["value_chain", "trend"]].reset_index(drop=True)
|
| 69 |
|
|
|
|
| 79 |
results["strategic_importance_score"] = (0.8*df[strat_imp_cols].sum(axis=1))+(0.2*results["breadth"]).reset_index(drop=True)
|
| 80 |
results["institutional_committment_score"] = df[[c for c in df.columns if "value" in c and "institutional_commitment" in c]].sum(axis=1)
|
| 81 |
|
| 82 |
+
return normalize_committment_scores(results, conditions)
|
| 83 |
|
| 84 |
+
def normalize_committment_scores(results:pd.DataFrame, conditions:List):
|
| 85 |
|
| 86 |
results["trend_normalized"] = (results["trend"]-min(1, results["trend"].min()))/max(len(conditions), results["trend"].max())
|
| 87 |
results["strategic_importance_normalized"] = results["strategic_importance_score"]/3.4
|
|
|
|
| 97 |
c2vc_df = c2vc_df.replace("NOT_FOUND", 0)
|
| 98 |
c2vc_df = c2vc_df.replace("NO", 0)
|
| 99 |
|
| 100 |
+
trend, conditions = analyze_budget_trend(c2vc_df)
|
| 101 |
+
return get_scores(trend, conditions)
|