<jupyter_start><jupyter_text>**Read the children emergency data**<jupyter_code>df=pd.read_csv('/kaggle/input/children-vitals/children_vitals_emergency_data_big_juliet.csv')
df.head()<jupyter_output><empty_output><jupyter_text>**Lets Explore the data**<jupyter_code>df.em_score.value_counts()<jupyter_output><empty_output><jupyter_text>**Getting data mean of different emergency classes**<jupyter_code>df.groupby('em_score').mean()
#display basic statistics from the data
df.describe()<jupyter_output><empty_output><jupyter_text>**Scatter plots of emergency against temp**<jupyter_code>plt.scatter(x=df.temp[df.em_score==1], y=df.heart_rate[(df.em_score==1)], c="red")
plt.scatter(x=df.temp[df.em_score==0.5], y=df.heart_rate[(df.em_score==0.5)], c="blue")
plt.scatter(x=df.temp[df.em_score==0], y=df.heart_rate[(df.em_score==0)], c="green")
plt.legend(["Med_Emergency", "Moderate Emergency","Not Med_Emergency"])
plt.xlabel("Body Temperature")
plt.ylabel("Heart Rate")
plt.show()<jupyter_output><empty_output><jupyter_text>Using SVM to model the data Problem DescriptionPredict the Children Medical Emergency based on given attributes0 - NO EMERGECNY0.5 - MODERATE EMERENCY1- HIGH EMERGENCY<jupyter_code>data=df.drop('em_score',axis=1)
data.head()
#Display basic info about the data
data.info()
#Separate features from th emergency output
y = data.emer_label
x = data.drop('emer_label',axis = 1) 

#Splitting data into training set and testing set
x_train, x_test, y_train, y_test = train_test_split(x, y, train_size=0.7,test_size=0.3,random_state=109) # 70% training and 30% test
from sklearn.model_selection import GridSearchCV
#Create a svm Classifier

# defining hyperparameters range
param_grid = {'C': [0.1, 1, 10, 100, 1000], 
              'gamma': [1, 0.1, 0.01, 0.001, 0.0001],
              'kernel': ['linear']} 
  
model = GridSearchCV(SVC(), param_grid, refit = True, verbose = 3)
  
# fitting the model for grid search
model.fit(x_train, y_train)
# print best parameter after tuning
print(model.best_params_)
  
# print how our model looks after hyper-parameter tuning
print(model.best_estimator_)
model=SVC(kernel='linear',C=0.1, gamma=1)
model.fit(x_train, y_train)<jupyter_output><empty_output><jupyter_text>SVM MODEL EVALUATION<jupyter_code>#Check the performance of SVM, if less, try another classifier
#Predict the response for test dataset
y_pred = model.predict(x_test)

# Model Accuracy: how often is the classifier correct?
print("Accuracy of Support Vector Machine:",metrics.accuracy_score(y_test, y_pred))<jupyter_output><empty_output><jupyter_text>Decision Tree Classifier<jupyter_code>from sklearn.tree import DecisionTreeClassifier
dtc = DecisionTreeClassifier()
dtc.fit(x_train, y_train)

acc = dtc.score(x_test, y_test)*100

print("Decision Tree Test Accuracy {:.2f}%".format(acc))
#ROC Curve for the decision tree
y_pred=dtc.predict(x_test)

y_proba=dtc.predict_proba(x_test)

cm=confusion_matrix(y_test,y_pred)
print(cm)
sns.heatmap(cm,annot=True)
plt.show()
y_classes=['NON','MODERATE','EMERGENCY']
fig = plt.figure(figsize=(25,20))
_ = tree.plot_tree(dtc, 
                   feature_names=x.columns,  
                   class_names=y_classes,
                   filled=True)
#Trying to predict some emergency
x=np.array([[1.0,37.5,98,110,88,46]])
x.reshape(1,-1)
y_em=dtc.predict(x)
print(y_em)
#Using some data to predict emergency
from sklearn.metrics import classification_report
report = classification_report(y_true=y_test, y_pred=y_pred)
print(report)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1327659574468085, 'fraction_numerical': 0.02269503546099291, 'mean_word_length': 6.599137931034483, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '396748', 'license': 'MIT', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1276, 'n_words': 256, 'path': 'notebook63646d32f7 (2).ipynb', 'repo_name': 'JohnGatara/Children_Emergency_Cases_Prediction', 'size': '3525'}