Linear Regression
Microservices with Spring Boot and Spring Cloud
Full Stack app with Angular 10
Marco Yuri Fujii Melo
2
Agenda

Quick introduction to Linear Regression

Weka Machine Learning Software

Demo #1 using Weka GUI

Microservices Architecture of Demo #2

Demo #2 with three Microservices, using Weka Java API
➔ Spring Data JPA using H2 database
➔ Centralized Configuration with Spring Cloud Config Server and Git repository
➔ Service Invocation using Feign
➔ Load Balancing with Ribbon
➔ Eureka Naming Server
➔ API Gateway with Zuul
➔ Distributed Tracing with Zipkin, Sleuth and RabbitMQ
➔ Broadcast of configuration changes with Spring Cloud Bus and RabbitMQ
➔ Fault Tolerance with Hystrix

Demo #3 – Full Stack Application with Angular 10
3
Linear Regression - Definition
“Linear regression is a way to explain the
relationship between a dependent variable and
one or more explanatory variables using a
straight line.”
(Wikipedia)
4
Linear Regression - Equation
γ = α + β1x1 + β2x2 + … + βnxn + ε
γ - the dependent variable (the value to be predicted)
α - the intercept (the value of γ when x = 0)
β - the slope of the line (a.k.a. regression coefficient)
x - the independent variable (a.k.a. explanatory variable)
ε - the error term (a.k.a. residual), reflects the unexplained
variation in γ
5
Linear Regression - Graph

The blue points are actual samples.

With linear regression all points can be connected using a single, straight line.
6
Weka
(Waikato Environment for Knowledge Analysis)

Weka is an open source machine learning
software that can be accessed through a GUI,
standard terminal applications, or a Java API

Developed at the University of Waikato, New
Zealand

Licensed under the GNU General Public License

Available at:
https://www.cs.waikato.ac.nz/ml/weka/
7
Weka - GUI
8
Weka – ARFF File

ARFF (Attribute-Relation File Format) file is an
ASCII text file that describes a list of instances
sharing a set of attributes

ARFF files were developed by the Machine
Learning Project at the Department of Computer
Science of The University of Waikato for use with
the Weka machine learning software

The ARFF file format is:
@relation <relation-name>
@attribute <attribute-name> <datatype>
@data
9
ARFF File for Weka GUI Demo
@RELATION house
@ATTRIBUTE houseSize NUMERIC
@ATTRIBUTE lotSize NUMERIC
@ATTRIBUTE bedrooms NUMERIC
@ATTRIBUTE granite NUMERIC
@ATTRIBUTE upgradedBathroom NUMERIC
@ATTRIBUTE sellingPrice NUMERIC
@DATA
3529,9191,6,0,0,205000
3247,10061,5,1,1,224900
4032,10150,5,0,1,197900
2397,14156,4,1,0,189900
2200,9600,4,0,1,195000
3536,19994,6,1,1,325000
2983,9365,5,0,1,230000
10
Weka – Demo #1
Demo #1 using Weka GUI
11
Weka Explorer
Loading ARFF data file into Weka.
12
Weka with data loaded
13
Choosing LinearRegression model
Click on Classify tab, then Choose > functions > LinearRegression.
In Test options, select Use training set and sellingPrice, then hit Start.
14
Regression output
15
Linear Regression Model
sellingPrice =
-26.6882 * houseSize +
7.0551 * lotSize +
43166.0767 * bedrooms +
42292.0901 * upgradedBathroom +
-21661.1208
The regression model tells that granite in the
kitchen doesn’t affect the house’s value.
16
Applying the regression model equation
sellingPrice =
-26.6882 * 3198 +
7.0551 * 9669 +
43166.0767 * 5 +
42292.0901 * 1 +
-21661.1208
sellingPrice = 219,328
17
Microservices Architecture of Demo #2
18
Microservices Architecture of Demo #2
19
Microservices Architecture of Demo #2
20
Microservices Architecture of Demo #2
21
Demo #2 – H2 Database
22
Demo #2 – Eureka Naming Server
23
Demo #2 - Postman
24
Demo #2 – Zipkin Distributed Tracing
25
Weka – Demo #2
Demo #2 using Microservices and Weka Java API
Source code is available at: https://github.com/marcoyf
26
Demo #3 – Angular 10 web app
27
Demo #3 – Angular 10 web app
28
Weka – Demo #3
Demo #3 – Full Stack app with Angular 10
Source code is available at: https://github.com/marcoyf
29
Thank you
30
References

https://developer.ibm.com/technologies/analytics/articles/os-weka1/

https://simple.wikipedia.org/wiki/Linear_regression

https://www.cs.waikato.ac.nz/ml/weka/

Linear Regression

  • 1.
    Linear Regression Microservices withSpring Boot and Spring Cloud Full Stack app with Angular 10 Marco Yuri Fujii Melo
  • 2.
    2 Agenda  Quick introduction toLinear Regression  Weka Machine Learning Software  Demo #1 using Weka GUI  Microservices Architecture of Demo #2  Demo #2 with three Microservices, using Weka Java API ➔ Spring Data JPA using H2 database ➔ Centralized Configuration with Spring Cloud Config Server and Git repository ➔ Service Invocation using Feign ➔ Load Balancing with Ribbon ➔ Eureka Naming Server ➔ API Gateway with Zuul ➔ Distributed Tracing with Zipkin, Sleuth and RabbitMQ ➔ Broadcast of configuration changes with Spring Cloud Bus and RabbitMQ ➔ Fault Tolerance with Hystrix  Demo #3 – Full Stack Application with Angular 10
  • 3.
    3 Linear Regression -Definition “Linear regression is a way to explain the relationship between a dependent variable and one or more explanatory variables using a straight line.” (Wikipedia)
  • 4.
    4 Linear Regression -Equation γ = α + β1x1 + β2x2 + … + βnxn + ε γ - the dependent variable (the value to be predicted) α - the intercept (the value of γ when x = 0) β - the slope of the line (a.k.a. regression coefficient) x - the independent variable (a.k.a. explanatory variable) ε - the error term (a.k.a. residual), reflects the unexplained variation in γ
  • 5.
    5 Linear Regression -Graph  The blue points are actual samples.  With linear regression all points can be connected using a single, straight line.
  • 6.
    6 Weka (Waikato Environment forKnowledge Analysis)  Weka is an open source machine learning software that can be accessed through a GUI, standard terminal applications, or a Java API  Developed at the University of Waikato, New Zealand  Licensed under the GNU General Public License  Available at: https://www.cs.waikato.ac.nz/ml/weka/
  • 7.
  • 8.
    8 Weka – ARFFFile  ARFF (Attribute-Relation File Format) file is an ASCII text file that describes a list of instances sharing a set of attributes  ARFF files were developed by the Machine Learning Project at the Department of Computer Science of The University of Waikato for use with the Weka machine learning software  The ARFF file format is: @relation <relation-name> @attribute <attribute-name> <datatype> @data
  • 9.
    9 ARFF File forWeka GUI Demo @RELATION house @ATTRIBUTE houseSize NUMERIC @ATTRIBUTE lotSize NUMERIC @ATTRIBUTE bedrooms NUMERIC @ATTRIBUTE granite NUMERIC @ATTRIBUTE upgradedBathroom NUMERIC @ATTRIBUTE sellingPrice NUMERIC @DATA 3529,9191,6,0,0,205000 3247,10061,5,1,1,224900 4032,10150,5,0,1,197900 2397,14156,4,1,0,189900 2200,9600,4,0,1,195000 3536,19994,6,1,1,325000 2983,9365,5,0,1,230000
  • 10.
    10 Weka – Demo#1 Demo #1 using Weka GUI
  • 11.
    11 Weka Explorer Loading ARFFdata file into Weka.
  • 12.
  • 13.
    13 Choosing LinearRegression model Clickon Classify tab, then Choose > functions > LinearRegression. In Test options, select Use training set and sellingPrice, then hit Start.
  • 14.
  • 15.
    15 Linear Regression Model sellingPrice= -26.6882 * houseSize + 7.0551 * lotSize + 43166.0767 * bedrooms + 42292.0901 * upgradedBathroom + -21661.1208 The regression model tells that granite in the kitchen doesn’t affect the house’s value.
  • 16.
    16 Applying the regressionmodel equation sellingPrice = -26.6882 * 3198 + 7.0551 * 9669 + 43166.0767 * 5 + 42292.0901 * 1 + -21661.1208 sellingPrice = 219,328
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
    21 Demo #2 –H2 Database
  • 22.
    22 Demo #2 –Eureka Naming Server
  • 23.
    23 Demo #2 -Postman
  • 24.
    24 Demo #2 –Zipkin Distributed Tracing
  • 25.
    25 Weka – Demo#2 Demo #2 using Microservices and Weka Java API Source code is available at: https://github.com/marcoyf
  • 26.
    26 Demo #3 –Angular 10 web app
  • 27.
    27 Demo #3 –Angular 10 web app
  • 28.
    28 Weka – Demo#3 Demo #3 – Full Stack app with Angular 10 Source code is available at: https://github.com/marcoyf
  • 29.
  • 30.