diff --git a/PerformanceOfAlgorithms.xlsx b/ClassificationCharacteristicsOfAlgorithms.xlsx similarity index 100% rename from PerformanceOfAlgorithms.xlsx rename to ClassificationCharacteristicsOfAlgorithms.xlsx diff --git a/Jupyter Notebooks/PredictionScoreSheet.ipynb b/Jupyter Notebooks/PredictionScoreSheet.ipynb new file mode 100644 index 0000000..1cac366 --- /dev/null +++ b/Jupyter Notebooks/PredictionScoreSheet.ipynb @@ -0,0 +1,277 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Functions to Create Prediction Score Sheet\n", + "\n", + "This jupyter notebook was created for the purpose of querying the REST API programmatically and obtain results of the predction since there were a lot of Quarter's to be analyzed." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import seaborn as sns\n", + "import datetime" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "linearregoutfile=r\"C:\\Users\\Manasi\\Desktop\\linearregoutfile.csv\"\n", + "neuralnetworksoutfile=r\"C:\\Users\\Manasi\\Desktop\\neuralnetwokoutfile.csv\"\n", + "boosteddecisiontreeoutfiler=r\"C:\\Users\\Manasi\\Desktop\\boosteddecisiontree.csv\"" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "df=pd.read_csv(r\"C:\\Users\\Manasi\\Desktop\\predictionTestCases.csv\")" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
OG_QUARTER_YEARCREDITSCOREFIRST_HOME_BUYER_FLAGOG_UPBOG_LOANTERMSELLER_NAMESERVICE_NAMEORIGINAL_INTERESTRATE
0Q1 1999615Y48000360Other sellersOther servicers5.375
1Q1 1999791N284000312Other sellersOther servicers5.750
2Q2 1999574N162000325Other sellersOther servicers6.875
3Q2 1999716Y70000360NORWEST MORTGAGE, INWELLSFARGOHOMEMORTGA7.125
4Q3 1999642N178000329Other sellersOther servicers7.125
\n", + "
" + ], + "text/plain": [ + " OG_QUARTER_YEAR CREDITSCORE FIRST_HOME_BUYER_FLAG OG_UPB OG_LOANTERM \\\n", + "0 Q1 1999 615 Y 48000 360 \n", + "1 Q1 1999 791 N 284000 312 \n", + "2 Q2 1999 574 N 162000 325 \n", + "3 Q2 1999 716 Y 70000 360 \n", + "4 Q3 1999 642 N 178000 329 \n", + "\n", + " SELLER_NAME SERVICE_NAME ORIGINAL_INTERESTRATE \n", + "0 Other sellers Other servicers 5.375 \n", + "1 Other sellers Other servicers 5.750 \n", + "2 Other sellers Other servicers 6.875 \n", + "3 NORWEST MORTGAGE, IN WELLSFARGOHOMEMORTGA 7.125 \n", + "4 Other sellers Other servicers 7.125 " + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import os\n", + "import json\n", + "import requests\n", + "from flask import Flask, render_template, request, jsonify" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def get_prediction(og_quarter_year,credit_score,og_first_time_home_buyer,og_upb,og_loan_term,og_seller_name,og_servicer_name,algoType):\n", + "\n", + " #print(str(algoType)+\"\\t\"+str(credit_score)+\"\\t\"+str(og_first_time_home_buyer)+\"\\t\"+str(og_upb)+\"\\t\"+str(og_loan_term)+\"\\t\"+str(og_quarter_year)+\"\\t\"+str(og_seller_name)+\"\\t\"+str(og_servicer_name))\n", + " #make ai call\n", + " if algoType==\"pred_df\":\n", + " url=\"https://ussouthcentral.services.azureml.net/workspaces/43247f6706b64e68a8b7d22ff16a2a4f/services/89403771d86f46e887c4d27b6eb80908/execute?api-version=2.0&details=true\"\n", + " api_key='4/1AxmSvNJyjoFfc1SRtNHf8Znsr7/51JGIcH4Pxb7tI+1NEWrXlXzwUwy5/k5rBDz9kLENVEpt/iY2E/Tkt3g=='\n", + " elif algoType==\"pred_nn\":\n", + " url=\"https://ussouthcentral.services.azureml.net/workspaces/43247f6706b64e68a8b7d22ff16a2a4f/services/964b03c9c6fa480ca1156bd093eb9ff4/execute?api-version=2.0&details=true\"\n", + " api_key=\"A2fylieTrkGctlekKOCkblCgcEZkxq06AHi8fuE69A9MFfVeKHfVj2uMftzuN+utNqV3Wfuyhj1HmM8F4Fj/8g==\"\n", + " elif algoType==\"pred_lr\":\n", + " url=\"https://ussouthcentral.services.azureml.net/workspaces/43247f6706b64e68a8b7d22ff16a2a4f/services/1f553c369b314b9dad2097ff5c012200/execute?api-version=2.0&details=true\"\n", + " api_key=\"cz3t27xidE9ehvF8jtVhP0+s97DKnKqOLaodqaXC8I3Vmn844xIqjoAN8Q/enkiA1HXaOIvSLZQgi/SjaXfX2Q==\"\n", + " \n", + " \n", + " data = {\n", + " \n", + " \"Inputs\": {\n", + " \n", + " \"input1\":\n", + " {\n", + " \"ColumnNames\": [\"CREDIT_SCORE\", \"FIRST_HOME_BUYER_FLAG\", \"OG_UPB\", \"OG_LOANTERM\", \"SELLER_NAME\", \"SERVICE_NAME\", \"OG_QUARTERYEAR\"],\n", + " \"Values\": [ [credit_score,og_first_time_home_buyer,og_upb,og_loan_term,og_seller_name,og_servicer_name,og_quarter_year]]\n", + " }, },\n", + " \"GlobalParameters\": {\n", + " }\n", + " }\n", + " \n", + " body = str.encode(json.dumps(data))\n", + " \n", + " #url = 'https://ussouthcentral.services.azureml.net/workspaces/5de0e8bd28f74cf9a40babb3f1799a53/services/300d6267d2f843c9a5975621ff077a09/execute?api-version=2.0&details=true'\n", + " #api_key = 'wQWgTpa3GyVACzg7Q6jVDdwt5JEDnfdvqqG21PKDr+UHmZWRQJh1XfrtLVON846vEDEXoDgnruZ1s9zd4Drzyw==' # Replace this with the API key for the web service\n", + " headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key)}\n", + " \n", + " response = requests.post(url, data=body,headers=headers)\n", + " #print(response.content)\n", + " \n", + " response_json=json.loads(response.content)\n", + " predicted_interest_rate=response_json['Results']['output1']['value']['Values'][0][7]\n", + " \n", + " return_dict = {\"predicted_interest_rate\":predicted_interest_rate}\n", + " return predicted_interest_rate\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "\n", + "def writePredOutputToFile(outfile,algo_type):\n", + " with open(outfile,\"w\") as fil:\n", + " for index, row in df.iterrows():\n", + " fil.write(get_prediction(row.OG_QUARTER_YEAR,row.CREDITSCORE,row.FIRST_HOME_BUYER_FLAG,row.OG_UPB,row.OG_LOANTERM,row.SELLER_NAME,row.SERVICE_NAME,algo_type))\n", + " fil.write(\"\\n\")" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "writePredOutputToFile(linearregoutfile,'pred_lr')\n", + "writePredOutputToFile(neuralnetworksoutfile,'pred_nn')\n", + "writePredOutputToFile(boosteddecisiontreeoutfiler,'pred_df')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/PredictionModelErrorMetrics.xlsx b/PredictionModelErrorMetrics.xlsx new file mode 100644 index 0000000..19c9b29 Binary files /dev/null and b/PredictionModelErrorMetrics.xlsx differ diff --git a/Team1_Assignment3_Report.docx b/Team1_Assignment3_Report.docx new file mode 100644 index 0000000..67928f3 Binary files /dev/null and b/Team1_Assignment3_Report.docx differ diff --git a/Team1_Assignment3_Report.pdf b/Team1_Assignment3_Report.pdf new file mode 100644 index 0000000..2bdde7e Binary files /dev/null and b/Team1_Assignment3_Report.pdf differ diff --git a/Test Cases/ClassificationTestCases.xlsx b/Test Cases/ClassificationTestCases.xlsx new file mode 100644 index 0000000..0054217 Binary files /dev/null and b/Test Cases/ClassificationTestCases.xlsx differ diff --git a/Test Cases/PredictionTestCases.xlsx b/Test Cases/PredictionTestCases.xlsx new file mode 100644 index 0000000..3f796b6 Binary files /dev/null and b/Test Cases/PredictionTestCases.xlsx differ