Implementation of XOR Problem using Neural Network in scikit-learn
Experiment
Implementation of XOR Problem using Neural Network in scikit-learn
🎯 Objective
- To implement a neural network using scikit-learn
- To solve the XOR classification problem
- To visualize the decision boundary
Theory
🔹 1. XOR Problem
XOR (Exclusive OR) outputs 1 when inputs are different:
| x1 | x2 | y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
🔹 2. Key Concept
- XOR is not linearly separable
- A single-layer model cannot solve it
- Requires a multi-layer neural network
🔹 3. Neural Network (MLPClassifier)
We use:
- Input layer: 2 neurons
- Hidden layer: 2 neurons
- Output layer: 1 neuron
🔹 4. Activation Function
-
Sigmoid (
logistic) function:
🔹 5. Optimizer
-
lbfgsis used:- Fast convergence
- Suitable for small datasets
💻 Program
🌈 Decision Boundary Visualization
🔍 Observations
- Model correctly classifies XOR outputs
- Decision boundary is non-linear
- Hidden layer enables separation
Result
- Neural network successfully solves XOR problem
- Visualization shows the decision boundary

Comments
Post a Comment