Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -57,14 +57,17 @@ def extract_features(sequence):
|
|
| 57 |
|
| 58 |
# Convert to DataFrame
|
| 59 |
all_features_df = pd.DataFrame([all_features])
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
# Select only required features
|
| 62 |
all_features_df = all_features_df[selected_features]
|
| 63 |
|
| 64 |
-
# Ensure correct shape
|
| 65 |
-
if all_features_df.shape[0] == 0:
|
| 66 |
-
raise ValueError("No features extracted. Check the input sequence.")
|
| 67 |
-
|
| 68 |
# Normalize the features
|
| 69 |
normalized_features = scaler.transform(all_features_df)
|
| 70 |
|
|
|
|
| 57 |
|
| 58 |
# Convert to DataFrame
|
| 59 |
all_features_df = pd.DataFrame([all_features])
|
| 60 |
+
|
| 61 |
+
# Ensure all required features are present
|
| 62 |
+
missing_features = [feat for feat in selected_features if feat not in all_features_df.columns]
|
| 63 |
+
if missing_features:
|
| 64 |
+
print(f"Warning: Missing features - {missing_features}")
|
| 65 |
+
for feat in missing_features:
|
| 66 |
+
all_features_df[feat] = 0 # Fill missing features with 0
|
| 67 |
+
|
| 68 |
# Select only required features
|
| 69 |
all_features_df = all_features_df[selected_features]
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
# Normalize the features
|
| 72 |
normalized_features = scaler.transform(all_features_df)
|
| 73 |
|