class TestLinearDeploy(unittest.TestCase): def setUp(self): df = pd.read_csv(fixture('HCPyDiabetesClinical.csv'), na_values=['None']) df.drop('PatientID', axis=1, inplace=True) # drop uninformative column np.random.seed(42) self.o = DeploySupervisedModel(modeltype='classification', df=df, graincol='PatientEncounterID', windowcol='InTestWindowFLG', predictedcol='ThirtyDayReadmitFLG', impute=True) self.o.deploy( method='linear', cores=1, server='localhost', dest_db_schema_table='[SAM].[dbo].[HCPyDeployClassificationBASE]', use_saved_model=False) def runTest(self): self.assertAlmostEqual(np.round(self.o.y_pred[5], 5), 0.18087) def tearDown(self): del self.o
def main(): t0 = time.time() # Load in data # CSV snippet for reading data into dataframe df = pd.read_csv('healthcareai/tests/fixtures/HCPyDiabetesClinical.csv', na_values=['None']) # SQL snippet for reading data into dataframe # import pyodbc # cnxn = pyodbc.connect("""SERVER=localhost; # DRIVER={SQL Server Native Client 11.0}; # Trusted_Connection=yes; # autocommit=True""") # # df = pd.read_sql( # sql="""SELECT # * # FROM [SAM].[dbo].[HCPyDiabetesClinical]""", # con=cnxn) # # # Set None string to be None type # df.replace(['None'],[None],inplace=True) # Look at data that's been pulled in print(df.head()) print(df.dtypes) # Drop columns that won't help machine learning df.drop('PatientID', axis=1, inplace=True) p = DeploySupervisedModel(modeltype='regression', df=df, graincol='PatientEncounterID', windowcol='InTestWindowFLG', predictedcol='LDLNBR', impute=True, debug=False) p.deploy(method='rf', cores=2, server='localhost', dest_db_schema_table='[SAM].[dbo].[HCPyDeployRegressionBASE]', use_saved_model=False, trees=200, debug=False) print('\nTime:\n', time.time() - t0)
def setUp(self): df = pd.read_csv(fixture('DiabetesClinicalSampleData.csv'), na_values=['None']) df.drop('PatientID', axis=1, inplace=True) # drop uninformative column np.random.seed(42) self.o = DeploySupervisedModel(modeltype='classification', df=df, graincol='PatientEncounterID', windowcol='InTestWindowFLG', predictedcol='ThirtyDayReadmitFLG', impute=True) self.o.deploy( method='linear', cores=1, server='localhost', dest_db_schema_table='[SAM].[dbo].[HCPyDeployClassificationBASE]', use_saved_model=False)