Spaces:
Sleeping
Sleeping
Commit ·
c926705
1
Parent(s): a636254
Oracle
Browse files352 unmodified lines353354355356357358359360361362363364365366120 unmodified lines48748848949049149236 unmodified lines529530531532533534535352 unmodified linesplt.title("Feature Correlation Matrix", fontsize=16)plt.show()def normalize_funding(df):"""Normalize funding weights for child repositories grouped by parent."""print("[INFO] Normalizing funding weights...", flush=True)df["final_weight"] = df.groupby("parent")["final_weight"].transform(lambda x: x / x.sum() if x.sum() > 0 else 1 / len(x))print("[INFO] Funding weights normalized successfully.", flush=True)return df120 unmodified linesif X.shape[0] < 5 or X.shape[1] == 0 or y.nunique() <=1:print("[WARN] Not enough data or variance for model training. Using base weights directly.")df["final_weight"] = df["base_weight"]return df# Split data into train/test sets36 unmodified linesexcept Exception as e:print(f"[ERROR] Model training failed: {e}")df["final_weight"] = df["base_weight"]end_time = time.time()print(f"[INFO] Weight prediction completed in {end_time - start_time:.2f} seconds.", flush=True)return df352 unmodified lines353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383120 unmodified lines50450550650750850951036 unmodified lines547548549550551552553352 unmodified linesplt.title("Feature Correlation Matrix", fontsize=16)plt.show()def normalize_and_clip_weights(df,group_col="parent",weight_col ="final_weight"):"""Ensures all weights are non-negative and sum to 1 within each group."""#Clip negative weights to zerodf[weight_col] = df[weight_col].clip(lower=0)#Normalize weights within each groupdef normalize_group(x):total = x.sum()if total>0:return x/totalelse:return np.ones_like(x)/ len(x)df[weight_col] = df.groupby(group_col)[weight_col].transform(normalize_group)return dfdef normalize_funding(df):"""Normalize funding weights for child repositories grouped by parent."""print("[INFO] Normalizing funding weights...", flush=True)df = normalize_and_clip_weights(df)print("[INFO] Funding weights normalized successfully.", flush=True)return df120 unmodified linesif X.shape[0] < 5 or X.shape[1] == 0 or y.nunique() <=1:print("[WARN] Not enough data or variance for model training. Using base weights directly.")df["final_weight"] = df["base_weight"]df = normalize_and_clip_weights(df)return df# Split data into train/test sets36 unmodified linesexcept Exception as e:print(f"[ERROR] Model training failed: {e}")df["final_weight"] = df["base_weight"]df = normalize_and_clip_weights(df)end_time = time.time()print(f"[INFO] Weight prediction completed in {end_time - start_time:.2f} seconds.", flush=True)return df
Oracle/deepfundingoracle.py+22-4