Clean up features model

This commit is contained in:
Chris Proctor
2026-06-08 15:37:17 -04:00
parent 49c4e43f45
commit 95278c854d

View File

@@ -11,26 +11,10 @@ class FeatureExtractor:
return [self.extract_features(pixels) for pixels in X]
def extract_features(self, pixels):
"""Extract hand-designed features from a 784-pixel image.
Add at least two features of your own. Each feature should be a
number computed from the pixel array.
Arguments:
pixels: numpy array of 784 float values in [0, 1]
Returns:
dict: feature name -> numerical value
"""
img = pixels.reshape(28, 28)
return {
"mean_brightness": float(pixels.mean()),
"top_half_brightness": float(img[:14, :].mean()),
"bottom_half_brightness": float(img[14:, :].mean()),
# ---- Add your features here ----
# "left_half_brightness": float(img[:, :14].mean()),
# "right_half_brightness": float(img[:, 14:].mean()),
# "num_bright_pixels": float((pixels > 0.5).sum()),
}