Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,6 +43,23 @@ selected_features = [
|
|
| 43 |
"APAAC24"
|
| 44 |
]
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
def extract_features(sequence):
|
| 47 |
"""Extract selected features and normalize them."""
|
| 48 |
|
|
@@ -54,18 +71,14 @@ def extract_features(sequence):
|
|
| 54 |
|
| 55 |
# Combine all extracted features
|
| 56 |
all_features = {**aa_features, **auto_features, **ctd_features, **pseaac_features}
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
#
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
# Normalize the features
|
| 65 |
-
normalized_features = scaler.transform(feature_df)
|
| 66 |
-
|
| 67 |
-
# Convert to a NumPy array in the expected format
|
| 68 |
-
selected_feature_array = normalized_features.flatten().reshape(1, -1)
|
| 69 |
|
| 70 |
return selected_feature_array
|
| 71 |
|
|
|
|
| 43 |
"APAAC24"
|
| 44 |
]
|
| 45 |
|
| 46 |
+
def extract_features(sequence):
|
| 47 |
+
"""Extract selected features and normalize them."""
|
| 48 |
+
all_features = AAComposition.CalculateAADipeptideComposition(sequence)
|
| 49 |
+
feature_values = list(all_features.values())
|
| 50 |
+
feature_array = np.array(feature_values).reshape(-1, 1)
|
| 51 |
+
feature_array = feature_array[: 420] # Ensure we only use 420 features
|
| 52 |
+
normalized_features = scaler.transform(feature_array.T)
|
| 53 |
+
normalized_features = normalized_features.flatten()
|
| 54 |
+
|
| 55 |
+
# Select features that match training data
|
| 56 |
+
selected_feature_dict = {feature: normalized_features[i] for i, feature in enumerate(selected_features)
|
| 57 |
+
if feature in all_features}
|
| 58 |
+
selected_feature_df = pd.DataFrame([selected_feature_dict])
|
| 59 |
+
selected_feature_array = selected_feature_df.T.to_numpy()
|
| 60 |
+
|
| 61 |
+
return selected_feature_array
|
| 62 |
+
|
| 63 |
def extract_features(sequence):
|
| 64 |
"""Extract selected features and normalize them."""
|
| 65 |
|
|
|
|
| 71 |
|
| 72 |
# Combine all extracted features
|
| 73 |
all_features = {**aa_features, **auto_features, **ctd_features, **pseaac_features}
|
| 74 |
+
normalized_features = scaler.transform(all_features.T)
|
| 75 |
+
normalized_features = normalized_features.flatten()
|
| 76 |
|
| 77 |
+
# Select features that match training data
|
| 78 |
+
selected_feature_dict = {feature: normalized_features[i] for i, feature in enumerate(selected_features)
|
| 79 |
+
if feature in all_features}
|
| 80 |
+
selected_feature_df = pd.DataFrame([selected_feature_dict])
|
| 81 |
+
selected_feature_array = selected_feature_df.T.to_numpy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
return selected_feature_array
|
| 84 |
|