import { Injectable } from '@angular/core' ; import { Http } from "@angular/http" ; import { Observable } from "rxjs/Observable" ; import 'rxjs/add/operator/map' ; import { Iris , ProbabilityPrediction , SVCParameters , SVCResult } from "./types" ; const SERVER_URL = 'api/' ; @ Injectable ( ) export class IrisService { constructor ( private http ) { } public trainModel ( svcParameters ) { return this . http . post ( `${ SERVER_URL }train` , svcParameters ) . map ( ( res ) => res . json ( ) ) ; } public predictIris ( iris ) { return this . http . post ( `${ SERVER_URL }predict` , iris ) . map ( ( res ) => res . json ( ) ) ; } }