Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ DB_PORT=50000
DB_UID=<username>
DB_PWD=<password>
DB_SCHEMA=<schema name>
WML_SERVICEPATH=<service url name>
WML_UID=<wml service user name>
WML_PWD=<wml service password name>
WML_INSTANCEID=<service instance id >
WML_MODELID=<model id>
WML_DEPLOYMENTID=<deployment id>
30 changes: 26 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"nodemon": "^1.19.1",
"rxjs": "~6.4.0",
"tslib": "^1.9.0",
"watson-ml-model-utils": "0.0.3",
"zone.js": "~0.9.1"
},
"devDependencies": {
Expand Down
43 changes: 38 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@ app.use(function (req, res, next) {
next();
});


const { WatsonMLScoringEndpoint } = require("watson-ml-model-utils");


var features = ['LOTAREA', 'BLDGTYPE', 'HOUSESTYLE', 'OVERALLCOND', 'YEARBUILT',
'ROOFSTYLE', 'EXTERCOND', 'FOUNDATION', 'BSMTCOND', 'HEATING',
'HEATINGQC', 'CENTRALAIR', 'ELECTRICAL', 'FULLBATH', 'HALFBATH',
'BEDROOMABVGR', 'KITCHENABVGR', 'KITCHENQUAL', 'TOTRMSABVGRD',
'FIREPLACES', 'FIREPLACEQU', 'GARAGETYPE', 'GARAGEFINISH', 'GARAGECARS',
'GARAGECOND', 'POOLAREA', 'POOLQC', 'FENCE', 'MOSOLD', 'YRSOLD' ];


let endpoint = new WatsonMLScoringEndpoint(features, {
servicePath: process.env.WML_SERVICEPATH,
username: process.env.WML_UID,
password: process.env.WML_PWD,
instanceId: process.env.WML_INSTANCEID,
modelId: process.env.WML_MODELID,
deploymentId: process.env.WML_DEPLOYMENTID
});

var NodeGeocoder = require('node-geocoder');

var options = {
Expand All @@ -34,6 +55,8 @@ var geocoder = NodeGeocoder(options);
let connStr = "DATABASE="+process.env.DB_DATABASE+";HOSTNAME="+process.env.DB_HOSTNAME+";PORT="+process.env.DB_PORT+";PROTOCOL=TCPIP;UID="+process.env.DB_UID+";PWD="+process.env.DB_PWD+";";




//let connStr = "DATABASE=BLUDB;HOSTNAME=db2whoc-flex-zipnqsp.services.au-syd.bluemix.net;PORT=50000;PROTOCOL=TCPIP;UID=bluadmin;PWD=zWG@U4q1uFpDTi0v8jVBDI7_PtSr0;";

app.post('/newDataEntry', function(request, response){
Expand Down Expand Up @@ -77,7 +100,8 @@ let connStr = "DATABASE="+process.env.DB_DATABASE+";HOSTNAME="+process.env.DB_HO

})

app.post('/getData', function(request, response){
app.post('/getData', function(request, response){
console.log('hi')
ibmdb.open(connStr, function (err,conn) {
if (err){
return response.json({success:-1, message:err});
Expand All @@ -93,7 +117,7 @@ app.post('/getData', function(request, response){
});
})

app.post('/getUniqueData', function(request, response){
app.post('/getUniqueData', function(request, response){
ibmdb.open(connStr, function (err,conn) {
if (err){
return response.json({success:-1, message:err});
Expand Down Expand Up @@ -123,7 +147,7 @@ app.post('/getUniqueData', function(request, response){
});
})

app.post('/updateDataEntry', function(request, response){
app.post('/updateDataEntry', function(request, response){
ibmdb.open(connStr, function (err,conn) {
if (err){
return response.json({success:-1, message:err});
Expand Down Expand Up @@ -179,7 +203,7 @@ app.post('/updateDataEntry', function(request, response){
})


app.post('/deleteData', function(request, response){
app.post('/deleteData', function(request, response){
ibmdb.open(connStr, function (err,conn) {
if (err){
return response.json({success:-1, message:err});
Expand All @@ -203,7 +227,16 @@ app.post('/deleteData', function(request, response){
});
})

app.get('/predict', function(request, response){

app.post('/WML_Predict', function(request, response){
endpoint.score(request.body.values).then(
output => {
console.log(output.prediction);
return response.json({success:1, value:output.prediction});
}).catch(err => console.log(err));
})

app.get('/predict', function(request, response){
console.log(request);
return response.json({
"address1":"10892 Northfield Sq",
Expand Down
8 changes: 3 additions & 5 deletions src/app/edit-data/edit-data.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h1 style="color:#B2B2B2; " *ngIf=showMessage> Loading Data . . .</h1>

<option> Select BldgType</option>
<option>1Fam</option>
<option>2FmCon</option>
<option>2fmCon</option>
<option>Duplx</option>
<option>TwnhsE</option>
<option>TwnhsI</option>
Expand Down Expand Up @@ -176,7 +176,6 @@ <h1 style="color:#B2B2B2; " *ngIf=showMessage> Loading Data . . .</h1>
<option>TA</option>
<option>Fa</option>
<option>Po</option>
<option>NA</option>
</select>
</div>

Expand Down Expand Up @@ -241,7 +240,7 @@ <h1 style="color:#B2B2B2; " *ngIf=showMessage> Loading Data . . .</h1>
<div class="col-md-2 mb-3">
<label for="country"><strong>Bsmt Contition</strong></label><select class="form-control" required [(ngModel)]="model.bsmtCond" #opCarrier="ngModel" name="bsmtCond">
<option>Select BsmtCond</option>
<option>Ex</option>

<option>Gd</option>
<option>TA</option>
<option>Fa</option>
Expand All @@ -260,7 +259,6 @@ <h1 style="color:#B2B2B2; " *ngIf=showMessage> Loading Data . . .</h1>
<option>Gd</option>
<option>TA</option>
<option>Fa</option>
<option>Po</option>
<option>NA</option>
</select>
</div>
Expand Down Expand Up @@ -293,7 +291,7 @@ <h1 style="color:#B2B2B2; " *ngIf=showMessage> Loading Data . . .</h1>
<option>2Types</option>
<option>Attchd</option>
<option>Basment</option>
<option>Builtin</option>

<option>CarPort</option>
<option>Detchd</option>
<option>NA</option>
Expand Down
15 changes: 11 additions & 4 deletions src/app/http.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export class HttpService {

}



httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json;charset=UTF-8',
Expand Down Expand Up @@ -44,14 +46,19 @@ export class HttpService {
}

predict(predictOption: string, houseInfo: PredictHouseInfo) {
const payload = JSON.stringify(houseInfo);
console.log(houseInfo);
console.log(houseInfo['lotArea']);
var payload = JSON.stringify(houseInfo);
let api = '';
if (predictOption.toLowerCase() === 'db2') {
api = environment.GO_DB2_API;
// return this.http.get(environment.NODE_HOST + 'predict', payload, this.httpOptions);
} else {
api = environment.IBM_WML_API;
}
return this.http.post(api, payload, this.httpOptions);
return this.http.post(environment.NODE_HOST + 'WML_Predict', { values: [Number(houseInfo['lotArea']), houseInfo['bldgType'], houseInfo['houseStyle'], Number(houseInfo['overallCond']), Number(houseInfo['yearBuilt']), houseInfo['roofStyle'], houseInfo['exterCond'], houseInfo['foundation'], houseInfo['bsmtCond'],
houseInfo['heating'], houseInfo['heatingQC'], houseInfo['centralAir'], houseInfo['electrical'], Number(houseInfo['fullBath']), Number(houseInfo['halfBath']), Number(houseInfo['bedroomAbvGr']), Number(houseInfo['kitchenAbvGr']), houseInfo['kitchenQual'], Number(houseInfo['totalRmsAbvGrd']), Number(houseInfo['fireplaces']), houseInfo['fireplaceQu'], houseInfo['garageType'],
houseInfo['garageFinish'], Number(houseInfo['garageCars']), houseInfo['garageCond'], Number(houseInfo['poolArea']), houseInfo['poolQC'], houseInfo['fence'], Number(houseInfo['moSold']), Number(houseInfo['yrSold'])] }, this.httpOptions);
}

}

getCoordinates(address1, city, state, zipcode) {
Expand Down
8 changes: 3 additions & 5 deletions src/app/load-data/load-data.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h3 class="text-dark mb-4" >House Information</h3>

<option> Select BldgType</option>
<option>1Fam</option>
<option>2FmCon</option>
<option>2fmCon</option>
<option>Duplx</option>
<option>TwnhsE</option>
<option>TwnhsI</option>
Expand Down Expand Up @@ -136,7 +136,6 @@ <h3 class="text-dark mb-4" >House Information</h3>
<option>Gd</option>
<option>TA</option>
<option>Fa</option>
<option>Po</option>
</select>
<small
class="text-danger" *ngIf=errKitchenQual>Please Choose An Option</small>
Expand Down Expand Up @@ -248,7 +247,7 @@ <h3 class="text-dark mb-4" >House Information</h3>
<div class="col-md-2 mb-3">
<label for="country"><strong>Bsmt Contition</strong></label><select class="form-control" required [(ngModel)]="model.bsmtCond" #opCarrier="ngModel" name="bsmtCond">
<option>Select BsmtCond</option>
<option>Ex</option>

<option>Gd</option>
<option>TA</option>
<option>Fa</option>
Expand All @@ -268,7 +267,6 @@ <h3 class="text-dark mb-4" >House Information</h3>
<option>Gd</option>
<option>TA</option>
<option>Fa</option>
<option>Po</option>
</select>
<small
class="text-danger" *ngIf=errPoolQC>Please Choose An Option</small>
Expand Down Expand Up @@ -308,7 +306,7 @@ <h3 class="text-dark mb-4" >House Information</h3>
<option>2Types</option>
<option>Attchd</option>
<option>Basment</option>
<option>Builtin</option>

<option>CarPort</option>
<option>Detchd</option>
<option>NA</option>
Expand Down
21 changes: 9 additions & 12 deletions src/app/predict-data/predict-data.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ <h3 class="text-dark mb-4">House Information</h3>
</div>
<div class="card shadow mb-3">
<div class="card-header py-3">
<p class="text-primary m-0 font-weight-bold">address Information</p>
<p class="text-primary m-0 font-weight-bold">Address Information</p>
</div>
<div class="card-body">
<div class="form-row" style="margin-bottom:0px;">
<div class="col-md-2 mb-3">
<label for="address1">address 1</label>
<label for="address1">Address 1</label>
<input type="text" class="form-control" id="address1" placeholder="1234 abc st."
required [(ngModel)]="addressModel.address1" #address1="ngModel"
name="address1">
<small class="text-danger" *ngIf=errAddress1>Please enter a valid address</small>
</div>
<div class="col-md-2 mb-3">
<label for="address2">address2</label>
<label for="address2">Address2</label>
<input type="text" class="form-control" id="address2" placeholder="Apt 4" required
[(ngModel)]="addressModel.address2" #address2="ngModel" name="address2">
<small class="text-danger" *ngIf=errAddress2>Please enter a valid address</small>
Expand Down Expand Up @@ -117,7 +117,7 @@ <h3 class="text-dark mb-4">House Information</h3>

<option> Select BldgType</option>
<option>1Fam</option>
<option>2FmCon</option>
<option>2fmCon</option>
<option>Duplx</option>
<option>TwnhsE</option>
<option>TwnhsI</option>
Expand Down Expand Up @@ -207,7 +207,6 @@ <h3 class="text-dark mb-4">House Information</h3>
<option>Gd</option>
<option>TA</option>
<option>Fa</option>
<option>Po</option>
</select>
<small class="text-danger" *ngIf=errKitchenQual>Please choose an option</small>
</div>
Expand All @@ -220,7 +219,7 @@ <h3 class="text-dark mb-4">House Information</h3>
<p class="text-primary m-0 font-weight-bold">Utilities</p>
</div>
<div class="card-body">
<div class="form-row" style="margin-bottom:0px;">
<div class="form-row" style="margin-bottom:0px;">
<div class="col-md-2 mb-3">
<label for="email"><strong>Heating</strong></label><select class="form-control"
required [(ngModel)]="model.heating" #heating="ngModel" name="heating">
Expand Down Expand Up @@ -320,7 +319,6 @@ <h3 class="text-dark mb-4">House Information</h3>
class="form-control" required [(ngModel)]="model.bsmtCond" #bsmtCond="ngModel"
name="bsmtCond">
<option>Select BsmtCond</option>
<option>Ex</option>
<option>Gd</option>
<option>TA</option>
<option>Fa</option>
Expand All @@ -341,9 +339,8 @@ <h3 class="text-dark mb-4">House Information</h3>
<option>Select PoolQC</option>
<option>Ex</option>
<option>Gd</option>
<option>TA</option>
<option>Fa</option>
<option>Po</option>
<option>NA</option>
</select>
<small class="text-danger" *ngIf=errPoolQC>Please choose an option</small>

Expand Down Expand Up @@ -389,7 +386,7 @@ <h3 class="text-dark mb-4">House Information</h3>
<option>2Types</option>
<option>Attchd</option>
<option>Basment</option>
<option>Builtin</option>

<option>CarPort</option>
<option>Detchd</option>
<option>NA</option>
Expand Down Expand Up @@ -464,7 +461,7 @@ <h3 class="text-dark mb-4">House Information</h3>
type="text" placeholder="Year Sold" required [(ngModel)]="model.yrSold"
#yrSold="ngModel" name="yrSold"><small class="text-danger"
*ngIf=errYrSold>Please enter a valid number</small>
</div>
</div>
<div class="col-md-2 mb-3" style="margin-top:35px; margin-left:15px;">

<button class="btn btn-primary btn-sm" type="submit" (click)=predict()>SUBMIT
Expand All @@ -477,4 +474,4 @@ <h3 class="text-dark mb-4">House Information</h3>
</div>
</div>
</div>
</div>
</div>
Loading