Exemplo n.º 1
0
def combine_mul_row_treat(data_part2):
    logger.info('Combine Treatment with multiple rows!')

    new_treat = pd.DataFrame({})
    logger.info('Start processing categorical features!')
    logger.debug('FractionNumber')
    new_treat['FractionNumber'] = data_part2.groupby(['PatientSerNum', 'date']).FractionNumber.apply(set)
    new_treat['FractionNumber'] = new_treat['FractionNumber'].apply(lambda x: get_list(x))

    logger.debug('UserName')
    new_treat['UserName'] = data_part2.groupby(['PatientSerNum', 'date']).UserName.apply(set)
    new_treat['UserName'] = new_treat['UserName'].apply(lambda x: get_list(x))

    logger.debug('RadiationSerNum')
    new_treat['RadiationSerNum'] = data_part2.groupby(['PatientSerNum', 'date']).RadiationSerNum.apply(set)
    new_treat['RadiationSerNum'] = new_treat['RadiationSerNum'].apply(lambda x: get_list(x))

    #     print('Start RadiationId')
    #     new_treat['RadiationId'] = data_part2.groupby(['PatientSerNum', 'date']).RadiationId.apply(set)
    #     new_treat['RadiationId'] = new_treat['RadiationId'].apply(lambda x: get_list(x))

    logger.debug('ResourceSerNum')
    new_treat['ResourceSerNum'] = data_part2.groupby(['PatientSerNum', 'date']).ResourceSerNum.apply(set)
    new_treat['ResourceSerNum'] = new_treat['ResourceSerNum'].apply(lambda x: get_list(x))

    logger.debug('CourseId')
    new_treat['CourseId'] = data_part2.groupby(['PatientSerNum', 'date']).CourseId.apply(set)
    new_treat['CourseId'] = new_treat['CourseId'].apply(lambda x: get_list(x))

    logger.debug('PatientSerNum')
    new_treat['PatientSerNum'] = new_treat.index.get_level_values(level=0).tolist()

    logger.debug('date')
    new_treat['date'] = new_treat.index.get_level_values(level=1).tolist()

    logger.info('Start processing numerical features!')
    logger.debug('ImagesTaken_total')
    new_treat['ImagesTaken_total'] = data_part2.groupby(['PatientSerNum', 'date']).ImagesTaken.sum()

    logger.debug('MU_total')
    new_treat['MU_total'] = data_part2.groupby(['PatientSerNum', 'date']).MU.sum()

    logger.debug('MUCoeff_total')
    new_treat['MUCoeff_total'] = data_part2.groupby(['PatientSerNum', 'date']).MUCoeff.sum()

    logger.debug('TreatmentTime_total')
    new_treat['TreatmentTime_total'] = data_part2.groupby(['PatientSerNum', 'date']).TreatmentTime.sum()

    new_treat = new_treat.reset_index(drop=True)
    return new_treat
Exemplo n.º 2
0
import torchvision.models as models
import torch.nn as nn
from torch.autograd import Variable
import matplotlib.pyplot as plt
import random
from PIL import Image

test_set_path = 'LFW_annotation_test.txt'
max_epochs = 70
learning_rate = 0.0001
pretrained = True
str_pre = 'pre'
file_name = 'lfw_resnet_' + str(learning_rate) + '_' + str(
    max_epochs) + '_' + str_pre

test_list = dp.get_list(test_set_path)
test_dataset = dp.LFWDataSet(test_list)

test_data_loader = torch.utils.data.DataLoader(test_dataset,
                                               batch_size=64,
                                               shuffle=False,
                                               num_workers=0)
print('test items: ', len(test_dataset))

# use ResNet18
net = resnet.resnet18(pretrained=True, num_classes=14)
net.cuda()

test_net_state = torch.load(os.path.join('.', file_name + '.pth'))
net.load_state_dict(test_net_state)
net.eval()
Exemplo n.º 3
0
def combine_mul_row_appt(data_part1):
    logger.info('Combine Appointment with multiple rows!')

    new_appt = pd.DataFrame({})
    logger.info('Start processing categorical features!')
    logger.debug('PatientSerNum')
    new_appt['PatientSerNum'] = data_part1.groupby('AppointmentSerNum').PatientSerNum.apply(set)
    new_appt['PatientSerNum'] = new_appt['PatientSerNum'].apply(lambda x: get_list(x))

    logger.debug('Sex')
    new_appt['Sex'] = data_part1.groupby('AppointmentSerNum').Sex.apply(set)
    new_appt['Sex'] = new_appt['Sex'].apply(lambda x: get_list(x))

    logger.debug('DoctorSerNum')
    new_appt['DoctorSerNum'] = data_part1.groupby('AppointmentSerNum').DoctorSerNum.apply(set)
    new_appt['DoctorSerNum'] = new_appt['DoctorSerNum'].apply(lambda x: get_list(x))

    logger.debug('date')
    new_appt['date'] = data_part1.groupby('AppointmentSerNum').date.apply(set)
    new_appt['date'] = new_appt['date'].apply(lambda x: get_list(x))

    logger.debug('ScheduledStartTime')
    new_appt['ScheduledStartTime'] = data_part1.groupby('AppointmentSerNum').ScheduledStartTime.apply(set)
    new_appt['ScheduledStartTime'] = new_appt['ScheduledStartTime'].apply(lambda x: get_list(x))

    logger.debug('ScheduledEndTime')
    new_appt['ScheduledEndTime'] = data_part1.groupby('AppointmentSerNum').ScheduledEndTime.apply(set)
    new_appt['ScheduledEndTime'] = new_appt['ScheduledEndTime'].apply(lambda x: get_list(x))

    logger.debug('ActualStartDate')
    new_appt['ActualStartDate'] = data_part1.groupby('AppointmentSerNum').ActualStartDate.apply(set)
    new_appt['ActualStartDate'] = new_appt['ActualStartDate'].apply(lambda x: get_list(x))

    logger.debug('ActualEndDate')
    new_appt['ActualEndDate'] = data_part1.groupby('AppointmentSerNum').ActualEndDate.apply(set)
    new_appt['ActualEndDate'] = new_appt['ActualEndDate'].apply(lambda x: get_list(x))

    logger.debug('dxt_AliasName')
    new_appt['dxt_AliasName'] = data_part1.groupby('AppointmentSerNum').dxt_AliasName.apply(set)
    new_appt['dxt_AliasName'] = new_appt['dxt_AliasName'].apply(lambda x: get_list(x))

    logger.debug('AliasSerNum')
    new_appt['AliasSerNum'] = data_part1.groupby('AppointmentSerNum').AliasSerNum.apply(set)
    new_appt['AliasSerNum'] = new_appt['AliasSerNum'].apply(lambda x: get_list(x))

    logger.debug('CourseSerNum')
    new_appt['CourseSerNum'] = data_part1.groupby('AppointmentSerNum').CourseSerNum.apply(set)
    new_appt['CourseSerNum'] = new_appt['CourseSerNum'].apply(lambda x: get_list(x))

    logger.debug('PlanSerNum')
    new_appt['PlanSerNum'] = data_part1.groupby('AppointmentSerNum').PlanSerNum.apply(set)
    new_appt['PlanSerNum'] = new_appt['PlanSerNum'].apply(lambda x: get_list(x))

    logger.debug('TreatmentOrientation')
    new_appt['TreatmentOrientation'] = data_part1.groupby('AppointmentSerNum').TreatmentOrientation.apply(set)
    new_appt['TreatmentOrientation'] = new_appt['TreatmentOrientation'].apply(lambda x: get_list(x))

    logger.debug('month')
    new_appt['month'] = data_part1.groupby('AppointmentSerNum').month.apply(set)
    new_appt['month'] = new_appt['month'].apply(lambda x: get_list(x))

    logger.debug('week')
    new_appt['week'] = data_part1.groupby('AppointmentSerNum').week.apply(set)
    new_appt['week'] = new_appt['week'].apply(lambda x: get_list(x))

    logger.debug('hour')
    new_appt['hour'] = data_part1.groupby('AppointmentSerNum').hour.apply(set)
    new_appt['hour'] = new_appt['hour'].apply(lambda x: get_list(x))

    logger.debug('AppointmentSerNum')
    new_appt['AppointmentSerNum'] = new_appt.index.tolist()

    logger.info('Start processing numerical features!')
    logger.debug('age')
    new_appt['age'] = data_part1.groupby('AppointmentSerNum').age.mean()

    logger.debug('Scheduled_duration')
    new_appt['Scheduled_duration'] = data_part1.groupby('AppointmentSerNum').Scheduled_duration.mean()

    logger.debug('Actual_duration')
    new_appt['Actual_duration'] = data_part1.groupby('AppointmentSerNum').Actual_duration.mean()

    new_appt = new_appt.reset_index(drop=True)
    return new_appt
Exemplo n.º 4
0
import torchvision.models as models
import torch.nn as nn
from torch.autograd import Variable
import matplotlib.pyplot as plt

torch.set_default_tensor_type('torch.cuda.FloatTensor')

train_set_path = 'LFW_annotation_train.txt'
max_epochs = 180
learning_rate = 0.0001
pretrained = True
str_pre = 'pre'
file_name = 'lfw_alexnet_' + str(learning_rate) + '_' + str(
    max_epochs) + '_' + str_pre

train_list = dp.get_list(train_set_path)
valid_list = train_list[-2000:]
train_list = train_list[:-2000]

transform = ['flip', 'rcrop']
train_dataset = dp.LFWDataSet(train_list, transform=transform)
train_data_loader = torch.utils.data.DataLoader(train_dataset,
                                                batch_size=64,
                                                shuffle=False,
                                                num_workers=0)
print('training items:', len(train_dataset))

valid_dataset = dp.LFWDataSet(valid_list, transform=transform)
valid_data_loader = torch.utils.data.DataLoader(valid_dataset,
                                                batch_size=64,
                                                shuffle=True,