Source code for pipeline.preprocessing.features.class_map

import sys

import person
import emsfeatures
import mentalhealthfeatures
import miscfeatures
import jimsfeatures
import seqfeatures
import rsifeatures

[docs]class UnknownFeatureError(Exception): def __init__(self,feature): self.feature = feature def __str__(self): return "Unknown feature: {}".format(self.feature)
[docs]def lookup(feature, **kwargs): dict_lookup = {'gender': person.Gender(), 'race': person.Race(), 'age': person.Age(**kwargs), 'age_years': person.AgeYears(**kwargs), 'age_discrete': person.AgeDiscrete(**kwargs), 'ems_counts': emsfeatures.CountOfEms(**kwargs), 'jims_counts': jimsfeatures.CountOfJims(**kwargs), 'mh_counts': mentalhealthfeatures.CountOfMentalHealth(**kwargs), 'last_week_ems_count': emsfeatures.LastWeekEmsCount(**kwargs), 'last_week_mh_count': mentalhealthfeatures.LastWeekMhCount(**kwargs), 'last_week_jims_count': jimsfeatures.LastWeekJimsCount(**kwargs), 'last_year_ems_count': emsfeatures.LastYearEmsCount(**kwargs), 'last_year_mh_count': mentalhealthfeatures.LastYearMhCount(**kwargs), 'last_year_jims_count': jimsfeatures.LastYearJimsCount(**kwargs), 'last_month_ems_count': emsfeatures.LastMonthEmsCount(**kwargs), 'last_month_mh_count': mentalhealthfeatures.LastMonthMhCount(**kwargs), 'last_month_jims_count': jimsfeatures.LastMonthJimsCount(**kwargs), 'ems_triage': emsfeatures.TriageOfEms(**kwargs), 'last_year_mh_days_avg':mentalhealthfeatures.LastYearMhDaysAvg(**kwargs), 'last_year_mh_days_sum':mentalhealthfeatures.LastYearMhDaysSum(**kwargs), 'last_year_mh_days_stddev':mentalhealthfeatures.LastYearMhDaysStddev(**kwargs), 'last_year_jail_days_sum':jimsfeatures.LastYearJailDaysSum(**kwargs), 'last_year_jail_days_avg':jimsfeatures.LastYearJailDaysAvg(**kwargs), 'last_year_jail_days_stddev':jimsfeatures.LastYearJailDaysStddev(**kwargs), 'avg_length_between_event' : miscfeatures.AvgDaysBetweenEvents(**kwargs), 'std_length_between_event' : miscfeatures.StdDaysBetweenEvents(**kwargs), 'intersections_of_public_services': miscfeatures.IntersectionsPublicService(**kwargs), 'age_first_interaction_public_service': person.AgeFirstInteractionPublicService(**kwargs), 'age_first_interaction_public_service_years': person.AgeFirstInteractionPublicServiceInYears(**kwargs), 'age_first_interaction_public_service_discrete': person.AgeFirstInteractionPublicServiceDiscrete(**kwargs), 'age_last_interaction_public_service': person.AgeLastInteractionPublicService(**kwargs), 'age_last_interaction_public_service_years': person.AgeLastInteractionPublicServiceInYears(**kwargs), 'age_last_interaction_public_service_discrete': person.AgeLastInteractionPublicServiceDiscrete(**kwargs), 'mental_health_diagnoses': mentalhealthfeatures.ImportantDiagnoses(**kwargs), 'mental_health_referral_source': mentalhealthfeatures.Referral(**kwargs), 'mental_health_program': mentalhealthfeatures.Program(**kwargs), 'booking_ems_booking_730': seqfeatures.BookingEmsBooking730(**kwargs), 'ems_ems_730': seqfeatures.EmsEms730(**kwargs), 'booking_mh_730': seqfeatures.BookingMh730(**kwargs), 'booking_booking_booking_booking_730': seqfeatures.BookingBookingBookingBooking730(**kwargs), 'booking_ems_730': seqfeatures.BookingEms730(**kwargs), 'ems_booking_730': seqfeatures.EmsBooking730(**kwargs), 'mh_booking_730': seqfeatures.MhBooking730(**kwargs), 'booking_booking_730': seqfeatures.BookingBooking730(**kwargs), 'booking_booking_booking_730': seqfeatures.BookingBookingBooking730(**kwargs), 'ems_booking_booking_365': seqfeatures.EmsBookingEms365(**kwargs), 'booking_ems_ems_365': seqfeatures.BookingEmsEms365(**kwargs), 'ems_ems_booking_365': seqfeatures.EmsEmsBooking365(**kwargs), 'booking_booking_mh_365': seqfeatures.BookingBookingMh365(**kwargs), 'mh_booking_booking_365': seqfeatures.MhBookingBooking365(**kwargs), 'booking_mh_booking_365': seqfeatures.BookingMhBooking365(**kwargs), 'ems_booking_booking_365': seqfeatures.EmsBookingBooking365(**kwargs), 'booking_booking_ems_365':seqfeatures.BookingBookingEms365(**kwargs), 'booking_booking_booking_booking_365': seqfeatures.BookingBookingBookingBooking365(**kwargs), 'booking_booking_booking_365': seqfeatures.BookingBookingBooking365(**kwargs), 'booking_ems_booking_365': seqfeatures.BookingEmsBooking365(**kwargs), 'booking_ems_365': seqfeatures.BookingEms365(**kwargs), 'ems_ems_ems_365': seqfeatures.EmsEmsEms365(**kwargs), 'ems_mh_365': seqfeatures.EmsMh365(**kwargs), 'mh_ems_365': seqfeatures.MhEms365(**kwargs), 'mh_mh_365': seqfeatures.MhMh365(**kwargs), 'ems_ems_365': seqfeatures.EmsEms365(**kwargs), 'ems_booking_365': seqfeatures.EmsBooking365(**kwargs), 'booking_booking_365': seqfeatures.BookingBooking365(**kwargs), 'ems_ems_ems_ems_365': seqfeatures.EmsEmsEmsEms365(**kwargs), 'mh_booking_365': seqfeatures.MhBooking365(**kwargs), 'booking_booking_booking_182': seqfeatures.BookingBookingBooking182(**kwargs), 'ems_booking_ems_182': seqfeatures.EmsBookingEms182(**kwargs), 'booking_ems_booking_182': seqfeatures.BookingEmsBooking182(**kwargs), 'ems_ems_182': seqfeatures.EmsEms182(**kwargs), 'ems_booking_182': seqfeatures.EmsBooking182(**kwargs), 'booking_ems_182': seqfeatures.BookingEms182(**kwargs), 'ems_ems_ems_182': seqfeatures.EmsEmsEms182(**kwargs), 'booking_booking_182': seqfeatures.BookingBooking182(**kwargs), 'ems_mh_182': seqfeatures.EmsMh182(**kwargs), 'ems_ems_ems_ems_182': seqfeatures.EmsEmsEmsEms182(**kwargs), 'booking_mh_182': seqfeatures.BookingMh182(**kwargs), 'mh_mh_182': seqfeatures.MhMh182(**kwargs), 'mh_ems_182': seqfeatures.MhEms182(**kwargs), 'mh_booking_182': seqfeatures.MhBooking182(**kwargs), 'ems_ems_90': seqfeatures.EmsEms90(**kwargs), 'booking_ems_90': seqfeatures.BookingEms90(**kwargs), 'booking_booking_90': seqfeatures.BookingBooking90(**kwargs), 'ems_ems_ems_90': seqfeatures.EmsEmsEms90(**kwargs), 'ems_mh_90': seqfeatures.EmsMh90(**kwargs), 'ems_ems_ems_ems_90': seqfeatures.EmsEmsEmsEms90(**kwargs), 'mh_ems_90': seqfeatures.MhEms90(**kwargs), 'mh_booking_90': seqfeatures.MhBooking90(**kwargs), 'mh_mh_90': seqfeatures.MhMh90(**kwargs), 'ems_ems_mh_90': seqfeatures.EmsEmsMh90(**kwargs), 'ems_ems_30': seqfeatures.EmsEms30(**kwargs), 'booking_ems_30': seqfeatures.BookingEms30(**kwargs), 'ems_booking_30': seqfeatures.EmsBooking30(**kwargs), 'ems_ems_ems_30': seqfeatures.EmsEmsEms30(**kwargs), 'ems_ems_7': seqfeatures.EmsEms7(**kwargs), 'booking_ems_7': seqfeatures.BookingEms7(**kwargs), 'homelessness': emsfeatures.Homelessness(**kwargs), 'treated_sum': emsfeatures.TreatedSum(**kwargs), 'transported_sum': emsfeatures.TransportedSum(**kwargs), 'rsi_count': rsifeatures.CountOfRSI(**kwargs), 'rsi_avg_interval_in_and_out': rsifeatures.AvgIntervalFromInAndDisposition(**kwargs), 'rsi_residence_recorded_most': rsifeatures.ResidencyRecordedMost(**kwargs), 'rsi_num_transported_by': rsifeatures.TransportedBy(**kwargs), 'avg_bail_amt': jimsfeatures.AvgBailAmount(**kwargs), 'avg_bail_amt_last_year': jimsfeatures.LastYearAvgBailAmount(**kwargs), 'avg_bail_amt_last_month': jimsfeatures.LastMonthAvgBailAmount(**kwargs), 'avg_bail_amt_last_week': jimsfeatures.LastWeekAvgBailAmount(**kwargs), 'bail_type_count': jimsfeatures.BailTypeCount(**kwargs), 'bail_type_count_last_year': jimsfeatures.LastYearBailTypeCount(**kwargs), 'bail_type_count_last_month': jimsfeatures.LastMonthBailTypeCount(**kwargs), 'bail_type_count_last_week': jimsfeatures.LastWeekBailTypeCount(**kwargs), 'case_type_count': jimsfeatures.CaseTypeCount(**kwargs), 'case_type_count_last_year': jimsfeatures.LastYearCaseTypeCount(**kwargs), 'case_type_count_last_month': jimsfeatures.LastMonthCaseTypeCount(**kwargs), 'case_type_count_last_week': jimsfeatures.LastWeekCaseTypeCount(**kwargs), 'arresting_agency_type_count': jimsfeatures.ArrestingAgencyCount(**kwargs), 'bailed_out_count': jimsfeatures.BailedOutCount(**kwargs), 'destination': emsfeatures.Destination(**kwargs), 'primary_impression': emsfeatures.PrimaryImpression(**kwargs), 'mh_diagnoses': mentalhealthfeatures.Diagnoses(**kwargs), 'mh_num_services': mentalhealthfeatures.NumOfMHServices(**kwargs), 'mh_unique_num_services':mentalhealthfeatures.NumOfUniqueMHServices(**kwargs), 'mh_discharge_reason':mentalhealthfeatures.Discharge(**kwargs), 'mh_number_therapists': mentalhealthfeatures.NumberOfTherapists(**kwargs), 'mh_services_recieved': mentalhealthfeatures.ServicesRecieved(**kwargs), 'mh_most_common_therapist': mentalhealthfeatures.MostCommonTherapistNumber(**kwargs), 'ems_num_different_rescity': emsfeatures.DifferentResidenceOfCityRecorded(**kwargs), 'ems_refused_care_count': emsfeatures.RefusedCareCount(**kwargs), 'ems_refused_transport_count': emsfeatures.TreatedRefusedTransportCount(**kwargs), 'ems_treated_transffered_count': emsfeatures.TreatedTransferredCareCount(**kwargs), 'ems_transported_law_enforement_count': emsfeatures.TreatedTransportedByLawEnforcementCount(**kwargs), 'ems_no_treatment_count': emsfeatures.NoTreamentRequiredCount(**kwargs), 'ems_als_count': emsfeatures.TreatedTransportedALSCount(**kwargs), 'ems_bls_count': emsfeatures.TreatedTransportedBLSCount(**kwargs), 'mh_program_discharges': mentalhealthfeatures.ProgramsDischarges(**kwargs)} if feature not in dict_lookup.keys(): raise UnknownFeatureError(feature) return dict_lookup[feature]