# mlapp/views.py
from rest_framework.views import APIView
from rest_framework.response import Response
class PredictionAPI(APIView):
def post(self, request):
# Load your machine learning model
model = load_model() # Replace with your model loading code
# Get input data from the request
input_data = request.data.get('data')
# Perform predictions
prediction = model.predict(input_data)
# Return the prediction as a JSON response
return Response({'prediction': prediction})