from sklearn.datasets import load_iris
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.svm import SVC
from sklearn.ensemble import RandomForestClassifier

# Load the iris dataset
iris = load_iris()

# Create a pipeline that combines multiple models
pipe = Pipeline([
    ('model', None),
])

# Define the hyperparameters for the pipeline
params = [
    {
        'model': [SVC()],
        'model__C': [0.1, 1, 10],
        'model__kernel': ['linear', 'rbf']
    },
    {
        'model': [RandomForestClassifier()],
        'model__n_estimators': [10, 50, 100],
        'model__max_depth': [None, 5, 10]
    }
]

# Specify a scoring metric for GridSearchCV
scoring_metric = 'accuracy'

# Use GridSearchCV to search over the hyperparameters
grid = GridSearchCV(pipe, params, cv=5, scoring=scoring_metric)
result=grid.fit(iris.data, iris.target)

#Printing the result
print(result)