### Neuron Class for Binary Classification
This project defines a `Neuron` class in Python that simulates a single neuron used for binary classification tasks in machine learning.
---
### Features
- Validates input for number of features (`nx`)
- Initializes:
- `W`: Weights vector using a random normal distribution
- `b`: Bias, initialized to `0`
- `A`: Activated output, initialized to `0`
---
### Class Definition
```python
class Neuron:
def __init__(self, nx):
...nx(int): Number of input features to the neuron
TypeError: Ifnxis not an integerValueError: Ifnxis less than 1
W: Weights vector (NumPy array)b: Bias (float)A: Activated output (float)
from neuron import Neuron # The class is saved in Live coding - Neuron .ipynb
n = Neuron(3)
print("Weights:", n.W)
print("Bias:", n.b)
print("Activated Output:", n.A)n = Neuron("3") # Raises TypeError: nx must be an integer
n = Neuron(0) # Raises ValueError: nx must be a positive integerproject-folder/
β
βββ Live coding - Neuron .ipynb # Contains the Neuron class
βββ README.md # Project documentation
- Python 3.x
- NumPy
Install NumPy using pip:
pip install numpyYou can test this class in a Python script or interactive shell. For unit testing, consider using unittest or pytest.
Kanisa
Jolly