# AI in a nutshell

Neurons are computatonals Units of Cognition.

They are inspired by biological Neurons like the ones in the Human brain.

The human brain tries to learn prototypes of classes and learn the class mean, analogusly in a computer

## Protoypes are how the human brain learns and are very closely related to linear classification.

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqva2M9wdSuDCd9GQM%2Fimage.png?alt=media\&token=901f0f37-9f7b-4fb8-8723-95abca552041)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqviC3M1RezKiTNxg3%2Fimage.png?alt=media\&token=31ca0a3d-7de2-4c8c-a528-3c7cfcebf3cc)

Prototypes can be interpreted as means .

![](blob:https://legacy.gitbook.com/d853e3cf-057b-42bc-a4b4-9c5d18e9d1cf)![](blob:https://legacy.gitbook.com/b05739a4-e76b-4efc-b0a5-ca2e8bd72e36)Buid a classification boundary with a line.

#### This method is often also called the Nearest Centroid Classifier

#### \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

## Another Method for linear classification, the Perceptron

**It is more advanced and better than the Protypes Method, because it uses a learning rate and a Error Function to learn.**

Algo Overview:

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqvmBjy8Lc3YmzGjqb%2Fimage.png?alt=media\&token=1d0e9660-497f-46d8-9ed5-8c5c09c7e4e6)

**The Actual Algo:**

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqvpTH0zSBxqQWCxC0%2Fimage.png?alt=media\&token=eb5a231b-545a-4bb6-bc09-29a2a7722e49)

![](blob:https://legacy.gitbook.com/4a5086dd-5c45-4a96-b805-8a08bbed9e2c)

What makes this so Powerful, is :

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqvrDYEKz5nX1StKFv%2Fimage.png?alt=media\&token=1d868583-0b53-43a6-a8a7-d14871b78bfc)

![](blob:https://legacy.gitbook.com/fd83a322-7908-4ec5-8e5b-44a496843dee)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqvsIWtXihfKKFQLEI%2Fimage.png?alt=media\&token=bdaa990e-4e24-425d-a200-09b27ac1b24a)

## Problems with the Nearest Centroid Classification

## ![](blob:https://legacy.gitbook.com/7cffe219-97ff-4ce0-bfe7-e2d766fcac62)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqvuVTQnvur7YC2FFA%2Fimage.png?alt=media\&token=c9c8a090-dfb5-4f56-b9f4-9409be4a66a4)

## Since NNC is a linear classifier , it is bound to have Problems with non linear Data and correlted data .

#### Correlated Data makes prediction more difficult , however, we have a tool called LDA for dealing with the corrolation and decorrolate Data.

**Applications : Handwritten Digit Recogition, Classification, Automatic character recognition**

## Supervised Linear Classification with Fisher's LDA

**Kinda like PCA, but it focuses on maximizing the class seperability among known categories**

LDA Creates a new Axis and maps the data to the new Axis, while minimizing Between class variance-> by maximizing **mean Distance** between both classes and minimize in class vriance

## Decorrolate corrolated data and measure Class seperability.![](blob:https://legacy.gitbook.com/ede3287a-4800-42e2-a5da-6e46e45e0ec6)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqvzK1UzMe51SJg1ZV%2Fimage.png?alt=media\&token=9c9d356d-075d-4f9e-99ea-650bc44e2745)

## ![](blob:https://legacy.gitbook.com/6ae5ea99-5f0d-4b26-85b8-9dbe929099f9)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqw2viBfcTNkILQBvv%2Fimage.png?alt=media\&token=ba6a6b82-22e3-4f00-ae55-1d219dc40745)

**We Do this by maximizing the Fisiher Criterion and setting the derivative to 0!.**

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqw9ums9K526XluwMt%2Fimage.png?alt=media\&token=391ca657-2da3-4944-a6b1-c8313a3b0db6)

**If we Compare NNC and LDA on the same Dataset, we can see that LDA seperates the Classes better than NNC.**

**LDA Maximizes the difference Between the classes**

**LDA Minizies the differen INSIDE the classes!**

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwBcqju0l71TytI4v%2Fimage.png?alt=media\&token=bd26f3ce-8d37-4389-9824-7bf46eb161ef)

## Lda first decorrolates the data and then uses ne Nearest Centroid classification method.

**LDA Algo:**

Applications : Brain Computer Interface,

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwEThCKceAXNDPcSg%2Fimage.png?alt=media\&token=ae3b4b2d-67e1-4c7a-9d51-b6f3fc79243a)

##

If data is Guassion with equal class covariances, then LDA is the optimal classifier.

#### Cross Validation

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwJQCuLw4L36wD3PM%2Fimage.png?alt=media\&token=ea2ff2fe-7950-47e8-a16c-7fd672049436)

Cross Validation is a method of measuring the performance of an Classification Algorithm. Instead of using the whole dataset, we train the data only on one part of the data. Then we train the model on another disjunkt part of the data.

Repeat this process on different folds(disjunkt Sets) and calculate the average of the performance on those disjunkt folds.

**Cross Validation Algo** 

## Regression

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwTXcH0k-deQSqzND%2Fimage.png?alt=media\&token=5a1f43e0-95ab-4730-91e6-9e332331db0a)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwaGFY1T-5ZNOrmSL%2Fimage.png?alt=media\&token=bd3c2552-c4cc-435d-9881-1731c78f831c)

#### Example of the most simple form of Linear Regression, Least Square Error, OLS

#### ![](blob:https://legacy.gitbook.com/ac29cb5b-09c9-48c1-9f50-49cd82e40739)

Applications of Ridge Regression: Stock Predictiom based on basis of company performance measures and economic data, predict crop production from weather variables, control robotic arm with electric activity measued on the arm,

#### Comparision of Supervised Algorithmns![](blob:https://legacy.gitbook.com/3566df9b-64bf-46af-bc30-8371ece7ea9f)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwcGnun2o5cTLCuYW%2Fimage.png?alt=media\&token=7d756971-1d97-4c6b-b4c5-01c1563da11d)

### Ridge Regression,

Regression for Datapoints in finite Label Space( Regression had Infinite possible Labes, now its Limited Again by a certain amount of classes that can be predicted)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwekuicVstLfy0XT_%2Fimage.png?alt=media\&token=696ccecb-800b-492d-a4f8-5156801af35c)

![](blob:https://legacy.gitbook.com/d0b3c2d3-44d0-4e01-9457-1ddc5f8a80e9)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwgd8LWHf3vgf6bMf%2Fimage.png?alt=media\&token=6cf63956-8256-4ba2-8d30-41ddb86066fc)

![](blob:https://legacy.gitbook.com/c4197611-88ba-4fda-af14-09408154b685)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwiJCxmbiEy5f-bN0%2Fimage.png?alt=media\&token=d9b80694-bf3b-4332-9cbb-0b94fa204f83)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwksLPyJo4cEwLCrI%2Fimage.png?alt=media\&token=fc7a1609-bfc9-4da8-9cf1-9fc12861276d)

### ![](blob:https://legacy.gitbook.com/75ad9236-b975-4fb7-b264-9eff8d9e5ade)&#x20;

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwpFaQ2icM6e3-VdB%2Fimage.png?alt=media\&token=0f06f056-bce0-4a3b-bc90-8b909076dec2)

### Linear Regression is a generic framework for prediction straightforwardly extends to vector labels can model nonlinear dependencies between data and labels can be made more robust (Ridge Regression)

Applications : Myoelectric Control of Prostheses, Mind Controlled Robot Arms!

## Kernel Methods

## A trick for classifying linear non seperatable Data.

#### Calculations are done in a higher dimensional Space. Take data and project it to higher dimensional space, then compare it in this space (look for linear relationships) and use this knowledge to classify data . The Kernel is a measurement for the similarity of the data

### Non linear Problems become linear in Kernel space

### Popular Kernel Methods are the Linear Kernel, Polynomial Kernel and the Gaussian Kernel.

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwtYJstOvUKHfo3YJ%2Fimage.png?alt=media\&token=c8a3a491-e868-4001-8d44-da41d07da3d8)

![](blob:https://legacy.gitbook.com/11a50c8e-7442-4bff-b611-8b997195b836)![](blob:https://legacy.gitbook.com/7deaa226-3c6d-45c9-9e55-9aae4f162528)![](blob:https://legacy.gitbook.com/5a3a5fa7-65fe-4d34-91e5-7175af0b6053)![](blob:https://legacy.gitbook.com/4b5b9818-aef3-42a1-adcf-b3b64aeb26e0)![](blob:https://legacy.gitbook.com/e38d7a2c-d39f-47ba-86f0-95fa6c2bb18e)![](blob:https://legacy.gitbook.com/3b6b00f6-3719-4c77-ace7-c769dee68323)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwwKCPYobZfcLH0le%2Fimage.png?alt=media\&token=e0050b13-e6f1-4476-bf1a-700951b797cd)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqwzwTTGAjJxzO7SJQ%2Fimage.png?alt=media\&token=78f333fd-dc17-4f4c-aabf-772c8669a23f)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqx0f5SyLj_3wSk5qV%2Fimage.png?alt=media\&token=43e18efc-bdd0-46d8-b388-64fb46c6c1f9)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqx2C-WVlxLrOguUKX%2Fimage.png?alt=media\&token=58c0cf68-dfc9-4dd0-b580-3b810f042da5)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqx4opAaWxTsr5FVlM%2Fimage.png?alt=media\&token=f748d937-b3fc-4ef3-8800-7c7d211547ae)

## Neural Networks - *Multilayer Neural Networks*

**Example of an One layer Network**

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqx8Wf_JIVUVLots97%2Fimage.png?alt=media\&token=9682a6ee-ad7e-438d-9491-badb88820a17)

As you can see, it only has 1 Layer of Input Nods, x1-x4, which all go into 1 Evaluation/Activation function which generates Label Y.

One-Layerd Neural Networks are**not powerful enough to solve non linear Problems,**&#x6C;ike :

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqxAmbt_lMNY1_g8Vr%2Fimage.png?alt=media\&token=9bba57cf-6146-447d-92d1-1fd7c0b3238c)

![](blob:https://legacy.gitbook.com/f2b5df3c-ab66-4cba-9b78-f40767978d03)

Solution to Label non Linear Problems/Data?

## Multilayer Netwroks!![](blob:https://legacy.gitbook.com/ffbc265d-657d-4dac-94b2-dc54d3addb48)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqxNqTEaAPV5gbNCwl%2Fimage.png?alt=media\&token=2d10da1f-3daf-4078-88bb-ebf1d29ba34a)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqxR5DkbBdVQyR_Fps%2Fimage.png?alt=media\&token=38b7382e-4f4b-450e-91f7-73394b4fa750)

## Unsupervised Learning :

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqxKG1xund3-jvHsiZ%2Fimage.png?alt=media\&token=8ac07d1a-832a-471d-a3ee-6bf78f6cfcf6)

## ![](blob:https://legacy.gitbook.com/a8ad391e-1ac7-4ef7-a271-c4a505272437)

"Normal" neural Networks usually have one or two hidden layers and are used for **supervised** learning.

### **Deep Learning**

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqxTAd5x4CI-GRJtGA%2Fimage.png?alt=media\&token=76446f1c-d070-48e3-bef5-4a92cde9faa6)

![](blob:https://legacy.gitbook.com/456181e6-e8f5-4658-90d6-28c76b1bc9a5)

neural network architectures differ from " normal " nueral networks because they have more **hidden layers .** One special difference is that deep learning Algorithmns can work **Supervised** or **Unsupervised** .

Deep Learning differe from "normal" neural networks, in that they have multiple **HIDDEN** layerrs and are used for Un

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqxY5z-MEacn2D8i56%2Fimage.png?alt=media\&token=773575c7-8a9a-4236-9a7c-30fe4275aabf)

![](blob:https://legacy.gitbook.com/255efd8f-1393-4c4f-8b99-fa3bb7fa37f0)

Application Conv Nets : Style Transfer, Manifold Transfer (Faceswap) ,

Application of Recurrent Neural Networks \_ Generating Images and sound, generate Text, generate a picture from text , Force Estimation for Robitic Operation OP Arms, Visual Question Answering

Genaral Adversarial Networks (GANS ) applications : Super Resolution, image post processing, image generation,

Deep Reinforcement Learning Applications : Video Game Playing Ai'S (GO, Doom Bot, Atari Bot),

## Unsupervised Learning Methods

### Priniple Component Analysis PCA

**can be used for maximizing variance in Data, but also for Dimensionality reduction or finding a fitting line for the data**

**When dimensionality of data is too high to visualize it in 3 Dimensional space, we can reduce dimensions by using PCA**

**The variance between the data will be maximized, by projecting the data in another lover dimensional space.**

#### PCA for Maximizing Variance

PCA can be defined as the orthogonal projection of the data onto a lower Dimensional linear space, known as the pricipal subspace. The projection must be in a way, such that the variance of the projhected data is maximized.

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqxcxndTPpLoOFYnN_%2Fimage.png?alt=media\&token=a5a1921d-071d-47ef-8450-c0ba1217033b)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqxflbGQxVrWVyqtv_%2Fimage.png?alt=media\&token=facedcdc-2e1e-4001-877d-89b0cbf23e8c)

Es wird in die Daten die Linie einzezeichnet, die die Maximale Varianz zu den Daten hat.

#### ![](blob:https://legacy.gitbook.com/513b8e80-b7fa-409c-9e13-03320202e791)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqxicNv018BFa7bcH-%2Fimage.png?alt=media\&token=5ab84b5f-0152-4ebd-9c42-e85299141c94)

### ![](blob:https://legacy.gitbook.com/722fabd9-6c12-42cd-9381-53645f023a8e)

### Non Negative Matrix Factorization- NMF

**For some uses Cases PCA does not make since, for example for data with non-negative (only positive data)**

**PCA fails data sets that are strictly positive , like Text data, Image Data, Probabiistic data**

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqxmkVy5awCPTcQBeQ%2Fimage.png?alt=media\&token=5e523359-0cbf-40db-8557-880cc01dbf81)

![](blob:https://legacy.gitbook.com/da528cfb-b202-4aef-a5b4-2e2a49d11b33)

Applications: Face Recognition, news learning from bag of words

### Clustering

#### Kinda the same like NCC , but with multiple classes!

#### ![](blob:https://legacy.gitbook.com/0754a15b-cd89-487b-a262-4e3e0ac5cc64)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqxoFTJB4oAs5iFe6Y%2Fimage.png?alt=media\&token=616db0cf-7671-4df5-93f4-c464ad918cbd)

![](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LDquuvCh5m5WkHt-4e4%2F-LDqxqBZLyH-tqFyDne_%2Fimage.png?alt=media\&token=4bb6d465-fab1-4dae-8c23-3ff236616de7)

![](blob:https://legacy.gitbook.com/92ba5046-6ae7-45fd-8f1d-c6fc294b077e)

How to Choose Hyperparameter K ? Choose K with least instable Clusterings! in supervised scenarios we could use cross-validation to optimize hyper-parameters, now we cant, magic number tryout!.

Applications : Pulse Code Modulation, Geyser Eruptions,

## <br>
