Machine learning in trading: theory, models, practice and algo-trading - page 3447

 

A seemingly simple task for AGI

can you write a pseudocode of this code?
 n_clusters = 25
models = []
for i in range(1):
    data = meta_learner(5, 25, 2, 0.3, n_clusters=n_clusters, algorithm=0)
    
    for clust in data['clusters'].unique():
        print('Learn ' + str(i) + ' iter ' + str(clust) + ' model')
        models.append(fit_final_models(data['clusters'].apply(lambda x: 1 if x == clust else 0)))

models.sort(key=lambda x: x[0])
test_model(models[-1][1:], plt=True)
1. Set the number of clusters to 25.
2. Initialize an empty list to store the models.
3. For each iteration (in this case, only one iteration):
    a. Call the `meta_learner` function with the following parameters:
        - Number of folds: 5
        - Number of clusters: 25
        - Number of neighbors: 2
        - Threshold: 0.3
        - Algorithm: 0
    b. Iterate over the unique cluster labels in the data returned by `meta_learner`:
        - Print a message indicating the iteration number and cluster number.
        - Call the `fit_final_models` function to fit a model to the data where the cluster label matches the current cluster number.
        - Append the fitted model to the `models` list.
4. Sort the `models` list based on the first element of each tuple (the score).
5. Call the `test_model` function, passing in the sorted `models` list and setting `plt` to `True` to plot the results.
can you write a python code from this pseudocode?
1. Set the number of clusters to 25.
2. Initialize an empty list to store the models.
3. For each iteration (in this case, only one iteration):
    a. Call the `meta_learner` function with the following parameters:
        - Number of folds: 5
        - Number of clusters: 25
        - Number of neighbors: 2
        - Threshold: 0.3
        - Algorithm: 0
    b. Iterate over the unique cluster labels in the data returned by `meta_learner`:
        - Print a message indicating the iteration number and cluster number.
        - Call the `fit_final_models` function to fit a model to the data where the cluster label matches the current cluster number.
        - Append the fitted model to the `models` list.
4. Sort the `models` list based on the first element of each tuple (the score).
5. Call the `test_model` function, passing in the sorted `models` list and setting `plt` to `True` to plot the results.
from sklearn.cluster import KMeans
from sklearn.neighbors import NearestNeighbors
from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_selection import StratifiedKFold
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
import matplotlib.pyplot as plt

# Set the number of clusters
num_clusters = 25

# Initialize an empty list to store the models
models = []

# For each iteration (in this case, only one iteration)
for i in range(1):
    # Call the meta_learner function with the following parameters:
    # - Number of folds: 5
    # - Number of clusters: 25
    # - Number of neighbors: 2
    # - Threshold: 0.3
    # - Algorithm: 0
    meta_data = meta_learner(n_folds=5, n_clusters=num_clusters, n_neighbors=2, threshold=0.3, algorithm=0)

    # Iterate over the unique cluster labels in the data returned by meta_learner
    for cluster_label in np.unique(meta_data['cluster_label']):
        # Print a message indicating the iteration number and cluster number
        print(f'Iteration: {i}, Cluster: {cluster_label}')

        # Call the fit_final_models function to fit a model to the data where the cluster label matches the current cluster number
        model = fit_final_models(meta_data[meta_data['cluster_label'] == cluster_label])

        # Append the fitted model to the models list
        models.append((model.score(X_test, y_test), model))

# Sort the models list based on the first element of each tuple (the score)
models.sort(key=lambda x: x[0], reverse=True)

# Call the test_model function, passing in the sorted models list and setting plt to True to plot the results
test_model(models, plt=True)

Now it doesn't work.

 
mytarmailS #:

Name five grand at least.

Stock markets.

The price of a share is the market's assessment of the value of a company. Take a balance sheet, there are hundreds of indicators affecting the value of the company. Depreciation of fixed assets and investments in fixed capital are definitely related to the share price... In any case, there is a basis for the broadest, most importantly meaningful, reasoning about the features affecting the share price.

Commodity markets.

The situation is similar.

And Forex is practically a casino

 

Examples of how clustering can be used in two different ways

I will upload more bots to kodobase this weekend.

https://www.mql5.com/ru/articles/14548

Кластеризация временных рядов в причинно-следственном выводе
Кластеризация временных рядов в причинно-следственном выводе
  • www.mql5.com
Алгоритмы кластеризации в машинном обучении — это важные алгоритмы обучения без учителя, которые позволяют разделять исходные данные на группы с похожими наблюдениями. Используя эти группы, можно проводить анализ рынка для конкретного кластера, искать наиболее устойчивые кластеры на новых данных, а также делать причинно-следственный вывод. В статье предложен авторский метод кластеризации временных рядов на языке Python.
 
Maxim Dmitrievsky #:

Examples of how clustering can be used in two different ways

I will upload more bots to kodobase this weekend

https://www.mql5.com/ru/articles/14548

You wrote the article quickly - I can't keep up!

Only, for some reason I have a feeling that you use linguistic models - the text sounds strange at some points....

 
Aleksey Vyazmikin #:

You've written this article quickly - can't keep up!

But, for some reason, I have a feeling that you use linguistic models - the text sounds strange at some points....

I'm screwed. Decided to ask to make her routine descriptions, then edited. Overall I think it's not bad :)
 
Maxim Dmitrievsky #:
Got spoilt. Decided to ask to do her routine descriptions, then tweaked it. Overall I think it's not bad :)

Not bad for personal use, but I would prefer to read the work of a person, especially when the articles are recognised to teach something.

Sometimes I read articles of foreigners after almost machine translation, and I feel ashamed that my labour is probably so mangled in translation.

If we consider all this as an opportunity to earn money with less investment of time and effort, then it already looks interesting, there is no explicit ban from the editorial board on such an approach.

 
Aleksey Vyazmikin #:

Not bad for personal use, but I'd rather read a person's work, especially when the articles purport to teach something.

Sometimes I read articles by foreigners after almost machine translation, and I feel ashamed that my labour is probably so corrupted in translation.

If we consider all this as an opportunity to earn money with less investment of time and effort, then it already looks interesting, there is no explicit ban from the editorial board on such an approach.

Programming articles should be more like documentation rather than a mess of text and code. They read better that way.

There are special programs for creating documentation from code, they have been used for a long time. Now you can do it via chatGpt and others. Purely his niche. It seemed that in this case it will be good.

 
Aleksey Vyazmikin #:

If you consider all this as an opportunity to earn with less investment of your efforts and time, then it already looks interesting, there is no explicit ban from the editorial board on such an approach.

I wouldn't consider articles as an opportunity to make money. For that you should turn into an octopus and write an article a day :)
 
Кто управляет крипто рынком на самом деле. Манипулятор это миф или правда?
Кто управляет крипто рынком на самом деле. Манипулятор это миф или правда?
  • 2024.01.19
  • www.youtube.com
В видео мы на практике покажем, как происходит манипуляция ценой актива.Все этапы манипуляции, от создания монеты и листинга до пампа и дампа.Telegramhttps:/...
 
Maxim Dmitrievsky #:
Programming articles should be more like documentation, not a mess of text and code. They read better that way.

There are special programs for creating documentation from code, they have been used for a long time. Now you can do it via chatGpt and others. Purely his niche. It seemed that in this case it will be good.

I look for ideas in such articles. It is better to read code articles from authors who specialise in it.

Python is terrible for careless attitude to variables - it is hard to read it at all, because there are many variations of doing the same thing by different methods.

Maxim Dmitrievsky #:
I would not consider articles as an opportunity to earn money. For that you should turn into an octopus and write an article a day :)

Well, it depends on the time spent on the article. I don't have a steady income, so as an option when other things are done, could be an interesting source of income. Although I write at least a month article - almost every day spending time to work on it - probably need to change the approach.

Reason: