Skip to content

Latest commit

Β 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“„ README.md

### 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):
        ...

Parameters

  • nx (int): Number of input features to the neuron

Raises

  • TypeError: If nx is not an integer
  • ValueError: If nx is less than 1

Public Attributes

  • W: Weights vector (NumPy array)
  • b: Bias (float)
  • A: Activated output (float)

Example Usage

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)

Error Handling

n = Neuron("3")   # Raises TypeError: nx must be an integer
n = Neuron(0)     # Raises ValueError: nx must be a positive integer

Project Structure

project-folder/
β”‚
β”œβ”€β”€ Live coding - Neuron .ipynb        # Contains the Neuron class
└── README.md         # Project documentation

Requirements

  • Python 3.x
  • NumPy

Install NumPy using pip:

pip install numpy

Testing

You can test this class in a Python script or interactive shell. For unit testing, consider using unittest or pytest.


✍️ Author

Kanisa

Jolly

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages