exp 10:
# Import libraries
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import accuracy_score

# Load dataset (Iris)
data = load_iris()
X = data.data      # Features
y = data.target    # Labels

# Split data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Create a Multi-Layer Neural Network model
model = MLPClassifier(
    hidden_layer_sizes=(10, 5),   # Two hidden layers: 10 neurons, then 5
    activation='relu',            # Activation function
    solver='adam',                # Optimization algorithm
    max_iter=1000,                # Number of training iterations
    random_state=42
)

# Train the model
model.fit(X_train, y_train)

# Predict on test data
y_pred = model.predict(X_test)

# Evaluate performance
print("Accuracy:", accuracy_score(y_test, y_pred))



