# Learning: Deep Learning and AI Part I

# Intro:

I’ve been meaning to publish a small introductory series for Deep Learning and AI on my blog ðŸ¤–. While I’m getting into the subject matter myself and trying to learn, some posts will record my progress and thoughts on the respective topics. To get started, this paper will focus on the use of linear regression. For this purpose, python and the scikit-learn module are used. I wish you a lot of fun!

# What are coefficients?

In mathematics, a coefficient is a multiplicative factor in some term of a polynomial, a series, or any expression; it is usually a number, but may be any expression (including variables such as a, b and c). wikipedia.org

# Where are they used?

Coefficients are used in all kinds of fields. In physics, chemistry, storastics, mathematics. I would like to restrict myself in this contribution to the physical and storastic uses. wikipedia.org

# linear regression

Linear regression is a statistical technique that attempts to explain an observed dependent variable by one or more independent variables. In linear regression, a linear model is assumed. The goal in our application is to find a coefficient. wikipedia.org

# Example 1

Our task is to find the coefficient for converting kilometers to miles. We have been given input values x (in kilometers) and corresponding output values y (in miles). These values are not very accurate. 1km = 0.621 miles

```
x = [
[10],
[15],
[30]
]
y = [
[6.2],
[9.3],
[18.6],
]
```

Now we need to import the module, create the model and train it with our inputs and outputs.

```
from sklearn.linear_model import LinearRegression
model = LinearRegression(fit_intercept = False)
model.fit(x,y)
```

In this example the coefficient is 0.62152866 which is relativly close to the real 0.621.

```
model.coef_
array([[0.62152866]])
```

If we want to calculate/“predict” an output for a new value we use

```
model.predict([
[120],
[130]
])
```

The output will be 74.58343949 and 80.7872611.

## mention

In this example we disabled the so called intercept/“bias”. We will need to use it in the next example.

# example 2

In our next task, we are to convert temperatures from degrees Celcius and degrees Fahrenheit. In this example we have to calculate with an offset also called intercept. This is because there is a constant in the conversion formula.

We have been given input values x (in ceclius) and corresponding output values y (in fahrenheit).

```
x = [
[-10],
[0],
[20]
]
y = [
[14],
[32],
[68],
]
```

Now we need to import the module, create the model and train it with our inputs and outputs again.

```
from sklearn.linear_model import LinearRegression
model = LinearRegression
model.fit(x,y)
```

We can output the coefficient and bias by:

```
print("coefficient: " + str(model.coef_))
print("bias/offset: " + str(model.intercept_))
```

The coefficient: 1.8 and bias: 32 based on our input and output values are right.

# Conclusion

By using sklearn, it is very easy to find linear relationships between input and output values.