scieee AI-readable full text Open interactive document viewer

Implementing new interpretation oriented tools in KLASS to support decision making based on logistic regression

Lavanya, Mandadapu

Abstract

This project is part of an research line of combination of statistics methods and Artificial Intelligence for Knowledge Discovery in ill-structured real domains. At the end of this project KLASS contains the following functionalities: predictive models, dummies management and variables aggregation.

Full text

 BACHELOR THESIS IMPLEMENTING NEW INTERPRETATION ORIENTED TOOLS IN KLASS TO SUPPORT DECISION MAKING BASED ON LOGISTIC REGRESSION Supervisor  :  Candidate: Dr. Karina Gibert Mandadapu Lavanya Implementing new Interpretation oriented tools in KLASS to support decision making based on Logistic regression Mandadapu Lavanya February 2018 - June 2018 1 This if for you, Jahnavi Mandadapu 2 Acknowledgements First of all, I would like to thank my thesis supervisor, Dr. Karina Gibert, for the willingness, the constant support, the advice and the help, at any time of the day and the night during these months that I spent in Barcelona. Thanks to SASTRA university for believing in me and giving me this opportunity to do my Bachelor thesis in Barcelona. Thanks to FIB for accepting me as an exchange student. Thanks to Bea, Luis, Carlos and Johnny for all the support and help that you have provided during this thesis and thanks for being such sweet colleagues in this journey. Thanks to Toni Font for solving all the technical issues I have faced during the installation of softwares. Thanks to Vinnu and RamaKrishnan for being there with me and for ensuring that good times keep flowing. Thanks to the flatmates and friends that I met during this experience, because they made it as good as it was, and easier than it would've been otherwise. Finally, last but not least, the deepest thanks go to my family, who never stopped believing in me, for supporting me, for paying rent and letting me live where I felt like and for all they are, will be and will do hereafter. 3 Contents 1. Introduction 6 1.1. Project goals…………………………………………………..7 2. The Reference system KLASS 9 2.1. Introduction to KLASS………………………………………..9 2.2. Chronology of KLASS……………………………………….10 2.3. KLASS structure……………………………………………..15 3. Methods and Concepts of Interest 16 3.1. Dummy variables…………………………………………….16 3.2. Multiple linear regression…………………………………...17 3.3. Graphical residual analysis in linear regression………….18 3.4. Logistic regression…………………………………………..18 3.5. Residual Deviance…………………………………………..20 3.6. Embedded binary logistic regression……………………...21 3.7. Profile assessment grid……………………………………..23 3.8. Development tools…………………………………………...23 4. Methodology 25 5. New Data management functionalities 27 5.1. Generate Dummy…………………………………………....27 5.1.1. Functionality Description………………………….....27 5.1.2. Interface design and specification……….………….27 5.1.3. Implementation………………………….…………….31 5.2. Qualitative Aggregation……………………………………..32 5.2.1. Functionality Description……………………………. 32 5.2.2. Interface Design and Specification………………….32 5.2.3. Implementation………………………………………..35 6. New Modelling functionalities 36 6.1. Multiple linear regression..……………………………….....36 4 6.1.1. Functionality Description………………………….....36 6.1.2. Interface design and specification……….………….37 6.1.3. Implementation………………………….…………….38 6.2. Logistic regression…....……………………………………..40 6.2.1. Functionality Description……………………………..40 6.2.2. Interface Design and Specification………………….42 6.2.3. Implementation………………………………………..42 7. New Model evaluation and Management functionalities 46 7.1. Evaluate Multiple linear regression...……………………...46 7.1.1. Functionality Description………………………….....46 7.1.2. Interface design and specification……….………….46 7.1.3. Implementation………………………….…………….46 7.2. Evaluate Logistic regression…....…...……………………..47 7.2.1. Functionality Description……………………………..47 7.2.2. Interface Design and Specification………………….47 7.2.3. Implementation………………………………………..47 8. New Input Output functionalities 50 8.1. Export and Import MLR files…….....……………………....50 8.1.1. Functionality Description………………………….....50 8.1.2. Implementation………………………….…………….51 8.2. Export and Import LogReg files...…...……………………..52 8.2.1. Functionality Description……………………………..52 8.2.2. Implementation………………………………………..53 9. Testing 54 9.1. Validation of Multiple linear regression…………………….54 9.2. Validation of Logistic regression……………………………56 10. Application to functionality of elderly patients and decision support 59 11. Conclusions………………………………………………………….68 12. Future works…………………………………………………………69 List of Figures List of Tables Bibiliography 74 5 Chapter 1 Introduction In the context of problem solving, decision making involves choosing between possible solutions. Using the data available on a particular problem, we can process and choose the right decision. To get useful knowledge from available data we use Knowledge discovery from databases (KDD). Taking decisions on data which has both independent and dependent variables is risky. We need to find strong relation between these variables for accurate decisions when dependent variable is qualitative. One way is to build discriminant models. This means to be able to recognize the class of a new object provided that a proper discriminant model has been previously trained. Among the available discriminant models, logistic regression is a proposal coming from Statistical field. Logistic regression permits to determine a qualitative outcome by analyzing a dataset in which there are one or more independent variables.The outcome (often binary) is used to explain the relationship between one dependent binary variable and one or more independent variables. For these reasons, useful application of logistic regression analysis can be found for many fields, some of which are : ● Healthcare : Finding factors related with myocardial infarction from the data of an entire population followed within a period of 10 years. ● Fraud Detection : To recognize fraudulent credit card usages from a database of Internet credit card transactions before approval of operations. In intelligent decision support systems, logistic regression can be used as an internal component that predicts the expected class of a new case to which certain decisions or actions will be assigned. In fact, logistic regression (as other classifiers coming from the machine learning fields) contribute in any context where a diagnosis is required for future treatment. In this project a post-processing of logistic regression that helps to understand and visualize the situation of cases with regards to the plausible diagnosis is presented and treated over a real data set. 6 1.1 Project Goals This project is part of an almost 30-year long research line of combination of statistics methods and Artificial Intelligence for Knowledge Discovery in ill-structured real domains, conducted by Phd Karina Gibert from the Department of Statistics and Operations Research of the Universitat Politècnica de Catalunya- BarcelonaTech (UPC) of Barcelona,Spain. The developments achieved along this years are implemented in a application called JavaKlass, which is currently in its 19th version. JavaKlass was conceived as a system to support knowledge discovery from data in complex domains. Along the years it has been including new functionalities that come from very first versions, mainly oriented to clustering with heterogeneous data, towards high level operations such as automatic interpretation of clusters and concepts induction from clusters and so on. In this particular context, the work [Gibert 2013] is developing the EBLR (Embedded binary logistic regression) methodology that is able to combine several logistic regressions, trained after a clustering process, to provide a certain interpretation of what classes mean. The paper also proposes a visualization of this results in what its called a Profile Assessment Grid (PAG), which is a kind of cubic representation of the logistic regression results for a particular situation in which only 4 classes have to be assessed, under the hypothesis that these classes correspond to an ordinal qualitative variable, that means they can be properly sorted in ascendant or descendant way. This work shows the implementation of all required functionalities to upgrade KLASS to incorporate the EBLR methodology and preliminary visualization of the PAG. To that purpose some specific secondary goals arise. In practice, the new functionalities that this project brings to the Java-KLASS are the following: ● New Data management functionalities, which includes : ○ generation of dummy variables for a selected qualitative variable ○ generation of a new aggregated data matrix from the original dataset according to an aggregation factor or qualitative variable ● New Modelling functionalities : ○ Multiple linear regression ○ Binary logistic regression ● Model assessment functionalities : ○ goodness of fit indicators for Multiple linear regression and logistic regression. ○ graphical residual analysis. 7 ● Model evaluation functionalities, which include : ○ evaluation of linear and logistic regression models over a certain dataset and generation of new variables with predicted values. ● Model management functionalities: ○ Some required functionalities to deal with all previously trained models available for a certain dataset. ● Input / output operations : ○ exporting and importing MLR files. ○ exporting and importing LogReg files. We will present them one by one, explaining how and why they were designed and realized, with screenshots and examples of usage. In the end, we will perform a few case studies, investigating on the behaviour of the modelling functionalities and benchmarking the results with R. KLASS allows to visualize exhaustive LaTex reports, so we will present the actual results that the package produced. The structure of this work is, first we will introduce the reference system KLASS and methods and concepts needed to understand multiple linear regression and logistic regression then we will explain data management functionalities followed by modelling functionalities and Input/ Output functionalities. 8 2.3 KLASS structure In order to understand how the functionalities that we implemented work and interact with each other and with the rest of the software, it is important to know the structure of the JavaKlass. It is a java application that was implemented as a “layered” structure, in order to separate the graphic interface from the actual methods that perform the computation. It is constituted by three main packages: ●jKlass.iu : this package forms the “interface” layer of the system. Here, we can find the classes that draw graphic panels with which users interact with the Klass. They can only perform graphic interactions, store and call methods that perform actual computation and then eventually producing results. ●jKlass.nucli : this is the “core” layer of the system. this contains the methods which actually perform the actions desired by the user. There are two core classes inside this layer which are: ●GestorKlass : Klass can work with multiple matrices at the same time and eventually with multiple users. This class manage to store information about the actual matrix in use and consequently calling the methods corresponding to the correct instance of data to process. ●GestorMatriu : this is the class that represents a single data matrix and holds the methods that perform concrete actions on it, managing its properties and objects and providing information about it when needed.Normally, these methods are called from GestorKlass. GestorMatriu contains the data matrix and all the context to work with it, like associated metadata, knowledge bases, ontologies, dendograms, traffic light panels or models. ●jKlass.util : this package contains classes which are used for the configuration management of the options and parameters of the functionalities and for the communication with the operating system. 15 Chapter 3 Methods and concepts of interest In this chapter we will introduce all the methods used and the concepts needed to understand the development of this project. 3.1 Dummy Variables Dummy variables are the set of binary variables that are generated from a qualitative variable. Number of dummies that are generated for a qualitative variable depends upon the number of modalities of the reference qualitative variable. Dummy variables plays an important role in statistical modelling because this is the way in which qualitative variables enter into the classical statistical models like linear regression and logistic regression. If Xis a data matrix containing variables, in which some of them , ......XX1X2k are qualitative. X= (X, .......X) 1X2k Let us take a qualitative variable . The variable takes values in its Xk Xk domain that contains values.Dk{m, ......m} 1m2s Dk= {m, ......m} 1m2s When we generate dummies for this qualitative variable , we will get new Xk variables which are ., , .....XXm1Xm2.mS These generated variables are binary variables having values 1 and 0. s1 )∀= ( : S In this project we have convenience to generate dummies as numerical variables or qualitative variables (logical or nominal). 3.2 Multiple Linear Regression Main focus of regression methods is to find the relationship between a dependent variable and independent variables(s) and formulate the linear equation between dependent and independent variable(s). If the regression analysis takes 16 place between one dependent numerical variable and one independent numerical variable, then it is called as linear simple regression. Linear regression model with one dependent variable and more than one independent variables is called as multiple linear regression. Multiple linear regression analysis is formulated as in the following [Baron 2014]: x.... xyi= β0+ β1 1i+ . + βK Ki+ ε Y= Dependent variable X  i  = Independent variables βi  = Coefficients ε= Error Estimates of the model parameters ●SSR is the "regression sum of squares" and quantifies how far the estimated sloped regression line, , is from the horizontal "no relationship yi line," the sample mean or y [STAT 501].  SR (y )S= ∑ n i=1 i ︿−y2 ● SSE is the "error sum of squares" and quantifies how much the data points, , vary around the estimated regression line, .yiyi ︿  SE (y)S= ∑ n i=1 i−yi ︿2 ● SSTO is the "total sum of squares" and quantifies how much the data points, , vary around the global mean, .yiy  ST O )S= ∑ n i=1 (yi−y i 2 ● ,estimates , the variance of the errors. In the formula, nSEM =n−k SSE σ2 stands for the sample size, kis number of β coefficients in the model (including the intercept). ● Residual standard error, also named as the regression standard error , which estimates isσ 17 S=√MSE ● Residual term is calculated as ei=yi−yi ︿ ● Coefficient of Determination, R-Squared can be calculated using R2=SSR SST O = 1 − SSE SST O Qualitative variables enter into multiple linear regression as dummy variables. They are generated using Generate Dummy functionality that we have developed in KLASS. 3.3 Graphical Residual Analysis in linear regression Residual analysis plays an important role in validation of regression models fitted from data. In this thesis we will assume a simplified residual analysis containing: ● Histograms of residuals, predicted values and numerical explanatory variables ● Boxplots of residuals, predicted values and numerical explanatory variables. ● Statistical summaries of residuals, predicted values and numerical explanatory variables. ● Bar charts of qualitative explanatory variables ● Frequency tables of qualitative explanatory variables. ● Residual plots: ○ Residuals on vertical axis and predicted value on horizontal axis. ○ Residuals on vertical axis and independent numerical variables on horizontal axis. If points in the residual plots are randomly dispersed around the horizontal axis, a linear regression model is appropriate for the data. Otherwise, missing regressors or heteroskedasticity or non linearities occur and model is not valid. 3.4 Logistic Regression The central mathematical concept that underlies logistic regression is logit  . logit is the natural logarithm of the odds ratio. If we plot the simplest case of linear regression for one independent variable and one dichotomous dependent variable, we will get two parallel lines each corresponding to a value of the dichotomous dependent variable [vanderbilt] . (See figure 1). 18 Figure 1 : Plot between one independent variable and dichotomous dependent variable. Source [Vanderbilt]. Because the two parallel lines are difficult to be modelled with an ordinary least squares regression equation, one may create categories of the predictor and compute the mean of the outcome variable for the respective categories. This plot results in a S-shaped or Sigmoidal curve (see figure 2). This curve cannot be described by a linear equation for two reasons 1. The extremes do not follow a linear trend. 2. The errors are neither normally distributed nor constant across the entire range of the data and follows the logistic function. Figure 2: Sinusoidal Curves. Source [Vanderbilt] Logistic regression solves these problems by applying the logit transformation to the dependent variable [Montgomery 2012]. Logistic regression equation having multiple independent variables can be given by the following equation ogit(y)n x ..... x li=l(Pi 1−Pi)= β0+ β1 1i+ . + βK Ki y=Dependent variable 19 =Independent variablesxi P= , being Y the outcome of interest and are the independent(Y|X, , ...X)P1X2.K Xk variables.  Pi=eβ +β x+....+β x 0 1 1iK Ki 1+eβ +β x+....+β x 0 1 1iK Ki Odds and Odds Ratio There are algebraically equivalent ways to write the logistic regression model. (1)xp(β x..... x) Pi 1−Pi=e0+ β1 1i+ . + βK Ki The above equation describes the odds of being in the current category of interest. By definition, odds for an event is / 1- , where is the probability of P P P the event occurrence. From expression (1) it is easy to see that the logistic regression can be reduced to a multiple linear regression problem as well. og x ..... x l(Pi 1−Pi)= β0+ β1 1i+ . + βK Ki However in this project we used external library that is fitting logistic regression model directly. ( See section 3.8). 3.5 Residual Deviance Deviance is the measure of goodness of fit of the logistic regression model.Higher numbers always indicates the bad fit.The residual deviance shows how well the response variable is predicted in the model with the inclusion of intercept and the independent variables. D= 2 ∑ n i=1 y ln 1 )ln (i(yi P ︿ i)+ ( − yi((1−y) i (1−P) i ︿)) 20 =predicted probabilityP =dichotomous dependent variabley 3.6 Embedded Binary Logistic regression As mentioned in section 1.1, for PAG we need to have a combination of combined binary logistic regressions that can be nested according to the natural ordering of the classes. EBLR proposes this [Gibert 2013]. EBLR is a formal method to recognise the class of a new object, provided that a previous set of clusters has been found (P) and a total order (R) exists over the clusters. From a statistical point of view, the class can be considered as a qualitative variable to be fitted. The EBLR consists of nesting several binary logistic regressions to find the better prediction of a new case. ● Defining a family of embedded sets of objects, according to the R ordering being  the total set of objects to be analyzed.l ● For the particular case of 4 classes, this is defining 4 datasets. , l0=l ∖ ll1=l0 , , l ∖ (l l )l2= 0 ⋃ 1l ∖ (l l l )l3= 0 ⋃ 1⋃ 2 l ∖ (l l l l )l4= 0 ⋃ 1⋃ 2⋃ 3 being, , , { i ε l}l1= { i ε l i ∈C}l2= : / 1 { i ε l i C}l3= : ∈ 3⋃C4 { i ε l i }l4= : ∈C4 ● Define = p(i ∈| ), k = 1: ξ − 1. This estimates , a binary logistic Πk Cklk k1 regression model that can recognize class. For it estimates the C1 k2 probability of being in when it is known that object is not in and so on.C2C1 ● Find (i) to estimate ; apply binary logistic regression to the set of Pk ︿ Πk objects and the total set of variables X. The final model, (i) will only lk pk ︿ involve and will enable detection of when the larger classes (upon R) xp Ck have been previously discarded: 21 ● Given a threshold ε = [0, 1], EBLR_estimate calculates the logistic models for all classes and EBLR_use uses the results of EBLR_estimate to predict a class for new objects. Table 1: Algorithm of the EBLR_estimate method. Source [gibert 2013]. Table 2: Algorithm of EBLR_use method. Source [Gibert 2013]. 22 3.7 Profile Assessment Grid Profile assessment grid (PAG) represents a simple post-processing of the EBLR method, that enables non expert end-users to use the model. It is a graphical transformation of EBLR_use that aims to provide a frame to visualize the most likely profile of a new object in a unitary cube, using a minimal set of relevant variables, and currently works for a case of 4 ordered profiles.  Figure 3: Profile’s Assessment grid ( ).5 ε = 0 The PAG is built by associating three orthogonal axes with the three EBLR logistic models that are required to discriminate among the four profiles (the Π2 being represented on the X axis, the on the Z axis, the on the Y axis) and Π3 Π1 placing the origin in the top-right-front corner of the cube, for visual purposes. The threshold ε is used to label, and conveniently colour regions of the cube assigned to each profile, according to the conditionals used in the EBLR process 3.8 Development Tools Java under Eclipse, KLASS and JSAT are the only tools that are going to be used. Eclipse is flexible and serves as a good platform for java projects. 23 The main of our project is to develop and incorporate new modelling functionalities into KLASS. We will develop several modules corresponding to the different new functionalities mentioned in the section 1.1. Part of this will be developed from scratch. To develop our modelling modules we want to use already existing machine learning library, so that we can develop this project in less time by reducing the risk of implementation errors. There exist relatively few general purpose machine learning libraries for use. We have identified some of the libraries in which multiple linear regression and logistic regression are implemented in java such as JSAT[Raff 17] ,Weka[waikato 97] ,Java-ML[Abeel 2009]  . As we know, KLASS is a software that is entirely developed in java. If we incorporate a library that has been written in java, it will be easy to use the algorithms. The library that suits our project in a best way is JSAT. when a larger dataset is taken, JSAT analyzed the data faster than Weka. Java Statistical Analysis Tool (JSAT) [Raff 2017] is a machine learning library written in java 6 and has no dependencies, making it easy to integrate into KLASS without conflicts. JSAT includes numerous algorithms for classification and regression, clustering, feature selection and engineering. The part that we are interested is Regression.  Before incorporating into KLASS, we checked muliplelinearregression and logisticregression modules separately, we used iris.dat as input and benchmarked with R. Results are similar. Then, we included a folder called regressionjsat  in jklass.nucli in order to use MultipleLinearRegression and Logisticregression present in jsat.regression  . There is a method called train  in both MultipleLinearRegression and LogisticRegression  which computes coefficients given a dataset as input. This dataset must contain dependent variable at last and only works with numerical values. They have used least squares solution to calculate β values or regression coefficients. From JSAT only the coefficients are taken, predictions, residuals, model parameters and deviance are calculate using the formulas given in the previous section. We will use LaTeX too for writing reports. KLASS produces LaTeX outputs sometimes. So LaTeX is also indirectly linked to the project development. LaTeX is more comfortable if we have a lot of mathematical equations in our report. 24  Figure 8 :Descriptive analysis of Numerical dummy variable virginica0  Figure 9: Descriptive analysis of Qualitative dummy variable virginica3 5.1.3 Implementation In order to develop the Generate Dummy functionality we have added following classes to the KLASS packages that are mentioned in 2.3. ●PanelGenerateDummy: This class calls the panel to generate dummy variables, given a qualitative variable.This class is present in jKlass.iu package. ●generateDummyMLR  : Computes the modalities and calls generateDummyVar  present in MatriuDades  . This is present in jKlass.nucli. ●generateDummyVar:  Calls generateDummyVarBinary present in class Operacio  .This is present in jKlass.nucli. 31 ●generateDummyVarBinary  : Based on the option that user choose, this generates new columns in Matriu de dades  .This is present in jKlass.nucli. If D’accord button is clicked without selecting selected variable then proper error message will be generated. 5.2 Qualitative Aggregation 5.2.1 Functionality description The Qualitative Aggregation functionality allows the user to generate new Data Matrix, having aggregation factor as a first column and rest of the columns can be selected from one of the options that appear in the panel, which are : ● Counts ● Size ● Ratio ● Odds ● Odds Ratio ● Log Odds Ratio 5.2.2 Interface design and specification The functionality is available on Data drop-down menu, and its panel is generated by the class PanelBDaggregation.java  , in the jKlass.iu  package.  Figure 10: View of Qualitative Aggregation panel 32 Next we will present each element of the panel explaining its task. ●Qualitative Variables: This field contains all the qualitative variables present in the current data matrix. To perform qualitative aggregation user must choose from this list. ●Selected variable : This must contain only two modalities.This is considered as the response variable that helps us to generate the counts. ●Aggregation Factor: We can select one or more qualitative variables to be our explanatory variables. In case if we select one qualitative variable then we will generate dummies and perform Table of frequencies present in bivariant java object to get the frequencies which are considered as counts in our case. If we select more than one qualitative variable then they will be concatenated to get a single explanatory variable and Taula de frequencies will be performed. ●Name of new Matriu : User can name the generated new matrix in the textfield provided. Default name will be the Aggregated0. where 0 is the count for that particular session. ●Include Null combinations: Sometimes there will be 0 counts, which leads to infinity value for logs odds ratio. To avoid such conditions by default we are removing null count rows. But, if user wants to include those rows then he can do that by enabling this checkbox. ●Imputation values of Infinity : If user enables Include null combinations then the positive and negative infinity values in log odds ratio are replaced by 1E+18. User can change this imputation value, once include null combinations is enabled. ●Descriptive Analysis of new Matrix: By checking this user gets a latex report which has univariant description of all the columns present in the new matrix. Figure 12 shows univariant analysis that are generated for log odds ratio. ●Per defecte : On clicking this we can select all options which are counts,size,ratio,odds,oddsratio,logoddsratio and Include null combinations.log odds ratio and show descriptive analysis are enabled by default. ●D’accord : On clicking this button a new matrix will generate in Matriu de dades. First column of the matrix will always be single explanatory variable that is taken from the aggregation factor., and rest of the columns to be generated are selected from the panel. Figure 11 shows the new matrix with all options being selected. ●Cancel-la : This clears the window. 33  Figure 11 :View of new generated matrix  Figure 12: Univariant descriptive analysis of Log odds ratio. 34 5.2.3 Implementation In order to develop the Qualitative Aggregation functionality we have added following classes to the KLASS packages that are mentioned in 2.3. ●PanelBDaggregation.java  : This class calls the panel to perform qualitative aggregation.This class is present in jKlass.iu package. ●generateBDaggregation  : this method is present in GestorMatriu and called by the generateBDaggregation method present in GestorKlass. This returns List of Lists which contains name of the explanatory variable with the respective counts value. This counts values are taken from the bivariant object present in KLASS when we pass aggregated factor and selected variable. ● createMatriuLogistic :  This method call the GestorMatriu constructor with the name of new matix and list of lists, which are returned from generateBDaggregation. This method is present in GestorKlass. ●GestorMatriu  : This helps to generate new objects and properties that are needed to generate new matrix. ●afegirPropietatLogisti  c : returns propietats for the new matrix and adds to the propietats of the new GestorMatriu. ●afegirObjecteLogistic : returns objectes for the new matrix and adds to the objectes of the new GestorMatriu. ●computLogodds  : Given the imputation value, list of choices and counts, this method which is present in the GestorMatriu computes the values of selected choices and adds these values as new columns in the new matrix. ● addColAggre:  Given the column name and the values. This method creates the new column. 35 Chapter 6 New Modelling Functionalities We have created a new menu item inside KLASS called Predictive to include our modelling functionalities.We have created two modelling functionalities which are ● Multiple linear regression ● Logistic regression 6.1 Multiple Linear Regression 6.1.1 Functionality description This functionality allows the user to perform multiple linear regression analysis over the current matrix. In order to perform this analysis user must select a response variable, which is numerical and one or more explanatory variable(s) which can be numerical or qualitative. Once response and explanatory variables are selected, user can select what calculations should be performed on this variables.Following are the options that user can select ● Coefficients ● R-Squared ● S-Squared ● Predicted ● Residuals ● Fer dummies visibles ● Graphical residual Analysis 36 6.1.2 Interface design and specification  Figure 13 : View of Multiple linear regression panel Now we will present each element of the panel explaining its task. ●Vars.Num : This field shows the list of numerical variables present in the current matrix. ●Qualitative variables : This field shows the list of qualitative variables present in the current matrix. ●Response variable : This must be a numerical variable and is selected from Vars.Num . This serves as the dependent variable. ●Explanatory variables: These are independent variables and can be both numerical or qualitative. This must be selected from Vars.Num list in the panel. ●Quali Explanatory variables : These are also independent variables and are qualitative. This must be selected from Qualitative variables list in the panel. ●Coefficients : Coefficients are calculated by selecting this. By default , this is made selected. We have used JSAT to get the coefficients. 37 ●Predicted: Once the coefficients are generated, we can calculate the predicted values using the formulas given in section 3.2. ●Residuals : Once we have the predicted values, by subtracting original response variable values with predicted values, we can get the residuals. When predicted and residual options are selected, then they will generate new columns in the data matrix with the names given in the corresponding name field present in the panel. By default, the names are pre and res followed by the count value. When selected R-squared and S-Squared values are also computed using the formulas given in section 3.2.Remember, we have only taken coefficients from JSAT and rest of the calculations are implemented from scratch. ●Fer Dummies visibles : The multiple linear regression module of JSAT only works with numerical variables. So, If user selects Quali Explanatory variables, then numerical dummies are generated using Numerical Indicator in Generate Dummy panel. User can decide whether these intermediate dummy columns should be visible once he exit from the multiple linear regression module. If he want them to be visible then he must select this checkbox otherwise all the intermediate columns generated by this will be eliminated from the data matrix. We have created a list of Multiple linear regression objects in GestorMatriu. For each multiple linear regression analysis an object will be created and added to this list. The object contains ● Response variable ● Explanatory variables ● Coefficients ● R-squared ● S-squared ● Modelterms; which is a hashmap with the coefficients as keys and explanatory variables as values. ● Name of the model In the panel the value present in the name of the model field will be given in to the name of the model present in the MLR class.Using this name we can access particular multiple linear regression model. By default, name will be MLR followed by the counter. User can change this name if desired. ●Graphical residual analysis : On selecting this, Univariant analysis of predictions, residuals and bivariant analysis with the residuals on X-axis and all the explanatory variables and predicted on Y-axis will take 38 place.Figure 14 shows the graphical residual analysis of Bicingclass.dat dataset, we have taken response variable as temp and explanatory variables as windspeed,registered and season.  Figure 14: Example of Graphical residual analysis After selecting the response variable, Explanatory variables and proper calculations, when we press D’accord it will produce a LaTex document which contains the results of the analysis. The structure of the output has been designed in the following way ● Information about input parameters ● Information about method of fitting ● Information about model estimated parser ● Information about coefficients ● Goodness of fit indicators ● If graphical residual analysis is selected then univariant and bivariant analysis will also be added to this LaTex file. 39  Figure 15:  Multiple linear regression results display format 40 Chapter 7 New Model Evaluation and Management Functionalities 7.1 Evaluate Multiple Linear Regression 7.1.1 Functionality description This functionality allows the user to select one of the multiple linear regression models that are present in the current GestorMatriu. When a model is selected this panel generates a new column in data matrix which contains the predicted values that are computed from the Multiple linear regression equation.  Figure 19: View of evaluate Multiple regression models panel 7.1.2 Interface design and specification ●Llista MLR: This field shows all the multiple linear regression models present in the current GestorMatriu. ●MLR a evaluate: The selected MLR object will be shown here and the response variable and the explanatory variables with associated coefficients are displayed in a table present on the right side. ● In figure PreMLR0 is the new column that is generated when we evaluate MLR0 object which contains temp as response variable and atemp,casual,seasonrec as explanatory variables. 7.1.3 Implementation In order to develop the Evaluate Multiple linear regression functionality we have added following methods and classes to the KLASS packages that are mentioned in 2.3. 47 ● PanelEMLR: This class calls the panel to evaluate multiple linear regression models.This class is present in jKlass.iu package. ● computeEquationMLR:  This method which is present in GestorMatriu helps to creates new predicted column using the coefficients and explanatory variables present in the selected model.  Figure 20:  New column PreMLR0 is generated when we evaluate MLR0 object 7.2 Evaluate Logistic Regression 7.2.1 Functionality description This functionality allows the user to select one of the multiple linear regression models that are present in the current GestorMatriu. When a model is selected this panel generates two new columns in data matrix which contains the predictions and log prediction values that are computed from the logistic regression equation. 48  Figure 21:  View of Evaluate Logistic regression models panel 7.2.2 Interface design and specification ●Llista LR: This field shows all the logistic regression models present in the current GestorMatriu. ●LR a evaluate: The selected LR object will be shown here and the response variable and the explanatory variables with associated coefficients are displayed in a table present on the right side. ● In figure PreLR2 and CMpredi3 are the new columns that are generated when we evaluate LR2 object which contains HolidayRec as response variable and atemp,temp, seasonRec as explanatory variables. 7.2.3 Implementation In order to develop the Evaluate logistic regression functionality we have added following methods and classes to the KLASS packages that are mentioned in 2.3. ● PanelELR: This class calls the panel to evaluate logistic regression models.This class is present in jKlass.iu package. ● computeEquationLR:  This method which is present in GestorMatriu helps to creates new predicted column using the coefficients and explanatory variables present in the selected model. ● computeLogprediction :  This method which is present in GestorMatriu helps to creates new log predicted column using the coefficients and explanatory variables present in the selected model.This method is called from the computeEquationLR  method. 49 Figure 22: New columns PreLR2 and CMpredi3 are generated when we evaluate LR2 object 50 Chapter 8 New Input Output Functionalities 8.1 Exporting and Importing MLR files 8.1.1 Functionality description When multiple linear regression analysis is performed on a dataset then it will create a MLR model object. To use this model even after the session is closed we are going to create a file which contains ● Name of the model ● response variable ● number of model terms and then the model terms present in the MLR object. This files are given a .MLR extension and are exported into resultats folder present in KLASS\dades.  Figure 23: Export Multiple linear regression models If user want to import the MLR files, then he must go to the Export MLR menuitem present in Arxiu drop-down menu. Once it is clicked then all the .MLR extension files present in KLASS\dades\resultats will be open.When user selects one of this files then the data is retrieved from the file, MLR object is created and added to the list of MLR objects present in GestorMatriu. 8.1.2 Implementation In order to develop the this we have added following methods and classes to the KLASS packages that are mentioned in 2.3. 51 ● PanelExportMLR:  This class calls the panel to export MLR objects.This is present in jKlass.iu package. ●jMenuImportarMLR_actionPerformed  : This method helps to read the .MLR files and creates MLR objects.It is present in FrPrincipal.java. ● addTolrobjects :  This method which is present in the GestorMatriu adds the newly created MLR object into the list of MLR objects. 8.2 Exporting and Importing LR files 8.2.1 Functionality description When logistic regression analysis is performed on a dataset then it will create a LR model object. To use this model even after the session is closed we are going to create a file which contains ● Name of the model ● response variable ● number of modelterms and the modelterms present in the LR object. This files are given a .LOR extension and are exported into resultats folder present in KLASS\dades.  Figure 24: Export Logistic regression models panel If user want to import the LR files, then he must go to the Export LogReg menuitem present in Arxiu drop-down menu. Once it is clicked then all the .LOR extension files present in KLASS\dades\resultats will be open.When user selects one of this files then the data is retrieved from the file, LR object is created and added to the list of LR objects present in GestorMatriu. 52 8.2.2 Implementation In order to develop the this we have added following methods and classes to the KLASS packages that are mentioned in 2.3. ● PanelExportLR:  This class calls the panel to export MLR objects.This is present in jKlass.iu package. ●jMenuImportarLR_actionPerformed  : This method helps to read the .LOR files and creates LR objects.It is present in FrPrincipal.java. ● addTolrobjects :  This method which is present in the GestorMatriu adds the newly created LR object into the list of LR objects. 53 Chapter 9 Testing 9.1 Validation of Multiple linear regression The dataset that we have used to validate multiple linear regression module is iris.dat [UCI 88] .  This dataset contains 3 classes of 50 instances each, where each class refers to a 3 different species of iris flower (Setosa, Virginica and Versicolor) . The rows being the samples with 150 flowers from IRIS genera and the columns being: Sepal Length, Sepal Width, Petal Length, Petal Width and Species. Now we will perform multiple linear regression analysis for three cases in which ● Case 1: Sepal length as response variable and petal length, petal width and sepal width as explanatory variables that means we are considering only numerical explanatory variables. ● Case 2: Sepal length as response variable and specie as explanatory variable that means only qualitative explanatory variable. ● Case 3: Sepal length as response variable and Sepal width, Petal length, species as explanatory variables. As species is a qualitative explanatory variable, dummies are generated for species and first dummy will be automatically ignored, such that the MLR considers as a reference group with effect included in . We are estimating the modelβ0 Case 1 : epal length βSepal width P etal length βP etal W idthS = 0+ β1+ β2+ 3 where Versicolor is a binary variable that evaluates 1 for versicolor flowers and 0 to others. Similarly Virginica is a binary variable that evaluates 1 for virginica flowers and 0 to others.Once analysis is done , we will get the results in a LaTex file. ( see Table 3)  Table 3: Coefficients obtained in KLASS for case 1 54 In table 4 the results obtained from R package confirm that we get same results in KLASS (apart from some precision issues). JSAT is being used double float. So we presume that one precision is got with JSAT, although we open a future line to better check this.  Table 4: R code and Coefficients obtained in R for case 1 Case 2 : The regression equation that we are working in this case 2 is: epal length βV ersicolor V irginicaS = 0+ β1+ β2  Table 5: Coefficients obtained in KLASS for case 2  Table 6: R code and Coefficients obtained in R for case 2 55 Case 3: The regression equation that we are working in this case 3 is: epal length βSepal width P etal length V ersicolor V irginicaS = 0+ β1+ β2+ β3+ β4  Table 7: Coefficients obtained in KLASS for case 3  Table 8: R code and Coefficients obtained in R for case 3 We can see that in all the three cases the coefficients we got when we performed MLR in R are same with the coefficients we got when we perform MLR in KLASS. Even the model parameters, predicted and residuals also matched with those of R. Now, we can say that our Multiple linear regression module is working well. We have tested our module even with other datasets like Bicingclass.dat, bicingordenate.dat etc. In all the cases, we have benchmarked our results with R. 9.2 Validation of Logistic regression The dataset that we have used to validate our Logistic regression module is Bicingclass.dat. This data contains 600 rows with 23 columns. These are bicing trips from Montreal city in Canada. It has both numerical and qualitative variables. Some of the numerical variables are temperature, humidity, date, time, windspeed 56 6. If we perform 3D visualization, which is present in descriptive menu, taking CMpredi2 in X , CMpredi3 in Y, CMpredi4 in Z and Diagnosis0.5 in T , then we will get a pseudo PAG which looks like in figure 29 (with =0.5) and ε figure 30 (with =0.3).ε Figure 29: CMpredi2, CMpredi3 and CMpredi4 are new log predicted variables. 63 Figure 30: Data Matrix with Diagnosis variable which we will take as T in 3D vvisualization. Implementing EBLR_use in KLASS through KnowledgeBase The Avaluar BC  functionality present in KLASS helps us to generate the T categorical variable that directly use EBLR_use algorithm and produces a new variable with the result of each predicted variable (see figure 28). We take the advantage of the knowledge base management functionalities already available in KLASS to implement the EBLR_use algorithm. In fact no new code is required since EBLR can be formalized directly for a knowledge base. BC Diagnosis 0.5 We have generated a knowledge base with four rules taking . as 0.5 ε In figure 28, the diagnosis value for a patient having an id 202924 is green. Now if we observe the CMpredi2,CMpredi3 and CMpredi4 values for this id, we will see that CMpredi2 and CMpredi3 value is less than 0.5 and CMpredi4 value is greater than 0.5. in the knowledge base is satisfied for this id. So the value green is r3 given in the diagnosis for 202924 id. 64 Table 14: Knowledge Base that replaces EBLR_use for .5 ε = 0  Figure 31: Pseudo PAG for 0.5ε = we can see 4 different regions present in pseudo PAG which resembles the 4 regions present in the PAG. Majority of class high is given as impaired sample of patients. Moving more or less, conservative diagnosis will be given.ε 65 BC Diagnosis 0.3 We have generated a knowledge base with four rules taking . The as 0.3 ε Avaluar BC  functionality present in KLASS helps us to generate a categorical variable for this knowledge base. (See table 15) Table 15: Knowledge Base when .3 ε = 0  Figure 33: Pseudo PAG with .3 ε = 0 In this case with , we can observe that there are more class. .3 ε = 0 C3 66 If we add colors to the walls of this Pseudo-PAG then we will get a 3D graph which resembles like PAG (see figure 34) Figure 34: Pseudo PAG with colors for .3 ε = 0 Generation of EBLR Logistic regression from scratch In this we used previously found LogReg to show how pseudo-PAG can be visualized using functionalities that KLASS offers, also the probability to fit the LogReg models internally as well. To implement the EBLR_estimate algorithm we need to follow the sequence of steps described below: ● Our response variable is Class4. But response variable in logistic regression must be a binary variable. ● From the original data set, perform logistic regression analysis by taking Class4.class91 as response variable which is generated by using recode functionality in KLASS and B2,B4,B7 as numerical explanatory variables save the model. ● Now, select a submatrix by removing all the samples that contains class88 modality in Class4 variable. ● Perform logistic regression on this sub matrix with the response variable being Class4.class88 as response variable and B2,B4,B7 as explanatory variables and save the model. ● Now, select a submatrix from the above matrix by removing all the samples that contains class87 modality in Class4 variable. 67 ● Perform logistic regression on this sub matrix with the response variable being Class4.class87 as response variable and B2,B4,B7 as explanatory variables and save the model. ● Now we have 3 LOR files present in the KLASS\dades\resultats and when we import them into KLASS then 3 LOR models will be created and added to the list of logistic regression models present in GestorMatriu. ● Perform evaluation of logistic regression on the 3 models using evaluate logistic regression functionality. This will give us 3 predicted variables required for the 3D visualization. 68 Chapter 11 Conclusions All the functionalities that we implemented produced more than satisfying results and have been integrated well with the rest of the application and this launches release javaKlass v19. Now KLASS has all the functionalities that we have mentioned in 1.2. As we benchmarked our results with R, we can confirm that our modules are working well and are producing correct results. KLASS is now able to learn predictive probabilities for a certain number of clusters and visualize the assigned class of a patient through the EBLR methodology in a 3D graph giving a first support to the diagnosis and follow up of patients In my third year of B.Tech I have Data Analysis and Data Mining course. The concepts present in that course helped me to understand the multiple linear regression and logistic regression. I have been programming in java for past two years and it helped me to implement the methods in more efficient way. I have been introducing logistic regression into KLASS as a means to build PAG. So, we have prioritize all the elements required to build the PAG and there is an important missing part which is the inference on the models. But, as we can export the logistic regression models outside KLASS, we can easily enter them into R and can run all the inferencies and now we can eliminate non significant terms from the model files (.LOR or .MLR) while the inference of the module being infected, out of the scope of the paper. 69 Chapter 12 Future Works ● In future, we can do the real implementation of the PAG procedure that are the sequence of calls to the existing functionalities in the KLASS. ● We can do the modification of the 3D representation that incorporates the wall with the colors in the cube. ● We can include classical statistical modelling that makes inference on coefficients of logistic regression models and the goodness of fit indicators. ● In future, it would be interesting to implement the PAG for more than 4 classes. ● We can add new functionality that automatically generates BC Diagnosis given the 3 probability variables and threshold (trivial using current form of BC Diagnosis). List of Figures 1. Plot between one independent variable and dichotomous dependent variable 19 2. Sinusoidal Curves 19 3. Profile’s Assessment grid ( ). 23 .5 ε = 0 4. View of Generate dummy panel. 27 5. Numerical dummy generation 28 6. Qualitative dummy generation on selecting Logical Indicator 29 7. Nominal dummies and prefix generation examples 30 8. Descriptive analysis of Neumerical dummy variable Virginica0 31 9. Descriptive analysis of Qualitative dummy variable Virginica3 31 10.View of qualitative aggregation panel 32 11. View of newly generated matrix. 34 12.Univariant descriptive analysis of Log odds ratio 34 13.View of Multiple linear regression panel 37 14.Example of Graphical residual analysis 39 15.Multiple linear regression results display format 40 16.View of Logistic regression panel 42 17.Confusion matrix with threshold 0.5 44 18.View of Logistic regression display format 45 19.View of Evaluate Multiple linear regression models panel 46 20. New column PreMLR0 is generated when we evaluate MLR0 object 47 70 21.View of Evaluate Logistic regression panel 48 22.New columns PreLR2 and CMpredi3 are generated when we evaluate LR2 object. 50 23.View of Export Multiple linear regression models panel 51 24.View of Export Logistic regression models panel 52 25.phigh.LOR file 61 26.pIntI.LOR file 61 27.pIntII.LOR file 61 28. phigh, pintI and pintII models present in Gestor Matriu for evaluation. 62 29.CMpredi2, CMpredi3 and CMpredi4 are new log predicted variables. 63 30.Data Matrix with Diagnosis variable which we will take as T in 3D visualization. 64 31. Pseudo PAG with =0.5. 65ε 32. Pseudo PAG with =0.3. 65ε List of Tables 1. Algorithm of the EBLR_estimate method 22 2. Algorithm of the EBLR_use method 22 3. Coefficients obtained in KLASS for case 1. 54 4. R code and coefficients obtained in R for case 1. 55 5. Coefficients obtained in KLASS for case 2. 55 6. R code and coefficients obtained in R for case 2. 55 7. Coefficients obtained in KLASS for case 3. 55 8. R code and coefficients obtained in R for case 3. 56 9. Coefficients obtained in KLASS for logistic regression model. 56 10.R code and coefficients obtained in R for logistic regression module for Bicingclass.dat. 57 11.Residual deviance obtained in KLASS. 57 12.Residual deviance obtained in R. 58 13.Knowledge Base that replaces EBLR_use with . 58 14.Knowledge Base that replaces EBLR_use with . 60 .3 ε = 0 15. Prediction values from [Gibert 2013]. 65 71 Bibiliography 1. [Gibert 2013] K.Gibert, G.Rodriguez-Silva, R.Annicchiarico (2013) Post-processing: bridging the gap between modeling and effective decision-support. The profile assessment grid in human behavior. 2. [Gibert 91] K. Gibert. Klass. estudi d'un sistema d'ajuda al tractament estadstic de grans bases de dades.  Master's thesis, Universitat Politecnica de Catalunya, 1991. 3. [Gibert 94] K. Gibert. L'us de la informacio simbolica en l'automatitzacio del tractament estadstic de dominis poc estructurat  s. PhD thesis, EIO Dep, UPC, Barcelona, Spain, 1994. 4. [Gibert 05] K. Gibert and R. Nonell. Descriptive statistics with klass. supporting latex documents elaboration. In Proceedings of the 3rd World Conference on Computational Statistics and Data Analysi  s, page 90, 2005. 5. [Gibert 08] K. Gibert and R. Nonell. Pre and postprocessing in klass. In Proceedings of the iEMSs IVth International Congress of Environmental Modeling and Software (DM-TES'08 Workshop)  , 2008. 6. [GCV 12] K. Gibert, D. Conti, and D. Vrecko. Assisting the end-user in the interpretation of profiles for decision support. an application to wastewater treatment plants. Environmental Engineering and Management Journal, 11(5):931{944, January 2012. 7. [GRSA 13] K. Gibert, G. Rodrguez-Silva, and R. Annicchiarico. Post-processing: Bridging the gap between modelling and effective decision-support. the prole assessment grid in human behaviour. Mathematical and Computer Modelling  , page 16331639, April 2013. 8. [Gibert 14] K. Gibert. Automatic generation of classes interpretation as a bridge between clustering and decision making. International Journal of Multicriteria Decision Making  , 4(2), 2014. 9. [GC 14] K. Gibert and D. Conti. On the understanding of proles by means of post-processing techniques: an application to financial assets  . International Journal of Computer Mathematics, 2014. 10. [GGRRS 08] K. Gibert, A. Garca-Rudolph, and G. Rodrguez-Silva. The role of kdd support-interpretation tools in the conceptualization of medical proles: an application to neurorehabilitation  . Acta Informatica Medica, 16(4):178{182, December 2008. 11. [MS 14] S. Molla Santiago. Generalitzacio de metodes de density-based clustering a dades mixtes  . Master's thesis, Universitat Politecnica de Catalunya, June 2014. 12. [Raff 17] Edward Raff (2017 April) JSAT: Java Statistical Analysis Tool, a Library for Machine Learning. 13. [Baron 2014] Baron, M, Chapman & Hall Probability and statistics for computer scientists  - , 2014. ISBN: 9781439875902 72