DEV Community

Nazim Shaikh
Nazim Shaikh

Posted on

ARTIFICIAL NEURAL NETWORK (ANN)

INTRODUCTION

Artificial Intelligence allows computers to perform tasks that normally require human intelligence. Artificial Neural Networks are an important part of AI and are inspired by the structure and functioning of the human brain.

WHAT IS AN ARTIFICIAL NEURAL NETWORK?

An Artificial Neural Network (ANN) is a machine learning model consisting of interconnected units called neurons. These neurons process information and learn patterns from data to make predictions and decisions.

STRUCTURE OF ANN

An Artificial Neural Network generally consists of three main layers.

  1. INPUT LAYER: Receives the input data.
  2. HIDDEN LAYER: Processes information and identifies patterns.
  3. OUTPUT LAYER: Produces the final result.

HOW DOES IT WORK?

  1. Input data is provided to the network.
  2. Neurons process information using weights and biases.
  3. Activation functions help generate outputs.
  4. Predictions are compared with actual results.
  5. Weights are adjusted during training to improve performance.

PYTHON IMPLEMENTATION

We can create an Artificial Neural Network using Scikit-learn.

Install the library:

pip install scikit-learn
Enter fullscreen mode Exit fullscreen mode

Python Code:

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.neural_network import MLPClassifier
from sklearn.pipeline import make_pipeline
from sklearn.metrics import accuracy_score

# Load dataset
data = load_iris()

X = data.data
y = data.target

# Split dataset
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42
)

# Create ANN model
model = make_pipeline(
    StandardScaler(),
    MLPClassifier(
        hidden_layer_sizes=(10,),
        max_iter=1000,
        random_state=42
    )
)

# Train model
model.fit(X_train, y_train)

# Predict results
predictions = model.predict(X_test)

# Calculate accuracy
accuracy = accuracy_score(y_test, predictions)

print("ANN Accuracy:", accuracy)
Enter fullscreen mode Exit fullscreen mode

OUTPUT

ANN Accuracy: A value between 0 and 1.

APPLICATIONS

  1. Face recognition.
  2. Speech recognition.
  3. Medical diagnosis support.
  4. Fraud detection.
  5. Weather forecasting.
  6. Pattern recognition.

ADVANTAGES

  • Learns complex patterns.
  • Handles different types of data.
  • Useful for prediction and classification.
  • Can improve through training.

LIMITATIONS

  • Requires sufficient training data.
  • Training can be computationally expensive.
  • Some neural networks are difficult to interpret.

CONCLUSION

Artificial Neural Networks are an important technology in modern Artificial Intelligence. They help computers learn from data and perform complex tasks. Their applications are growing in healthcare, education, finance and technology.

Top comments (0)