Loan Credit Risk

PowerShell Instructions


If you have deployed a VM using the 'Deploy to Azure' button on the Quick start page, all the steps below have already been performed and your database on that machine has all the resulting tables and stored procedures. Skip to the Typical Workflow for a description of how these files were first created in R by a Data Scientist and then deployed to SQL stored procedures.

If you are configuring your own server, continue with the steps below to run the PowerShell script.

Setup


First, make sure you have set up your SQL Server. Then proceed with the steps below to run the solution template using the automated PowerShell files.

Execute PowerShell Script


Running this PowerShell script will create the data tables and stored procedures for the the operationalization of this solution in R in the Loans_R database. It will also execute these procedures to create full database with results of the steps – dataset creation, modeling, and scoring as described here.

  1. Log onto the computer that contains the SQL Server you wish to use.

  2. Install Git if it is not already present. During the install, check the box to add LFS support.

  3. Download LoanCreditRiskSetup.ps1 to your computer.

  4. Open a command or PowerShell window as Administrator.

  5. CD to the directory where you downloaded the above .ps1 file and execute the command:

    .\LoanCreditRiskSetup.ps1

  6. Make sure to accept installation of NuGet if prompted.

  7. This will make the following modification to your SQL Server:

    • Installs the SQL Server PowerShell module. If this is already installed, it will update it if necessary.
    • Creates the SLQRUserGroup for running R and Python code.
    • Reconfigures SQL Server to allow running of external scripts.
    • Clones the solution code and data into the c:\Solutions\Loans directory
    • Creates the solution databases Loans_R and configures an ODBC connection to the database.
    • Executes the stored procedure Initial_Run_Once_R to run the entire workflow for this solution.

Review Data


Once the PowerShell script has completed successfully, log into the SQL Server Management Studio to view all the datasets that have been created in the Loans_R database. Hit Refresh if necessary.

  • View more information about each of the tables created in the Loans_R database.

  • Right click on Loans_R.dbo.Scores and select View Top 1000 Rows to preview the testing scored data.

  • Right click on Loans_R.dbo.Scores_Prod and select View Top 1000 Rows to preview the production scored data.

Visualizing Results


You’ve now uploaded and processed borrower and loan data, created models, evaluated the model and scored new data as described here.

Let’s look at our current results. Proceed to Visualizing Results with PowerBI.

Other Steps


You’ve just completed the fully automated solution by executing PowerShell scripts.

See the Typical Workflow for a description of how these files were first created in R by a Data Scientist and then incorporated into the SQL stored procedures that you just deployed.