Contents
Clinical trial is the foundation pillar of the drug discovery process. Roughly 1 in 10 of drugs tested in human subjects receive FDA approval. Given the title and summary of the clinical trial, this tool will predict if the clinical trial will be approved or not. This tool can be used in the nascent stage of the clinical trial process which can help the researchers take a better decision. This tool is trained on around 1200 approved/rejected clinical trials.
The csv file used in the model has 2 columns ,
Same kind of CSV file should be fed to the model for best output.
For reference, A sample CSV file is attached in the link. The user only needs to clik on the link to get it downloaded to the local. The data should be in a similar format like the sample csv.
Download sample Data from the link : Data Source for Feasibility Analysis
import pandas as pd
df = pd.read_csv('S3/Sagemaker path of FeasibilityAnalysis.csv file')
df.to_csv("sample.csv",index=False)
df.head(3)
df = pd.read_csv('FeasibilityAnalysis.csv')
df.to_csv("sample.csv",index=False)
df.head(3)
The model can be directly accessed via the console provided by AWS. However, for a more customized process one can access the model using the below code as well.
To create a model, import boto3, sagemaker and get the arn of the model package
import boto3
import sagemaker
role = sagemaker.get_execution_role()
smmp = boto3.client('sagemakermp')
modelName='Name of the model'
modelArn = 'Model ARN name'
createHeatIndexResponse = smmp.create_model(ModelName=modelName,\
Containers=[{'ModelPackageName': modelArn}],\
ExecutionRoleArn=role,\
EnableNetworkIsolation=True )
configName ='<Input Configuration Name>'
instanceType = '<Input Instance Type>'
createHeatIndexEndpointConfig = smmp.create_endpoint_config(EndpointConfigName = configName, ProductionVariants = [{'InstanceType':instanceType, 'InitialInstanceCount':1, 'ModelName':modelName, 'VariantName':'xyz'}])
endpointName = '<Input Endpoint Name>'
createHeatIndexEndpoint = smmp.create_endpoint(EndpointName = endpointName, EndpointConfigName = configName)
runtime = boto3.Session().client('runtime.sagemaker')
#Reading Input Data
with open('sample.csv','rb') as f:
payload = f.read()
response = runtime.invoke_endpoint(EndpointName = endpointName, ContentType = 'text/csv', Body = payload)
result = response['Body'].read().decode()
#Writing Output Data
with open('sampleOutput.txt','w') as f:
f.write(result)
If you're ready to be done with this notebook, please run the delete_endpoint line in the cell below. This will remove the hosted endpoint you created and avoid any charges from a stray instance being left on
sagemaker.Session().delete_endpoint(endpointName)
with open("./sampleOutput.txt","r") as f:
sampleResponse =f.read()
sampleResponse = sampleResponse.split('\n')
sampleResponse = [item.replace("'", "").replace('"', "") for item in sampleResponse]
sampleResponse