This commit is contained in:
Eqbal Zaffar 2017-06-15 20:20:25 -07:00
Родитель d2dd81eb34
Коммит 705a8cc985
3 изменённых файлов: 11 добавлений и 88 удалений

Просмотреть файл

@ -166,12 +166,12 @@ if ($uninterrupted -eq 'y' -or $uninterrupted -eq 'Y')
# create the views for features and label with training, test and scoring split
Write-Host -ForeGroundColor 'magenta'(" Creating features label view and persisting...")
$script = $filepath + "step2_features_label_view.sql"
ExecuteSQL $script "datasize = $dataSize"
ExecuteSQL $script "datasize=$dataSize"
Write-Host -ForeGroundColor 'magenta'(" Done creating features label view and persisting...")
# create the stored procedure for training
$script = $filepath + "step3_train_test_model.sql"
ExecuteSQL $script
ExecuteSQL $script "datasize=$dataSize"
Write-Host -ForeGroundColor 'magenta'(" Done creating training and eval stored proc...")
# execute the training
@ -188,7 +188,7 @@ if ($uninterrupted -eq 'y' -or $uninterrupted -eq 'Y')
# create the stored procedure for recommendations
$script = $filepath + "step4_chargeoff_batch_prediction.sql"
ExecuteSQL $script
ExecuteSQL $script "datasize=$dataSize"
Write-Host -ForeGroundColor 'magenta'(" Done creating batch scoring stored proc...")
#score on the data
@ -198,13 +198,13 @@ if ($uninterrupted -eq 'y' -or $uninterrupted -eq 'Y')
# create the stored procedure for recommendations
$script = $filepath + "step4a_chargeoff_ondemand_prediction.sql"
ExecuteSQL $script
ExecuteSQL $script "datasize=$dataSize"
Write-Host -ForeGroundColor 'magenta'(" Done creating on demand scoring stored proc [predict_chargeoff_ondemand]...")
}
catch
{
Write-Host -ForegroundColor DarkYellow "Exception in populating database tables:"
Write-Host -ForegroundColor Yellow "Exception executing Data Science pipeline..."
Write-Host -ForegroundColor Red $Error[0].Exception
throw
}
@ -288,7 +288,7 @@ if ($ans -eq 'y' -or $ans -eq 'Y')
{
# create the stored procedure for feature engineering
$script = $filepath + "step2a_optional_feature_selection.sql"
ExecuteSQL $script
ExecuteSQL $script "datasize=$dataSize"
# execute the feature engineering
Write-Host -ForeGroundColor 'Cyan' (" selecting features using MicrosoftML selectFeatures mlTransform with Logistic Regression...")
@ -310,7 +310,7 @@ if ($ans -eq 'y' -or $ans -eq 'Y')
{
# create the stored procedure for training
$script = $filepath + "step3_train_test_model.sql"
ExecuteSQL $script
ExecuteSQL $script "datasize=$dataSize"
Write-Host -ForeGroundColor 'magenta'(" Starting training and evaluation of models...")
$modelNames = 'logistic_reg','fast_linear','fast_trees','fast_forest','neural_net'
@ -336,7 +336,7 @@ if ($ans -eq 'y' -or $ans -eq 'Y')
{
# create the stored procedure for recommendations
$script = $filepath + "step4_chargeoff_batch_prediction.sql"
ExecuteSQL $script
ExecuteSQL $script "datasize=$dataSize"
# compute loan chargeoff predictions
Write-Host -ForeGroundColor 'Cyan' ("Scoring based on best performing model score table = $scoreTable, prediction table = $predictionTable...")
@ -354,7 +354,7 @@ if ($ans -eq 'y' -or $ans -eq 'Y')
{
# create the stored procedure for recommendations
$script = $filepath + "step4a_chargeoff_ondemand_prediction.sql"
ExecuteSQL $script
ExecuteSQL $script "datasize=$dataSize"
Write-Host -ForeGroundColor 'Cyan' ("Done creating on demand chargeoff prediction stored proc [predict_chargeoff_ondemand]...")
}

Просмотреть файл

@ -43,7 +43,7 @@ if (!$createuser)
}
else
{
Write-Host -ForegroundColor DarkYellow "Either ExportedSqlPassword.txt must exist with encrypted database password or must provide password using dbpass parameter."
Write-Host -ForegroundColor Yellow "Either ExportedSqlPassword.txt must exist with encrypted database password or must provide password using dbpass parameter."
throw
}
}
@ -76,7 +76,7 @@ else
$secureTxt = $securePassword | ConvertFrom-SecureString
Set-Content $passwordFile $secureTxt
} catch {
Write-Host -ForegroundColor 'Red' "Error creating database user, see error message output"
Write-Host -ForegroundColor 'Yellow' "Error creating database user, see error message output"
Write-Host -ForegroundColor 'Red' $Error[0].Exception
#Try to read password from stored file
if (Test-Path $passwordFile)

Просмотреть файл

@ -1,77 +0,0 @@
##############################################################################################
# Script to invoke the LoanChargeOff data science workflow with a larger dataset of 1,000,000
# loans.
# It can also optionally creates a SQL Server user and stores the password in
# 'ExporedSqlPassword.txt'. Users can retrieve the password from the file and decrypt using
# ConvertTo-SecureString commandlet in PowerShell.
#
# Parameters:
# dbuser - (Optional) username for database LoanChargeOff
# dbpass - (Optional) database password
# createuser - (Optional) whethere to create a database user
##############################################################################################
Param([string]$dbuser, [string]$dbpass, [bool]$createuser = $true, [string]$datadir)
# Function to generate a temporary password for SQL Server
Function Get-TempPassword()
{
Param
(
[int]$length=10,
[string[]]$sourcedata
)
For ($loop=1; $loop -le $length; $loop++)
{
$TempPassword += ($sourcedata | Get-Random)
}
return $TempPassword
}
$passwordSource=$NULL
$dbpassword = ""
$dbusername = "rdemo"
$passwordFile = "ExportedSqlPassword.txt"
For ($a=33;$a -le 126; $a++)
{
$passwordSource += ,[char][byte]$a
}
if ($dbuser)
{
$dbusername = $dbuser
}
if (!$createuser)
{
if (!$dbpass)
{
if (Test-Path $passwordFile)
{
$secureTxtFromFile = Get-Content $passwordFile
$securePasswordObj = $secureTxtFromFile | ConvertTo-SecureString
#get back the original unencrypted password
$PasswordBSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePasswordObj)
$dbpassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($PasswordBSTR)
}
else
{
Write-Host -ForegroundColor Yellow "Either ExportedSqlPassword.txt must exist with encrypted database password or must provide password using dbpass parameter."
throw
}
}
else
{
$dbpassword = $dbpass
}
}
else
{
Write-Host -ForegroundColor Cyan "Creating database user"
$dbpassword = Get-TempPassword -length 15 -sourcedata $passwordSource
$securePassword = $dbpassword | ConvertTo-SecureString -AsPlainText -Force
$secureTxt = $securePassword | ConvertFrom-SecureString
Set-Content $passwordFile $secureTxt
sqlcmd -S $env:COMPUTERNAME -v username="$dbusername" -v password="$dbpassword" -i .\createuser.sql
}
.\Loan_ChargeOff.ps1 -ServerName $env:COMPUTERNAME -DBName LoanChargeOff -username $dbusername -password $dbpassword -uninterrupted y -dataPath $datadir -dataSize L