This is my views (django), help me add classification report and prediction probablity
from django.shortcuts import render

# Import necessary libraries for the API
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC
from sklearn.neighbors import KNeighborsClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.ensemble import GradientBoostingClassifier, AdaBoostClassifier
from xgboost import XGBClassifier  # Ensure you have xgboost installed
import joblib
import numpy as np

# Load your trained model
# model = joblib.load('path/to/iris_model.pkl')
# Global variable to store the model
model = None

class TrainModelView(APIView):
    def post(self, request):
        model_type = request.data.get('modelType')
        epochs = int(request.data.get('epochs', 100))

        # Load dataset and split (using the Iris dataset for example)
        iris = load_iris()
        X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=42)

        # Train based on selected model type
        if model_type == 'random_forest':
            model = RandomForestClassifier(n_estimators=epochs)
        elif model_type == 'decision_tree':
            model = DecisionTreeClassifier()
        elif model_type == 'logistic_regression':
            model = LogisticRegression(max_iter=epochs)
        elif model_type == 'svm':
            model = SVC()
        elif model_type == 'knn':
            model = KNeighborsClassifier(n_neighbors=epochs)  # Using epochs as number of neighbors
        elif model_type == 'naive_bayes':
            model = GaussianNB()
        elif model_type == 'gradient_boosting':
            model = GradientBoostingClassifier(n_estimators=epochs)
        elif model_type == 'adaboost':
            model = AdaBoostClassifier(n_estimators=epochs)
        elif model_type == 'xgboost':
            model = XGBClassifier(n_estimators=epochs)
        else:
            return Response({'error': 'Invalid model type'}, status=status.HTTP_400_BAD_REQUEST)

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

        # Save the model
        joblib.dump(model, f'{model_type}_model.joblib')

        return Response({'status': f'Model {model_type} trained successfully'}, status=status.HTTP_202_ACCEPTED)



class PredictView(APIView):
    def post(self, request):
        global model
        # Get the model type and input data from the request
        model_type = request.data.get('modelType')
        input_data = request.data.get('inputData')

        # Load the corresponding model
        try:
            model = joblib.load(f'{model_type}_model.joblib')
        except FileNotFoundError:
            return Response({'error': 'Model not found'}, status=status.HTTP_404_NOT_FOUND)

        # Ensure input data is in the correct format
        try:
            # Convert input data to a NumPy array
            input_features = np.array(input_data).reshape(1, -1)  # Reshape for a single sample
            prediction = model.predict(input_features)

            # Return the prediction result
            return Response({'prediction': prediction.tolist()}, status=status.HTTP_200_OK)

        except Exception as e:
            return Response({'error': str(e)}, status=status.HTTP_400_BAD_REQUEST)