Scripts to create a dataset from Redcap outputs to use for a PLS-DA classification.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.7 KiB

# -*- coding: utf-8 -*-
Created on Fri May 14 09:18:32 2021
@author: Dijkhofmf
# Import stuff
import os
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import preprocessing
#%% Import data and path
Path = 'I:\Mike Dijkhof\Connecare MGP\Data\FinalFiles'
# Set path
#%% Create DF
FinalDF = pd.DataFrame(pd.read_csv('FinalDataset.csv'))
X = pd.DataFrame(FinalDF)
cols = X.drop('Pt Type', axis=1)
ID = X['Study ID']
y = X['Pt Type']
y= y.replace('Healthy', 'No-complication')
X = X.drop(['Pt Type', 'Study ID'], axis=1)
X1 = pd.DataFrame(preprocessing.scale(X), columns=X.columns)
X1['Pt Type'] = y
X1.columns = ['Age (years)', 'Gender', 'Daily alcohol use', 'Medication',
'ASA-classification', 'Recurrent disease?', 'Comorb',
'Independent, with others', 'Smokes cigarettes/sigar', 'BMI', 'GFI',
'HADS_A', 'HADS Depression', 'ADL', 'iADL', 'TUG', 'Handgrip strength',
'Avg. Steps/day', 'Avg. MVPA/day', 'Pt Type']
plots = X1.columns
import matplotlib.pylab as pylab
params = {'legend.fontsize': 'x-large',
'axes.labelsize': 'x-large',
plots = plots[1:]
for x in plots:
name = str(plots[namecount])
sns.boxplot(x='Pt Type', y=x, data=X1, boxprops=dict(alpha=0.5))
sns.swarmplot(x='Pt Type', y=x, data=X1)
plt.title('Swarm-boxplot ' + name)
namecount = namecount +1