Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -71,10 +71,10 @@ def extract_features(sequence):
|
|
| 71 |
all_features_dict.update(pseudo_features)
|
| 72 |
|
| 73 |
feature_values = list(all_features_dict.values())
|
| 74 |
-
feature_array = np.array(feature_values).reshape(1,
|
| 75 |
print(f"Shape of feature_array before normalization: {feature_array.shape}") # Debug print
|
| 76 |
|
| 77 |
-
normalized_features = scaler.transform(feature_array) # Normalize - NO TRANSPOSE
|
| 78 |
normalized_features = normalized_features.flatten() # Flatten AFTER normalization if needed
|
| 79 |
|
| 80 |
|
|
@@ -84,7 +84,7 @@ def extract_features(sequence):
|
|
| 84 |
selected_feature_dict[feature] = normalized_features[i]
|
| 85 |
|
| 86 |
selected_feature_df = pd.DataFrame([selected_feature_dict])
|
| 87 |
-
selected_feature_array = selected_feature_df.to_numpy()
|
| 88 |
|
| 89 |
return selected_feature_array
|
| 90 |
|
|
@@ -95,8 +95,8 @@ def predict(sequence):
|
|
| 95 |
if isinstance(features, str) and features.startswith("Error:"):
|
| 96 |
return features
|
| 97 |
|
| 98 |
-
prediction = model.predict(features)[0]
|
| 99 |
-
probabilities = model.predict_proba(features)[0]
|
| 100 |
|
| 101 |
if prediction == 0:
|
| 102 |
return f"{probabilities[0] * 100:.2f}% chance of being an Antimicrobial Peptide (AMP)"
|
|
|
|
| 71 |
all_features_dict.update(pseudo_features)
|
| 72 |
|
| 73 |
feature_values = list(all_features_dict.values())
|
| 74 |
+
feature_array = np.array(feature_values).reshape(-1, 1) # Reshape to (1, n_features) - CORRECT SHAPE
|
| 75 |
print(f"Shape of feature_array before normalization: {feature_array.shape}") # Debug print
|
| 76 |
|
| 77 |
+
normalized_features = scaler.transform(feature_array.T) # Normalize - NO TRANSPOSE
|
| 78 |
normalized_features = normalized_features.flatten() # Flatten AFTER normalization if needed
|
| 79 |
|
| 80 |
|
|
|
|
| 84 |
selected_feature_dict[feature] = normalized_features[i]
|
| 85 |
|
| 86 |
selected_feature_df = pd.DataFrame([selected_feature_dict])
|
| 87 |
+
selected_feature_array = selected_feature_df.T.to_numpy()
|
| 88 |
|
| 89 |
return selected_feature_array
|
| 90 |
|
|
|
|
| 95 |
if isinstance(features, str) and features.startswith("Error:"):
|
| 96 |
return features
|
| 97 |
|
| 98 |
+
prediction = model.predict(features.T)[0]
|
| 99 |
+
probabilities = model.predict_proba(features.T)[0]
|
| 100 |
|
| 101 |
if prediction == 0:
|
| 102 |
return f"{probabilities[0] * 100:.2f}% chance of being an Antimicrobial Peptide (AMP)"
|