# Linear Regression in Python

Linear Regression is a machine learning algorithm based on supervised learning. Linear Regression is a predictive model that is used for finding the linear relationship between a dependent variable and one or more independent variables. Here,dependent variable/target variable(Y) should be continuous variable.

Let’s learn the math behind simple linear regression and the Python way of implementation using ski-kit learn

## Dataset

Let’s looks at our dataset first. I have taken a simple dataset for an easy explanation.` Years of Experience vs Salary`.

We want to predict the salary of the person based on their years of experience?

# Math Behind the Simple Linear Regression

Dataset

In the given dataset, we have Exp vs Salary. Now, we want to predict the salary for 3.5 years of experience? Let’s see how to predict that? …

# Importing Packages in Python

## Importing Packages in Python

Packages are a way of structuring Python’s module namespace by using “dotted module names”.

Refer to my story for importing modules in python.

For example, the module name `A.B` designates a submodule named `B` in a package named `A`

I have created the following packages and sub-packages. Let’s see how to import these packages.

I have created a package` calc`

I have created a sub-package` mathcalc`

I have created files addition.py,subtract.py under `mathcalc` subpackage.

All packages and subpackages have` init.py`.It …

# Merging Dictionaries in Python 3.9 Using the Union Operator

In Python 3.9, merge `|` and update `|=` operators have been added to the built-in `dict` class.

Let’s explore different ways to merge dictionaries before and after Python 3.9.

# Different Ways to Merge Dictionaries Before Python 3.9

## 1.dict.update()

`d1.update(d2)` Update the dictionary `d1` with the key/value pairs from `d2`, overwriting existing keys. Return `None`.

`d1={'a':1,'b':2}d2={'c':3,'b':9999}d1.update(d2)print (d1)#Output:{'a': 1, 'b': 9999, 'c': 3}`

Limitations

`d1.update(d2)` will modify the original dictionary `d1`. If the original dictionary need not be modified, create a copy of dictionary `d1` and then update it.

`d1={'a':1,'b':2}d2={'c':3,'b':9999}from copy import copyd3=copy(d1)d3.update(d2)print (d3)#Output:{'a': 1, 'b': 9999, 'c': 3}`

## 2. Dictionary unpacking {**d1,**d2}

`d3={**d1,**d2}`

A double asterisk `**` denotes dictionary unpacking. … 