ML - Multiple Linear Regression

A
Andrew FerlitschSecurity Engineer/Consultant at AllMed Healthcare Management
Regression Methods in
Machine Learning
Multiple Linear Regression
Portland Data Science Group
Created by Andrew Ferlitsch
Community Outreach Officer
July, 2017
Multiple Linear Regression
X1 (Independent Variable)
Y (Dependent Variable) Hyperplane
• Used to Predict a correlation between more than one
independent variables and a dependent variable.
e.g., Income and Age is correlated with Spending
• When the data is plotted on a graph, there appears to
be a hyperplane relationship.
X2 (Independent Variable)
Simple vs. Multiple Linear Regression
• Simple Linear Regression – one independent variable.
y = b0 + b1x1
• Multiple Linear Regression – multiple independent
variables.
y = b0 + b1x1 + b2x2 … + bnxn
2nd independent
variable and
weight (coefficient)
nth independent
variable and
weight (coefficient)
Feature Elimination
ID Income Age Height Spending
37 18000 18 5’8”
38 75000 40 5’9”
39 27000 28 6’1”
40 24000 26 5’6”
41 45000 34 6’2”
• In a dataset, we may not want to keep all the independent
variables (features) in our model:
• More Features = More Complex Model
• If feature does not contribute to prediction, adds noise
to the model.
ID fields are like
random numbers –
do not contribute
to prediction.
Height not likely or
very little to
influence spending
Backward Elimination
• A method for identifying and removing independent
variables that do not contribute enough to the model.
• Steps:
• Fit (Train) the model with all the independent variables.
• Calculate the P-value of each independent variable.
• Eliminate independent variable with highest P-value above
threshold (e.g., 0.05 [5 percent]).
• Repeat (re-fit) until there are no independent variables with
P-value above threshold.
All Variables Train
Is Variable with highest
P-value > Threshold
DONE
Eliminate the variable
Multiple Linear Regression in Python
from sklearn.linear_model import LinearRegression # sci-kit learn library for linear regression
regressor = LinearRegression() # instantiate linear regression object
regressor.fit(X_train, y_train) # train (fit) the model
• Perform Linear Regression with all independent variables.
y_pred = regressor.predict( X_test ) # y_pred is the list of predicted results
• Run (Predict) the model on the test data.
• Analyze (View) the predicted values (y_pred) to the actual values (y_test)
Backward Elimination in Python
import statsmodels.formula.api as sm
X = np.append( arr = np.ones( (nrows,1 )).astype(int), values = X, axis = 1 )
• Prepare for Backward Elimination.
• The statsmodel does not take into account the constant b0.
• Need to fake it by adding a x0 = 1 independent variable for b0.
Function to create
column of ones
Append column
of ones to X
Create array of one
column of nrows
Append ones
to this array
X_opt = X[:, [0, 1, 2, 3, 4] ]
• Create array of optional independent variables (features) from which we
will eliminate independent variables.
All rows Start with all columns (i.e., 0, 1, 2 .. N)
Backward Elimination in Python (2)
ols = sm.OLS( endog = y, exog = X_opt).fit() # Create OLS object and fit the model
ols.summary() # Display Statistical Metrics including P-values
• Use the class Ordinary Linear Square (OLS) from stats model to train (fit)
the model and get P-values.
Independent
Variables
Dependent
Variable (Label)
• Example elimination of an independent variable (x2).
X_opt = X[:, [0,1,3,4,5]]
ols = sm.OLS( endog = y, exog = X_opt).fit()
ols.summary()
Eliminate x2 (2), where 0 is x0 (constant)
• Repeat elimination until independent variable with highest P-value is not
greater than the threshold (e.g., 0.05).
1 de 8

Recomendados

Logistic regression por
Logistic regressionLogistic regression
Logistic regressionsaba khan
46.1K visualizações11 slides
Machine learning session4(linear regression) por
Machine learning   session4(linear regression)Machine learning   session4(linear regression)
Machine learning session4(linear regression)Abhimanyu Dwivedi
3.3K visualizações13 slides
Logistic Regression Analysis por
Logistic Regression AnalysisLogistic Regression Analysis
Logistic Regression AnalysisCOSTARCH Analytical Consulting (P) Ltd.
17.5K visualizações15 slides
Machine Learning-Linear regression por
Machine Learning-Linear regressionMachine Learning-Linear regression
Machine Learning-Linear regressionkishanthkumaar
3.3K visualizações10 slides
Linear regression theory por
Linear regression theoryLinear regression theory
Linear regression theorySaurav Mukherjee
7.1K visualizações36 slides
Support Vector Machines por
Support Vector MachinesSupport Vector Machines
Support Vector Machinesnextlib
19.9K visualizações56 slides

Mais conteúdo relacionado

Mais procurados

Principal Component Analysis por
Principal Component AnalysisPrincipal Component Analysis
Principal Component AnalysisRicardo Wendell Rodrigues da Silveira
29.8K visualizações23 slides
PCA (Principal component analysis) por
PCA (Principal component analysis)PCA (Principal component analysis)
PCA (Principal component analysis)Learnbay Datascience
466 visualizações28 slides
Ml3 logistic regression-and_classification_error_metrics por
Ml3 logistic regression-and_classification_error_metricsMl3 logistic regression-and_classification_error_metrics
Ml3 logistic regression-and_classification_error_metricsankit_ppt
311 visualizações54 slides
Logistic regression por
Logistic regressionLogistic regression
Logistic regressionKhaled Abd Elaziz
5.4K visualizações20 slides
Principal Component Analysis (PCA) and LDA PPT Slides por
Principal Component Analysis (PCA) and LDA PPT SlidesPrincipal Component Analysis (PCA) and LDA PPT Slides
Principal Component Analysis (PCA) and LDA PPT SlidesAbhishekKumar4995
2.8K visualizações15 slides
Logistic regression with SPSS por
Logistic regression with SPSSLogistic regression with SPSS
Logistic regression with SPSSLNIPE
2K visualizações34 slides

Mais procurados(20)

PCA (Principal component analysis) por Learnbay Datascience
PCA (Principal component analysis)PCA (Principal component analysis)
PCA (Principal component analysis)
Learnbay Datascience466 visualizações
Ml3 logistic regression-and_classification_error_metrics por ankit_ppt
Ml3 logistic regression-and_classification_error_metricsMl3 logistic regression-and_classification_error_metrics
Ml3 logistic regression-and_classification_error_metrics
ankit_ppt311 visualizações
Logistic regression por Khaled Abd Elaziz
Logistic regressionLogistic regression
Logistic regression
Khaled Abd Elaziz5.4K visualizações
Principal Component Analysis (PCA) and LDA PPT Slides por AbhishekKumar4995
Principal Component Analysis (PCA) and LDA PPT SlidesPrincipal Component Analysis (PCA) and LDA PPT Slides
Principal Component Analysis (PCA) and LDA PPT Slides
AbhishekKumar49952.8K visualizações
Logistic regression with SPSS por LNIPE
Logistic regression with SPSSLogistic regression with SPSS
Logistic regression with SPSS
LNIPE2K visualizações
Logistic regression por DrZahid Khan
Logistic regressionLogistic regression
Logistic regression
DrZahid Khan5.8K visualizações
3.7 outlier analysis por Krish_ver2
3.7 outlier analysis3.7 outlier analysis
3.7 outlier analysis
Krish_ver214.9K visualizações
Autoencoders por CloudxLab
AutoencodersAutoencoders
Autoencoders
CloudxLab4.9K visualizações
Logistic regression in Machine Learning por Kuppusamy P
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine Learning
Kuppusamy P974 visualizações
Linear Regression Analysis | Linear Regression in Python | Machine Learning A... por Simplilearn
Linear Regression Analysis | Linear Regression in Python | Machine Learning A...Linear Regression Analysis | Linear Regression in Python | Machine Learning A...
Linear Regression Analysis | Linear Regression in Python | Machine Learning A...
Simplilearn6.6K visualizações
ML - Simple Linear Regression por Andrew Ferlitsch
ML - Simple Linear RegressionML - Simple Linear Regression
ML - Simple Linear Regression
Andrew Ferlitsch3.1K visualizações
Principal component analysis and lda por Suresh Pokharel
Principal component analysis and ldaPrincipal component analysis and lda
Principal component analysis and lda
Suresh Pokharel3.3K visualizações
Bias and variance trade off por VARUN KUMAR
Bias and variance trade offBias and variance trade off
Bias and variance trade off
VARUN KUMAR712 visualizações
Outlier analysis and anomaly detection por ShantanuDeosthale
Outlier analysis and anomaly detectionOutlier analysis and anomaly detection
Outlier analysis and anomaly detection
ShantanuDeosthale2.1K visualizações
Linear Regression Algorithm | Linear Regression in Python | Machine Learning ... por Edureka!
Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...
Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...
Edureka!4.3K visualizações
CART – Classification & Regression Trees por Hemant Chetwani
CART – Classification & Regression TreesCART – Classification & Regression Trees
CART – Classification & Regression Trees
Hemant Chetwani6.5K visualizações
Multiple Linear Regression por Vamshi krishna Guptha
Multiple Linear Regression Multiple Linear Regression
Multiple Linear Regression
Vamshi krishna Guptha2.7K visualizações
Lasso and ridge regression por SreerajVA
Lasso and ridge regressionLasso and ridge regression
Lasso and ridge regression
SreerajVA831 visualizações
Multiple linear regression por James Neill
Multiple linear regressionMultiple linear regression
Multiple linear regression
James Neill69.6K visualizações

Similar a ML - Multiple Linear Regression

Presentation on machine learning por
Presentation on machine learningPresentation on machine learning
Presentation on machine learningJawaharlal Nehru Centre for Advanced Scientific Research
91 visualizações14 slides
Recommender Systems por
Recommender SystemsRecommender Systems
Recommender SystemsJoão Paulo Leonidas Fernandes Dias da Silva
213 visualizações20 slides
机器学习Adaboost por
机器学习Adaboost机器学习Adaboost
机器学习AdaboostShocky1
50 visualizações46 slides
Linear regression without tears por
Linear regression without tearsLinear regression without tears
Linear regression without tearsAnkit Sharma
14.6K visualizações43 slides
Regression: A skin-deep dive por
Regression: A skin-deep diveRegression: A skin-deep dive
Regression: A skin-deep diveabulyomon
319 visualizações23 slides
Linear Regression.pptx por
Linear Regression.pptxLinear Regression.pptx
Linear Regression.pptxRamakrishna Reddy Bijjam
115 visualizações21 slides

Similar a ML - Multiple Linear Regression(20)

机器学习Adaboost por Shocky1
机器学习Adaboost机器学习Adaboost
机器学习Adaboost
Shocky150 visualizações
Linear regression without tears por Ankit Sharma
Linear regression without tearsLinear regression without tears
Linear regression without tears
Ankit Sharma14.6K visualizações
Regression: A skin-deep dive por abulyomon
Regression: A skin-deep diveRegression: A skin-deep dive
Regression: A skin-deep dive
abulyomon319 visualizações
Machine learning pt.1: Artificial Neural Networks ® All Rights Reserved por Jonathan Mitchell
Machine learning pt.1: Artificial Neural Networks ® All Rights ReservedMachine learning pt.1: Artificial Neural Networks ® All Rights Reserved
Machine learning pt.1: Artificial Neural Networks ® All Rights Reserved
Jonathan Mitchell2.7K visualizações
Data Handling.pdf por MILANOP1
Data Handling.pdfData Handling.pdf
Data Handling.pdf
MILANOP18 visualizações
Tutorial on convolutional neural networks por Hojin Yang
Tutorial on convolutional neural networksTutorial on convolutional neural networks
Tutorial on convolutional neural networks
Hojin Yang705 visualizações
Unit-1 Introduction and Mathematical Preliminaries.pptx por avinashBajpayee1
Unit-1 Introduction and Mathematical Preliminaries.pptxUnit-1 Introduction and Mathematical Preliminaries.pptx
Unit-1 Introduction and Mathematical Preliminaries.pptx
avinashBajpayee197 visualizações
Regression por ramyaranjith
RegressionRegression
Regression
ramyaranjith31 visualizações
machine learning.pptx por AbdusSadik
machine learning.pptxmachine learning.pptx
machine learning.pptx
AbdusSadik3 visualizações
Matlab solved problems por Make Mannan
Matlab solved problemsMatlab solved problems
Matlab solved problems
Make Mannan17.2K visualizações
ppt - Deep Learning From Scratch.pdf por surefooted
ppt - Deep Learning From Scratch.pdfppt - Deep Learning From Scratch.pdf
ppt - Deep Learning From Scratch.pdf
surefooted8 visualizações
Session 4 .pdf por ssuser8cda84
Session 4 .pdfSession 4 .pdf
Session 4 .pdf
ssuser8cda8410 visualizações
Machine learning por Shreyas G S
Machine learningMachine learning
Machine learning
Shreyas G S2.6K visualizações
Introduction to Image Processing por Israel Gbati
Introduction to Image ProcessingIntroduction to Image Processing
Introduction to Image Processing
Israel Gbati186 visualizações

Mais de Andrew Ferlitsch

AI - Intelligent Agents por
AI - Intelligent AgentsAI - Intelligent Agents
AI - Intelligent AgentsAndrew Ferlitsch
4.6K visualizações13 slides
Pareto Principle Applied to QA por
Pareto Principle Applied to QAPareto Principle Applied to QA
Pareto Principle Applied to QAAndrew Ferlitsch
1.6K visualizações29 slides
Whiteboarding Coding Challenges in Python por
Whiteboarding Coding Challenges in PythonWhiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in PythonAndrew Ferlitsch
1.6K visualizações89 slides
Object Oriented Programming Principles por
Object Oriented Programming PrinciplesObject Oriented Programming Principles
Object Oriented Programming PrinciplesAndrew Ferlitsch
1.6K visualizações8 slides
Python - OOP Programming por
Python - OOP ProgrammingPython - OOP Programming
Python - OOP ProgrammingAndrew Ferlitsch
1K visualizações9 slides
Python - Installing and Using Python and Jupyter Notepad por
Python - Installing and Using Python and Jupyter NotepadPython - Installing and Using Python and Jupyter Notepad
Python - Installing and Using Python and Jupyter NotepadAndrew Ferlitsch
352 visualizações6 slides

Mais de Andrew Ferlitsch(20)

AI - Intelligent Agents por Andrew Ferlitsch
AI - Intelligent AgentsAI - Intelligent Agents
AI - Intelligent Agents
Andrew Ferlitsch4.6K visualizações
Pareto Principle Applied to QA por Andrew Ferlitsch
Pareto Principle Applied to QAPareto Principle Applied to QA
Pareto Principle Applied to QA
Andrew Ferlitsch1.6K visualizações
Whiteboarding Coding Challenges in Python por Andrew Ferlitsch
Whiteboarding Coding Challenges in PythonWhiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in Python
Andrew Ferlitsch1.6K visualizações
Object Oriented Programming Principles por Andrew Ferlitsch
Object Oriented Programming PrinciplesObject Oriented Programming Principles
Object Oriented Programming Principles
Andrew Ferlitsch1.6K visualizações
Python - OOP Programming por Andrew Ferlitsch
Python - OOP ProgrammingPython - OOP Programming
Python - OOP Programming
Andrew Ferlitsch1K visualizações
Python - Installing and Using Python and Jupyter Notepad por Andrew Ferlitsch
Python - Installing and Using Python and Jupyter NotepadPython - Installing and Using Python and Jupyter Notepad
Python - Installing and Using Python and Jupyter Notepad
Andrew Ferlitsch352 visualizações
Natural Language Processing - Groupings (Associations) Generation por Andrew Ferlitsch
Natural Language Processing - Groupings (Associations) GenerationNatural Language Processing - Groupings (Associations) Generation
Natural Language Processing - Groupings (Associations) Generation
Andrew Ferlitsch235 visualizações
Natural Language Provessing - Handling Narrarive Fields in Datasets for Class... por Andrew Ferlitsch
Natural Language Provessing - Handling Narrarive Fields in Datasets for Class...Natural Language Provessing - Handling Narrarive Fields in Datasets for Class...
Natural Language Provessing - Handling Narrarive Fields in Datasets for Class...
Andrew Ferlitsch223 visualizações
Machine Learning - Introduction to Recurrent Neural Networks por Andrew Ferlitsch
Machine Learning - Introduction to Recurrent Neural NetworksMachine Learning - Introduction to Recurrent Neural Networks
Machine Learning - Introduction to Recurrent Neural Networks
Andrew Ferlitsch371 visualizações
Machine Learning - Introduction to Convolutional Neural Networks por Andrew Ferlitsch
Machine Learning - Introduction to Convolutional Neural NetworksMachine Learning - Introduction to Convolutional Neural Networks
Machine Learning - Introduction to Convolutional Neural Networks
Andrew Ferlitsch1.4K visualizações
Machine Learning - Introduction to Neural Networks por Andrew Ferlitsch
Machine Learning - Introduction to Neural NetworksMachine Learning - Introduction to Neural Networks
Machine Learning - Introduction to Neural Networks
Andrew Ferlitsch270 visualizações
Python - Numpy/Pandas/Matplot Machine Learning Libraries por Andrew Ferlitsch
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Andrew Ferlitsch3.5K visualizações
Machine Learning - Accuracy and Confusion Matrix por Andrew Ferlitsch
Machine Learning - Accuracy and Confusion MatrixMachine Learning - Accuracy and Confusion Matrix
Machine Learning - Accuracy and Confusion Matrix
Andrew Ferlitsch3.3K visualizações
Machine Learning - Ensemble Methods por Andrew Ferlitsch
Machine Learning - Ensemble MethodsMachine Learning - Ensemble Methods
Machine Learning - Ensemble Methods
Andrew Ferlitsch2.2K visualizações
Machine Learning - Dummy Variable Conversion por Andrew Ferlitsch
Machine Learning - Dummy Variable ConversionMachine Learning - Dummy Variable Conversion
Machine Learning - Dummy Variable Conversion
Andrew Ferlitsch768 visualizações
Machine Learning - Splitting Datasets por Andrew Ferlitsch
Machine Learning - Splitting DatasetsMachine Learning - Splitting Datasets
Machine Learning - Splitting Datasets
Andrew Ferlitsch4.6K visualizações
Machine Learning - Dataset Preparation por Andrew Ferlitsch
Machine Learning - Dataset PreparationMachine Learning - Dataset Preparation
Machine Learning - Dataset Preparation
Andrew Ferlitsch2K visualizações
Machine Learning - Introduction to Tensorflow por Andrew Ferlitsch
Machine Learning - Introduction to TensorflowMachine Learning - Introduction to Tensorflow
Machine Learning - Introduction to Tensorflow
Andrew Ferlitsch1.2K visualizações
Introduction to Machine Learning por Andrew Ferlitsch
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
Andrew Ferlitsch284 visualizações
AI - Introduction to Dynamic Programming por Andrew Ferlitsch
AI - Introduction to Dynamic ProgrammingAI - Introduction to Dynamic Programming
AI - Introduction to Dynamic Programming
Andrew Ferlitsch537 visualizações

Último

Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... por
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...ShapeBlue
44 visualizações13 slides
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive por
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveNetwork Automation Forum
43 visualizações35 slides
Kyo - Functional Scala 2023.pdf por
Kyo - Functional Scala 2023.pdfKyo - Functional Scala 2023.pdf
Kyo - Functional Scala 2023.pdfFlavio W. Brasil
418 visualizações92 slides
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue por
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueShapeBlue
70 visualizações7 slides
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue por
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueShapeBlue
71 visualizações20 slides
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... por
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...ShapeBlue
64 visualizações20 slides

Último(20)

Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... por ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue44 visualizações
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive por Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Network Automation Forum43 visualizações
Kyo - Functional Scala 2023.pdf por Flavio W. Brasil
Kyo - Functional Scala 2023.pdfKyo - Functional Scala 2023.pdf
Kyo - Functional Scala 2023.pdf
Flavio W. Brasil418 visualizações
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue por ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue70 visualizações
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue por ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue71 visualizações
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... por ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue64 visualizações
HTTP headers that make your website go faster - devs.gent November 2023 por Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn26 visualizações
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue por ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue31 visualizações
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... por Moses Kemibaro
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Moses Kemibaro27 visualizações
MVP and prioritization.pdf por rahuldharwal141
MVP and prioritization.pdfMVP and prioritization.pdf
MVP and prioritization.pdf
rahuldharwal14137 visualizações
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... por ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue54 visualizações
Uni Systems for Power Platform.pptx por Uni Systems S.M.S.A.
Uni Systems for Power Platform.pptxUni Systems for Power Platform.pptx
Uni Systems for Power Platform.pptx
Uni Systems S.M.S.A.58 visualizações
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... por ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue28 visualizações
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... por ShapeBlue
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
ShapeBlue40 visualizações
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue por ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue62 visualizações
Scaling Knowledge Graph Architectures with AI por Enterprise Knowledge
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AI
Enterprise Knowledge50 visualizações
Five Things You SHOULD Know About Postman por Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman38 visualizações
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue por ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue26 visualizações
Why and How CloudStack at weSystems - Stephan Bienek - weSystems por ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue81 visualizações
Data Integrity for Banking and Financial Services por Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely29 visualizações

ML - Multiple Linear Regression

  • 1. Regression Methods in Machine Learning Multiple Linear Regression Portland Data Science Group Created by Andrew Ferlitsch Community Outreach Officer July, 2017
  • 2. Multiple Linear Regression X1 (Independent Variable) Y (Dependent Variable) Hyperplane • Used to Predict a correlation between more than one independent variables and a dependent variable. e.g., Income and Age is correlated with Spending • When the data is plotted on a graph, there appears to be a hyperplane relationship. X2 (Independent Variable)
  • 3. Simple vs. Multiple Linear Regression • Simple Linear Regression – one independent variable. y = b0 + b1x1 • Multiple Linear Regression – multiple independent variables. y = b0 + b1x1 + b2x2 … + bnxn 2nd independent variable and weight (coefficient) nth independent variable and weight (coefficient)
  • 4. Feature Elimination ID Income Age Height Spending 37 18000 18 5’8” 38 75000 40 5’9” 39 27000 28 6’1” 40 24000 26 5’6” 41 45000 34 6’2” • In a dataset, we may not want to keep all the independent variables (features) in our model: • More Features = More Complex Model • If feature does not contribute to prediction, adds noise to the model. ID fields are like random numbers – do not contribute to prediction. Height not likely or very little to influence spending
  • 5. Backward Elimination • A method for identifying and removing independent variables that do not contribute enough to the model. • Steps: • Fit (Train) the model with all the independent variables. • Calculate the P-value of each independent variable. • Eliminate independent variable with highest P-value above threshold (e.g., 0.05 [5 percent]). • Repeat (re-fit) until there are no independent variables with P-value above threshold. All Variables Train Is Variable with highest P-value > Threshold DONE Eliminate the variable
  • 6. Multiple Linear Regression in Python from sklearn.linear_model import LinearRegression # sci-kit learn library for linear regression regressor = LinearRegression() # instantiate linear regression object regressor.fit(X_train, y_train) # train (fit) the model • Perform Linear Regression with all independent variables. y_pred = regressor.predict( X_test ) # y_pred is the list of predicted results • Run (Predict) the model on the test data. • Analyze (View) the predicted values (y_pred) to the actual values (y_test)
  • 7. Backward Elimination in Python import statsmodels.formula.api as sm X = np.append( arr = np.ones( (nrows,1 )).astype(int), values = X, axis = 1 ) • Prepare for Backward Elimination. • The statsmodel does not take into account the constant b0. • Need to fake it by adding a x0 = 1 independent variable for b0. Function to create column of ones Append column of ones to X Create array of one column of nrows Append ones to this array X_opt = X[:, [0, 1, 2, 3, 4] ] • Create array of optional independent variables (features) from which we will eliminate independent variables. All rows Start with all columns (i.e., 0, 1, 2 .. N)
  • 8. Backward Elimination in Python (2) ols = sm.OLS( endog = y, exog = X_opt).fit() # Create OLS object and fit the model ols.summary() # Display Statistical Metrics including P-values • Use the class Ordinary Linear Square (OLS) from stats model to train (fit) the model and get P-values. Independent Variables Dependent Variable (Label) • Example elimination of an independent variable (x2). X_opt = X[:, [0,1,3,4,5]] ols = sm.OLS( endog = y, exog = X_opt).fit() ols.summary() Eliminate x2 (2), where 0 is x0 (constant) • Repeat elimination until independent variable with highest P-value is not greater than the threshold (e.g., 0.05).