# Machine Learning

To leverage the advancements in machine learning and more, we've added a new module to calculate the Linear Regression via machine learning. The new app ['Linear Regression'](https://www.klickanalytics.com/ml_lr). The app will use the machine learning i.e.

* The user will be able to select any global instrument e.g. Stocks, ETFS, Funds, Index, Commodities, Currency, Crypto
* Set the duration of dates
* The app will then take daily historical returns for the said symbol
* Calculate the daily LAG1 returns i.e. Return of 1-Day before for each day
* Run machine learning model to predict returns on above data set
* Calculate the linear regression model by apply the fit for
  * Daily LAG1 return
  * Daily return
* Calculate the linear regression line
* Calculate the predicted returns based on the linear model
* Provide a scatter plot to visualize the daily LAG1 returns, returns and regression line

<figure><img src="https://3315571876-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa9DKqYOZWk2CHHmS2pYQ%2Fuploads%2FkxdCZIcrYq91Zn9bi02k%2Fimage.png?alt=media&#x26;token=f7031b63-8aad-4bdd-8d23-5b0cf01ed03d" alt=""><figcaption></figcaption></figure>

The time series chart also provide a way to view the returns vs predicted returns and to see how many times the predicted returns direction was correct i.e. If the predicted returns and daily returns directions are same, it is considered a good forecasted direction.

<figure><img src="https://3315571876-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa9DKqYOZWk2CHHmS2pYQ%2Fuploads%2FGweijGNujVuVEYClyrkS%2Fimage.png?alt=media&#x26;token=8533e224-f19c-48f4-8493-e3c7ca23e368" alt=""><figcaption></figcaption></figure>

Also it provides stats like;

* \# number of observations i.e Number of trading days,
* \# of positive forecast
* % of positive forecasted returns within the model

This is the very first Machine Learning model among the many more models to come at KlickAnalytics.com

**To access:** From the top bar, Click ML > [Linear Regression](https://www.klickanalytics.com/ml_lr)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://klickanalytics.gitbook.io/docs/tools/machine-learning.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
