Implement a single neuron that takes inputs, applies weights and a bias, and uses a sigmoid activation function. Return the activated output.
import math
def single_neuron(features: list[list[float]], labels: list[int],
weights: list[float], bias: float) -> tuple[list[float], float]:
outputs = []
for x in features:
z = sum(x[i] * weights[i] for i in range(len(weights))) + bias
a = 1 / (1 + math.exp(-z))
outputs.append(a)
# Compute MSE loss
mse = sum((outputs[i] - labels[i]) ** 2 for i in range(len(labels))) / len(labels)
return [round(o, 4) for o in outputs], round(mse, 4)