This document discusses different types of linear regression models including simple, multiple, and polynomial linear regression. It provides code examples for implementing linear regression using scikit-learn and statsmodels. Key steps covered include importing packages, providing data, creating and fitting regression models, obtaining results like coefficients and metrics, making predictions on new data, and visualizing models. Types of linear regression covered are simple linear regression with one variable, multiple linear regression with two or more variables, and polynomial regression with higher degree polynomials.
Lecture on 11 December 2018
Cryptography
Steganography
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 18 December 2018
Role of Cryptography in Blockchain
RSA and SHA
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 11 December 2018
Cryptography
Steganography
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 18 December 2018
Role of Cryptography in Blockchain
RSA and SHA
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 29 January 2019
Consensus Algorithms
Nakamoto Consensus
Federated Consensus
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 15 January 2019
Role of Cryptography in Blockchain
RSA and SHA
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 13 November 2018
Introduction to Blockchain
History of Blockchain
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 20 November 2018
Blockchain Terminologies
Types of Blockchain
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 4 December 2018
Hyperledger
Smart Contracts
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 22 January 2019
CAP Theorem
Byzantines General Problem
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 27 November 2018
FinTech
Cryptocurrencies
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Best Python Libraries For Data Science & Machine Learning | EdurekaEdureka!
YouTube Link: https://youtu.be/LepMvJdr2-w
** Machine Learning Engineer Masters Program: https://www.edureka.co/masters-program/machine-learning-engineer-training **
This Edureka session will focus on the top Python libraries that you should know to master Data Science and Machine Learning. Here’s a list of topics that are covered in this session:
Introduction To Data Science And Machine Learning
Why Use Python For Data Science And Machine Learning?
Python Libraries for Data Science And Machine Learning
Python libraries for Statistics
Python libraries for Visualization
Python libraries for Machine Learning
Python libraries for Deep Learning
Python libraries for Natural Language Processing
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Python For Data Analysis | Python Pandas Tutorial | Learn Python | Python Tra...Edureka!
This Edureka Python Pandas tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) will help you learn the basics of Pandas. It also includes a use-case, where we will analyse the data containing the percentage of unemployed youth for every country between 2010-2014. Below are the topics covered in this tutorial:
1. What is Data Analysis?
2. What is Pandas?
3. Pandas Operations
4. Use-case
Lecture on 29 January 2019
Consensus Algorithms
Nakamoto Consensus
Federated Consensus
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 15 January 2019
Role of Cryptography in Blockchain
RSA and SHA
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 13 November 2018
Introduction to Blockchain
History of Blockchain
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 20 November 2018
Blockchain Terminologies
Types of Blockchain
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 4 December 2018
Hyperledger
Smart Contracts
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 22 January 2019
CAP Theorem
Byzantines General Problem
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Lecture on 27 November 2018
FinTech
Cryptocurrencies
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Best Python Libraries For Data Science & Machine Learning | EdurekaEdureka!
YouTube Link: https://youtu.be/LepMvJdr2-w
** Machine Learning Engineer Masters Program: https://www.edureka.co/masters-program/machine-learning-engineer-training **
This Edureka session will focus on the top Python libraries that you should know to master Data Science and Machine Learning. Here’s a list of topics that are covered in this session:
Introduction To Data Science And Machine Learning
Why Use Python For Data Science And Machine Learning?
Python Libraries for Data Science And Machine Learning
Python libraries for Statistics
Python libraries for Visualization
Python libraries for Machine Learning
Python libraries for Deep Learning
Python libraries for Natural Language Processing
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Python For Data Analysis | Python Pandas Tutorial | Learn Python | Python Tra...Edureka!
This Edureka Python Pandas tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) will help you learn the basics of Pandas. It also includes a use-case, where we will analyse the data containing the percentage of unemployed youth for every country between 2010-2014. Below are the topics covered in this tutorial:
1. What is Data Analysis?
2. What is Pandas?
3. Pandas Operations
4. Use-case
This presentation has slides from a talk that I gave at the annual Experimental Biology meeting, 2015, on our curriculum for Big Data Analytics in the Inland Empire.
Accelerating the Pace of Engineering Education with Simulation, Hardware and ...Joachim Schlosser
Presentation for MathWorks (www.mathworks.com) at World Engineering Education Forum 2014, Dubai.
Education is challenging. It always was challenging, and it always will be challenging, but every generation of educators and society has to find answers specific to their era. This talk addresses some of the challenges in engineering education in the 21st century.
Industry complains about the skills gap they face with graduates in engineering, for lack of project awareness, problem solving skills, applicable tool skills or applied science skills. Academia complains about students not bringing the necessary basic skills as engineering freshmen. Teachers complain about a lack of student engagement. Students complain about classes not engaging them and seeming irrelevant.
When putting this chain of challenges – industry, academia, school, students – on its head and starting with the student engagement, one method getting attention is Project-Based Learning. Students educate themselves on concepts they need, with the teacher facilitating the learning experience. Applying theory in practical ways with tools that are used in industry gives students first-hand experience on industry relevant methods as well as the why behind theory. The talk shows examples of programming, modeling and simulation to gain insight into theory and application.
Too often students and educators feel that topics throughout their education are not connected. Early on they lack understanding of the why they are learning something. Later they no longer see the connection of advanced theory to fundamental concepts. Reusing learning artifacts, skills and methods helps mapping out the story. Demonstrations illustrate how educators implement this re-use throughout teaching.
Consequent reuse leads to Integrated Curriculum, where methods and skills in each year build on previous ones. Evaluations in integrated curriculum enabled programs show a higher retention of know-how.
We all can make math, physics and engineering able to experience using simulation and hardware experiments. The tools and resources are there. Let's address our generation's engineering education challenges.
Analysis of Educational Robotics activities using a machine learning approachLorenzo Cesaretti
These slides present the preliminary results through the utilisation of machine learning techniques for the analysis of Educational Robotics activities. An experimentation with 197 secondary school students from Italy was con-ducted, through updating Lego Mindstorms EV3 programming blocks in order to record log files containing the coding sequences designed by the students (within team work), during the resolution of a preliminary Robotics’ exercise. We utilised four machine learning techniques (logistic regression, support vec-tor machine, K-nearest neighbors and random forests) to predict the students’ performance, comparing a supervised approach (using twelve indicators ex-tracted from the log files as input for the algorithms) and a mixed approach (ap-plying a k-means algorithm to calculate the machine learning features). The re-sults have highlighted that SVM with the mixed approach outperformed the other techniques, and that three learning styles were predominantly emerged from the data mining analysis.
This presentation discusses the following topics:
DBMS Architecture
Relational Algebra
Union and Differences
Selection
Projection
Cartesian Product
Renaming
Join
Limitations of Relational Algebra
Similar to Week 9: Programming for Data Analysis (20)
Adjusting primitives for graph : SHORT REPORT / NOTESSubhajit Sahu
Graph algorithms, like PageRank Compressed Sparse Row (CSR) is an adjacency-list based graph representation that is
Multiply with different modes (map)
1. Performance of sequential execution based vs OpenMP based vector multiply.
2. Comparing various launch configs for CUDA based vector multiply.
Sum with different storage types (reduce)
1. Performance of vector element sum using float vs bfloat16 as the storage type.
Sum with different modes (reduce)
1. Performance of sequential execution based vs OpenMP based vector element sum.
2. Performance of memcpy vs in-place based CUDA based vector element sum.
3. Comparing various launch configs for CUDA based vector element sum (memcpy).
4. Comparing various launch configs for CUDA based vector element sum (in-place).
Sum with in-place strategies of CUDA mode (reduce)
1. Comparing various launch configs for CUDA based vector element sum (in-place).
As Europe's leading economic powerhouse and the fourth-largest hashtag#economy globally, Germany stands at the forefront of innovation and industrial might. Renowned for its precision engineering and high-tech sectors, Germany's economic structure is heavily supported by a robust service industry, accounting for approximately 68% of its GDP. This economic clout and strategic geopolitical stance position Germany as a focal point in the global cyber threat landscape.
In the face of escalating global tensions, particularly those emanating from geopolitical disputes with nations like hashtag#Russia and hashtag#China, hashtag#Germany has witnessed a significant uptick in targeted cyber operations. Our analysis indicates a marked increase in hashtag#cyberattack sophistication aimed at critical infrastructure and key industrial sectors. These attacks range from ransomware campaigns to hashtag#AdvancedPersistentThreats (hashtag#APTs), threatening national security and business integrity.
🔑 Key findings include:
🔍 Increased frequency and complexity of cyber threats.
🔍 Escalation of state-sponsored and criminally motivated cyber operations.
🔍 Active dark web exchanges of malicious tools and tactics.
Our comprehensive report delves into these challenges, using a blend of open-source and proprietary data collection techniques. By monitoring activity on critical networks and analyzing attack patterns, our team provides a detailed overview of the threats facing German entities.
This report aims to equip stakeholders across public and private sectors with the knowledge to enhance their defensive strategies, reduce exposure to cyber risks, and reinforce Germany's resilience against cyber threats.
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...John Andrews
SlideShare Description for "Chatty Kathy - UNC Bootcamp Final Project Presentation"
Title: Chatty Kathy: Enhancing Physical Activity Among Older Adults
Description:
Discover how Chatty Kathy, an innovative project developed at the UNC Bootcamp, aims to tackle the challenge of low physical activity among older adults. Our AI-driven solution uses peer interaction to boost and sustain exercise levels, significantly improving health outcomes. This presentation covers our problem statement, the rationale behind Chatty Kathy, synthetic data and persona creation, model performance metrics, a visual demonstration of the project, and potential future developments. Join us for an insightful Q&A session to explore the potential of this groundbreaking project.
Project Team: Jay Requarth, Jana Avery, John Andrews, Dr. Dick Davis II, Nee Buntoum, Nam Yeongjin & Mat Nicholas
StarCompliance is a leading firm specializing in the recovery of stolen cryptocurrency. Our comprehensive services are designed to assist individuals and organizations in navigating the complex process of fraud reporting, investigation, and fund recovery. We combine cutting-edge technology with expert legal support to provide a robust solution for victims of crypto theft.
Our Services Include:
Reporting to Tracking Authorities:
We immediately notify all relevant centralized exchanges (CEX), decentralized exchanges (DEX), and wallet providers about the stolen cryptocurrency. This ensures that the stolen assets are flagged as scam transactions, making it impossible for the thief to use them.
Assistance with Filing Police Reports:
We guide you through the process of filing a valid police report. Our support team provides detailed instructions on which police department to contact and helps you complete the necessary paperwork within the critical 72-hour window.
Launching the Refund Process:
Our team of experienced lawyers can initiate lawsuits on your behalf and represent you in various jurisdictions around the world. They work diligently to recover your stolen funds and ensure that justice is served.
At StarCompliance, we understand the urgency and stress involved in dealing with cryptocurrency theft. Our dedicated team works quickly and efficiently to provide you with the support and expertise needed to recover your assets. Trust us to be your partner in navigating the complexities of the crypto world and safeguarding your investments.
Opendatabay - Open Data Marketplace.pptxOpendatabay
Opendatabay.com unlocks the power of data for everyone. Open Data Marketplace fosters a collaborative hub for data enthusiasts to explore, share, and contribute to a vast collection of datasets.
First ever open hub for data enthusiasts to collaborate and innovate. A platform to explore, share, and contribute to a vast collection of datasets. Through robust quality control and innovative technologies like blockchain verification, opendatabay ensures the authenticity and reliability of datasets, empowering users to make data-driven decisions with confidence. Leverage cutting-edge AI technologies to enhance the data exploration, analysis, and discovery experience.
From intelligent search and recommendations to automated data productisation and quotation, Opendatabay AI-driven features streamline the data workflow. Finding the data you need shouldn't be a complex. Opendatabay simplifies the data acquisition process with an intuitive interface and robust search tools. Effortlessly explore, discover, and access the data you need, allowing you to focus on extracting valuable insights. Opendatabay breaks new ground with a dedicated, AI-generated, synthetic datasets.
Leverage these privacy-preserving datasets for training and testing AI models without compromising sensitive information. Opendatabay prioritizes transparency by providing detailed metadata, provenance information, and usage guidelines for each dataset, ensuring users have a comprehensive understanding of the data they're working with. By leveraging a powerful combination of distributed ledger technology and rigorous third-party audits Opendatabay ensures the authenticity and reliability of every dataset. Security is at the core of Opendatabay. Marketplace implements stringent security measures, including encryption, access controls, and regular vulnerability assessments, to safeguard your data and protect your privacy.
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Subhajit Sahu
Abstract — Levelwise PageRank is an alternative method of PageRank computation which decomposes the input graph into a directed acyclic block-graph of strongly connected components, and processes them in topological order, one level at a time. This enables calculation for ranks in a distributed fashion without per-iteration communication, unlike the standard method where all vertices are processed in each iteration. It however comes with a precondition of the absence of dead ends in the input graph. Here, the native non-distributed performance of Levelwise PageRank was compared against Monolithic PageRank on a CPU as well as a GPU. To ensure a fair comparison, Monolithic PageRank was also performed on a graph where vertices were split by components. Results indicate that Levelwise PageRank is about as fast as Monolithic PageRank on the CPU, but quite a bit slower on the GPU. Slowdown on the GPU is likely caused by a large submission of small workloads, and expected to be non-issue when the computation is performed on massive graphs.
Show drafts
volume_up
Empowering the Data Analytics Ecosystem: A Laser Focus on Value
The data analytics ecosystem thrives when every component functions at its peak, unlocking the true potential of data. Here's a laser focus on key areas for an empowered ecosystem:
1. Democratize Access, Not Data:
Granular Access Controls: Provide users with self-service tools tailored to their specific needs, preventing data overload and misuse.
Data Catalogs: Implement robust data catalogs for easy discovery and understanding of available data sources.
2. Foster Collaboration with Clear Roles:
Data Mesh Architecture: Break down data silos by creating a distributed data ownership model with clear ownership and responsibilities.
Collaborative Workspaces: Utilize interactive platforms where data scientists, analysts, and domain experts can work seamlessly together.
3. Leverage Advanced Analytics Strategically:
AI-powered Automation: Automate repetitive tasks like data cleaning and feature engineering, freeing up data talent for higher-level analysis.
Right-Tool Selection: Strategically choose the most effective advanced analytics techniques (e.g., AI, ML) based on specific business problems.
4. Prioritize Data Quality with Automation:
Automated Data Validation: Implement automated data quality checks to identify and rectify errors at the source, minimizing downstream issues.
Data Lineage Tracking: Track the flow of data throughout the ecosystem, ensuring transparency and facilitating root cause analysis for errors.
5. Cultivate a Data-Driven Mindset:
Metrics-Driven Performance Management: Align KPIs and performance metrics with data-driven insights to ensure actionable decision making.
Data Storytelling Workshops: Equip stakeholders with the skills to translate complex data findings into compelling narratives that drive action.
Benefits of a Precise Ecosystem:
Sharpened Focus: Precise access and clear roles ensure everyone works with the most relevant data, maximizing efficiency.
Actionable Insights: Strategic analytics and automated quality checks lead to more reliable and actionable data insights.
Continuous Improvement: Data-driven performance management fosters a culture of learning and continuous improvement.
Sustainable Growth: Empowered by data, organizations can make informed decisions to drive sustainable growth and innovation.
By focusing on these precise actions, organizations can create an empowered data analytics ecosystem that delivers real value by driving data-driven decisions and maximizing the return on their data investment.
4. New Library needed
• Scikit Learn
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
4
5. Regression
• Regression analysis is one of the most important fields in statistics
and machine learning.
• There are many regression methods available.
• Linear regression is one of them.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
5
6. Linear Regression
• Linear regression is probably one of the most important and widely
used regression techniques.
• It’s among the simplest regression methods.
• One of its main advantages is the ease of interpreting results.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
6
7. Types of Linear Regression
• Simple Linear Regression
• Multiple Linear Regression
• Polynomial Regression
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
7
8. Simple Linear Regression
• Simple or single-variate linear regression is the simplest case of linear
regression with a single independent variable, 𝐱 = 𝑥.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
8
9. Simple Linear Regression
• It starts with a given set of input-output (𝑥-𝑦) pairs (green circles).
• These pairs are your observations.
• For example, the leftmost observation (green circle) has the input 𝑥 =
5 and the actual output (response) 𝑦 = 5.
• The next one has 𝑥 = 15 and 𝑦 = 20, and so on.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
9
10. Multiple Linear Regression
• Multiple or multivariate linear regression is a case of linear regression
with two or more independent variables.
• If there are just two independent variables, the estimated regression
function is 𝑓(𝑥₁, 𝑥₂) = 𝑏₀ + 𝑏₁𝑥₁ + 𝑏₂𝑥₂.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
10
11. Polynomial Regression
• Polynomial regression is a generalized case of linear regression.
• The simplest example of polynomial regression has a single
independent variable, and the estimated regression function is a
polynomial of degree 2: 𝑓(𝑥) = 𝑏₀ + 𝑏₁𝑥 + 𝑏₂𝑥².
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
11
12. Underfitting and Overfitting
• Underfitting occurs when a model can’t accurately capture the
dependencies among data, usually as a consequence of its own
simplicity.
• Overfitting happens when a model learns both dependencies among
data and random fluctuations.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
12
13. Underfitting
• The given plot shows a linear regression line that has a low 𝑅². It
might also be important that a straight line can’t take into account the
fact that the actual response increases as 𝑥 moves away from 25
towards zero. This is likely an example of underfitting.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
13
14. Overfitting
• The given plot presents polynomial regression with the degree equal
to 3. The value of 𝑅² is higher than in the preceding cases. This model
behaves better with known data than the previous ones.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
14
15. Well fitted
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
15
16. Linear Relationship
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
16
Positive Linear Relationship Negative Linear Relationship
17. Simple Linear Regression With scikit-learn
There are five basic steps when you’re implementing linear regression:
• Import the packages and classes you need.
• Provide data to work with and eventually do appropriate transformations.
• Create a regression model and fit it with existing data.
• Check the results of model fitting to know whether the model is
satisfactory.
• Apply the model for predictions.
• Visualize
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
17
18. Import the packages and classes you need
• The first step is to import the package numpy and the class
LinearRegression from sklearn.linear_model:
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
18
19. Provide data
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
19
20. Create a model and fit it
model = LinearRegression()
model = LinearRegression().fit(x, y)
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
20
21. Get results
• r_sq = model.score(x, y)
• print('coefficient of determination:', r_sq)
• print('intercept:', model.intercept_)
• print('slope:', model.coef_)
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
21
22. Predict Response
• y_pred = model.predict(x)
• print('predicted response:', y_pred, sep='n’)
• y_pred = model.intercept_ + model.coef_ * x
• print('predicted response:', y_pred, sep='n')
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
22
23. Predict Response
• x_new = np.arange(5).reshape((-1, 1))
• print(x_new)
• y_new = model.predict(x_new)
• print(y_new)
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
23
24. Display in a plot
import matplotlib.pyplot as plt
plt.plot(x, y, label = "actual")
plt.plot(x_new, y_new, label = "Predicted")
plt.legend()
plt.show()
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
24
25. Multiple Linear Regression
• Import packages, classes and data
• Create Model and fit it
• Get results
• Predict Response
• Visualize
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
25
26. Get Data
x = [[0, 1], [5, 1], [15, 2], [25, 5], [35, 11], [45, 15], [55, 34], [60, 35]]
y = [4, 5, 20, 14, 32, 22, 38, 43]
x, y = np.array(x), np.array(y)
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
26
27. Create Model and fit
model = LinearRegression().fit(x, y)
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
27
28. Get Results
r_sq = model.score(x, y)
print('coefficient of determination:', r_sq)
print('intercept:', model.intercept_)
print('slope:', model.coef_)
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
28
30. Polynomial Regression
• Import packages and classes
• Provide Data
• Create a model and fit it
• Get results
• Predict Response
• Visualize
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
30
31. Import packages and classes
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
31
32. Provide Data
x = np.array([5, 15, 25, 35, 45, 55]).reshape((-1, 1))
y = np.array([15, 11, 2, 8, 25, 32])
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
32
33. Transform input data
transformer = PolynomialFeatures(degree=2, include_bias=False)
transformer.fit(x)
x_ = transformer.transform(x)
x_ = PolynomialFeatures(degree=2, include_bias=False).fit_transform(x)
print(x_)
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
33
34. Create a model and fit it
model = LinearRegression().fit(x_, y)
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
34
35. Get Results
# Step 4: Get results
r_sq = model.score(x_, y)
intercept, coefficients = model.intercept_, model.coef_
# Step 5: Predict
y_pred = model.predict(x_)
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
35
36. Advanced Linear Regression using stats
models
• Import Packages
• Provide Data and Transform inputs
• Create Model and fit it
• Get Results
• Predict Response
• Visualize
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
36
38. Provide data and transform inputs
x = [[0, 1], [5, 1], [15, 2], [25, 5], [35, 11], [45, 15], [55, 34], [60, 35]]
y = [4, 5, 20, 14, 32, 22, 38, 43]
x, y = np.array(x), np.array(y)
x = sm.add_constant(x)
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
38
39. Create Model and fit it
model = sm.OLS(y, x)
results = model.fit()
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
39
40. Get Results
print(results.summary())
print('coefficient of determination:', results.rsquared)
print('adjusted coefficient of determination:', results.rsquared_adj)
print('regression coefficients:', results.params)
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
40
41. Predict Response
print('predicted response:', results.fittedvalues, sep='n')
print('predicted response:', results.predict(x), sep='n’)
x_new = sm.add_constant(np.arange(10).reshape((-1, 2)))
print(x_new)
y_new = results.predict(x_new)
print(y_new)
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
41
42. DSA 207 – Linear Regression
• Linear Regression
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
42