Skip to content

Commit f1b13b8

Browse files
committed
update predict output
1 parent a00140c commit f1b13b8

File tree

7 files changed

+46
-29
lines changed

7 files changed

+46
-29
lines changed

env.sample

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ DB_PORT=50000
77
DB_UID=<username>
88
DB_PWD=<password>
99
DB_SCHEMA=<schema name>
10+
WML_SERVICEPATH=<service url name>
11+
WML_UID=<wml service user name>
12+
WML_PWD=<wml service password name>
13+
WML_INSTANCEID=<service instance id >
14+
WML_MODELID=<model id>
15+
WML_DEPLOYMENTID=<deployment id>

server.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ var features = ['LOTAREA', 'BLDGTYPE', 'HOUSESTYLE', 'OVERALLCOND', 'YEARBUILT',
2828
'FIREPLACES', 'FIREPLACEQU', 'GARAGETYPE', 'GARAGEFINISH', 'GARAGECARS',
2929
'GARAGECOND', 'POOLAREA', 'POOLQC', 'FENCE', 'MOSOLD', 'YRSOLD' ];
3030

31+
3132
let endpoint = new WatsonMLScoringEndpoint(features, {
32-
servicePath: 'https://ibm-watson-ml.mybluemix.net',
33-
username: '04c75888-357b-4548-9a3d-824b0fdf4355',
34-
password: '1626bb66-81f2-4d17-962d-b750eedce230',
35-
instanceId: 'ee215244-7c33-4ffb-ae7f-e2aac55d92f4',
36-
modelId: 'fbb8ab9f-4600-470b-95f0-55dd30925d6e',
37-
deploymentId: 'c3cf73a6-4cbb-493f-879d-e60d30c3f26f'
33+
servicePath: process.env.WML_SERVICEPATH,
34+
username: process.env.WML_UID,
35+
password: process.env.WML_PWD,
36+
instanceId: process.env.WML_INSTANCEID,
37+
modelId: process.env.WML_MODELID,
38+
deploymentId: process.env.WML_DEPLOYMENTID
3839
});
3940

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

src/app/http.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class HttpService {
5252
let api = '';
5353
if (predictOption.toLowerCase() === 'db2') {
5454
api = environment.GO_DB2_API;
55-
return this.http.post(api, payload, this.httpOptions);
55+
// return this.http.get(environment.NODE_HOST + 'predict', payload, this.httpOptions);
5656
} else {
5757
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'],
5858
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'],

src/app/predict-data/predict-data.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ <h3 class="text-dark mb-4">House Information</h3>
3737
</div>
3838
<div class="card shadow mb-3">
3939
<div class="card-header py-3">
40-
<p class="text-primary m-0 font-weight-bold">address Information</p>
40+
<p class="text-primary m-0 font-weight-bold">Address Information</p>
4141
</div>
4242
<div class="card-body">
4343
<div class="form-row" style="margin-bottom:0px;">
4444
<div class="col-md-2 mb-3">
45-
<label for="address1">address 1</label>
45+
<label for="address1">Address 1</label>
4646
<input type="text" class="form-control" id="address1" placeholder="1234 abc st."
4747
required [(ngModel)]="addressModel.address1" #address1="ngModel"
4848
name="address1">
4949
<small class="text-danger" *ngIf=errAddress1>Please enter a valid address</small>
5050
</div>
5151
<div class="col-md-2 mb-3">
52-
<label for="address2">address2</label>
52+
<label for="address2">Address2</label>
5353
<input type="text" class="form-control" id="address2" placeholder="Apt 4" required
5454
[(ngModel)]="addressModel.address2" #address2="ngModel" name="address2">
5555
<small class="text-danger" *ngIf=errAddress2>Please enter a valid address</small>
@@ -386,7 +386,7 @@ <h3 class="text-dark mb-4">House Information</h3>
386386
<option>2Types</option>
387387
<option>Attchd</option>
388388
<option>Basment</option>
389-
389+
390390
<option>CarPort</option>
391391
<option>Detchd</option>
392392
<option>NA</option>

src/app/predict-data/predict-data.component.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class PredictDataComponent implements OnInit {
6363
validateInputFields: boolean;
6464

6565

66-
constructor(private router: Router, private httpService: HttpService) {
66+
constructor(private _router: Router, private httpService: HttpService) {
6767

6868
this.validateInputFields = true;
6969

@@ -141,17 +141,11 @@ export class PredictDataComponent implements OnInit {
141141
(predictions) => {
142142
console.log('Predictions Result');
143143
console.log(predictions);
144-
145-
146-
147-
148-
149-
150-
151-
152-
153-
154-
144+
localStorage.setItem('prediction_data', JSON.stringify(this.model));
145+
localStorage.setItem('predicted_value', JSON.stringify(predictions));
146+
localStorage.setItem('address', JSON.stringify(this.addressModel));
147+
localStorage.setItem('ml-model',this.predictOption);
148+
this._router.navigate(['/predictOutput']);
155149
});
156150
}
157151
}

src/app/predict-output/predict-output.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ <h3 class="text-dark mb-0">Predicted House Value</h3>
2323
<agm-map [zoom]="13" [latitude]="lat" [longitude]="lng">
2424
<agm-marker [latitude]="lat" [longitude]="lng"></agm-marker>
2525
</agm-map>
26-
<p style="font-size: 15px;margin-bottom: 0px;margin-top: 10px;">Address:&nbsp;{{model['address1']}} {{model['address2']}}, {{model['city']}}, {{model['state']}}, {{model['zipcode']}} {{model['country']}}</p>
27-
<p style="font-size: 20px;color: rgb(78,115,223);">Est. Sale Price:&nbsp;${{model['salePrice']}}</p>
26+
<p style="font-size: 15px;margin-bottom: 0px;margin-top: 10px;">Address:&nbsp;{{addressModel['address1']}} {{addressModel['address2']}}, {{addressModel['city']}}, {{addressModel['state']}}, {{model['zipcode']}} {{model['country']}}</p>
27+
<p style="font-size: 20px;color: rgb(78,115,223);">Est. Sale Price:&nbsp;${{salePrice}}</p>
2828
</div>
2929
</div>
3030
</div>

src/app/predict-output/predict-output.component.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Component, OnInit } from '@angular/core';
44
import {Router} from '@angular/router';
55
import { HttpService } from '../http.service';
66
import { PredictHouseInfo } from '../models/predict-house-info';
7+
import { AddressInfo } from '../models/address-info';
78
import { library } from '@fortawesome/fontawesome-svg-core';
89
import { MapsAPILoader } from '@agm/core';
910
import { faImage, faClock, faBed, faCar, faBuilding, faDoorOpen, faFire, faHome, faSwimmer, faBath } from '@fortawesome/free-solid-svg-icons';
@@ -32,7 +33,9 @@ export class PredictOutputComponent implements OnInit {
3233
averageSalePrice:string;
3334
showData:boolean;
3435
showMessage:boolean;
35-
model:any;
36+
37+
model: PredictHouseInfo;
38+
addressModel: AddressInfo;
3639

3740
constructor(private _router:Router, private _httpService:HttpService) {
3841
this.showData = false;
@@ -45,21 +48,34 @@ export class PredictOutputComponent implements OnInit {
4548
this.fireplace = '';
4649
this.garage = '';
4750
this.bath = '';
48-
this.model = [];
4951
this.salePrice = '';
5052
this.averageSalePrice = '';
53+
54+
this.model = new PredictHouseInfo('', 'Select BldgType', 'Select HouseStyle', '', '', '', '', '', '', 'Select KitchenQual', '', 'Select Heating', 'Select HeatingQC', 'Select CentralAir', 'Select Electrical', 'Select RoofStyle', 'Select ExterCond', 'Select Foundation', 'Select BsmtCond', '', 'Select PoolQC', '', 'Select FireplaceQu', 'Select GarageType', 'Select GarageFinish', '', 'Select GarageCond', 'Select Fence', '', '');
55+
56+
this.addressModel = new AddressInfo('', ' ', '', '', '', '');
57+
5158
}
5259

5360

5461
ngOnInit() {
5562
this.showData = false;
5663
this.showMessage = true;
57-
this.model = JSON.parse(localStorage.getItem("predictOutput"));
64+
65+
this.model = (JSON.parse(localStorage.getItem('prediction_data')));
66+
67+
if (localStorage.getItem('ml-model') === 'db2') {
68+
this.salePrice = (JSON.parse(localStorage.getItem('predicted_value'))['salePrice']);
69+
} else {
70+
this.salePrice = (JSON.parse(localStorage.getItem('predicted_value'))['value']);
71+
}
72+
73+
this.addressModel = (JSON.parse(localStorage.getItem('address')));
5874
this.getGeoCode();
5975
}
6076

6177
getGeoCode(){
62-
var geo = this._httpService.getCoordinates(this.model['address1'], this.model['city'],this.model['state'],this.model['zipcode']);
78+
var geo = this._httpService.getCoordinates(this.addressModel['address1'], this.addressModel['city'],this.addressModel['state'],this.addressModel['zipcode']);
6379
geo.subscribe(data => {
6480
console.log(data);
6581
if (data['success'] != 1){

0 commit comments

Comments
 (0)