日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

达尔文进化奖_使用Kydavra GeneticAlgorithmSelector将达尔文进化应用于特征选择

發布時間:2023/12/15 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 达尔文进化奖_使用Kydavra GeneticAlgorithmSelector将达尔文进化应用于特征选择 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

達爾文進化獎

Maths almost always have a good answer in questions related to feature selection. However, sometimes good-old brute force algorithms can bring into the game a better and more practical answer.

中號 ATHS幾乎總是在與特征選擇問題一個很好的答案。 但是,有時舊式的蠻力算法可以為游戲帶來更好,更實用的答案。

Genetic algorithms are a family of algorithms inspired by biological evolution, that basically use the cycle — cross, mutate, try, developing the best combination of states depending on the scoring metric. So, let’s get to the code.

遺傳算法是一類受生物進化啟發的算法,它們基本上使用循環-交叉,變異,嘗試,根據評分標準開發狀態的最佳組合。 因此,讓我們看一下代碼。

使用來自Kydavra庫的GeneticAlgorithmSelector。 (Using GeneticAlgorithmSelector from Kydavra library.)

To install kydavra just write the following command in terminal:

要安裝kydavra,只需在終端中輸入以下命令:

pip install kydavra

Now you can import the Selector and apply it on your data set a follows:

現在,您可以導入選擇器,并將其應用于數據集,如下所示:

from kydavra import GeneticAlgorithmSelectorselector = GeneticAlgorithmSelector()new_columns = selector.select(model, df, ‘target’)

As with every Kydavra selector that’s all. Now let’s try it on the Heart disease dataset.

就像所有Kydavra選擇器一樣。 現在讓我們在“心臟病”數據集上嘗試一下。

import pandas as pddf = pd.read_csv(‘cleaned.csv’)

I highly recommend you to shuffle your dataset before applying the selector, because it uses metrics (and right now cross_val_score isn’t implemented in this selector).

我強烈建議您在應用選擇器之前先對數據集進行洗牌,因為它使用指標(并且此選擇器中目前未實現cross_val_score)。

df = df.sample(frac=1).reset_index(drop=True)

Now we can apply our selector. To mention it has some parameters:

現在我們可以應用選擇器了。 要說它有一些參數:

  • nb_children (int, default = 4) the number of best children that the algorithm will choose for the next generation.

    nb_children (int,默認= 4)該算法將為下一代選擇的最佳子代數。

  • nb_generation (int, default = 200) the number of generations that will be created, technically speaking the number of iterations.

    nb_generation (整數,默認值= 200)將要創建的世代數,從技術上講是迭代數。

  • scoring_metric (sklearn scoring metric, default = accuracy_score) The metric score used to select the best feature combination.

    scoring_metric (sklearn評分標準,默認= precision_score)用于選擇最佳功能組合的度量標準分數。

  • max (boolean, default=True) if is set to True, the algorithm will select the combinations with the highest score if False the lowest scores will be chosen.

    max (布爾值,默認值= True),如果設置為True,則算法將選擇得分最高的組合,如果為False,則選擇最低得分。

But for now, we will use the basic setting except for the scoring_metric, because we have there a problem of disease diagnosis, so it will better to use Precision instead of accuracy.

但是現在,我們將使用除scoring_metric之外的基本設置,因為我們存在疾病診斷的問題,因此最好使用Precision而不是Precision。

from kydavra import GeneticAlgorithmSelectorfrom sklearn.metrics import precision_scorefrom sklearn.ensemble import RandomForestClassifierselector = GeneticAlgorithmSelector(scoring_metric=precision_score)model = RandomForestClassifier()

So now let’s find the best features. GAS (short version for GeneticAlgorithmSelector) need a sklearn model to train during the process of choosing features, the data frame itself and of course the name of target column:

因此,現在讓我們找到最佳功能。 GAS(GeneticAlgorithmSelector的縮寫)需要一個sklearn模型來進行特征選擇,數據框本身以及目標列名稱的訓練:

selected_cols = selector.select(model, df, 'target')

Now let’s evaluate the result. Before feature selection, the precision score of the Random Forest was — 0.805. GAS choose the following features:

現在讓我們評估結果。 在特征選擇之前,隨機森林的精度得分為-0.805。 GAS選擇以下功能:

['age', 'sex', 'cp', 'fbs', 'restecg', 'exang', 'slope', 'thal']

Which gave the following precision score — 0.823. Which is a good result, knowing that in the majority of cases it is very hard to level up the scoring metrics.

得出的精度得分為0.823。 知道在大多數情況下很難提高評分標準,這是一個很好的結果。

If you want to find out more about Genetic Algorithms, at the bottom of the article are some useful links. If you tried Kydavra and have some issues or feedback, please contact me on medium or please fill this form.

如果您想了解有關遺傳算法的更多信息,請在本文底部找到一些有用的鏈接。 如果您嘗試了Kydavra,但有任何問題或反饋,請通過媒體與我聯系,或填寫此表格 。

Made with ? by Sigmoid

由Sigmoid制造的?

Useful links:

有用的鏈接:

  • https://towardsdatascience.com/the-most-important-part-in-artifical-intesystems-development-243f04f73fcd

    https://towardsdatascience.com/the-most-important-part-in-artifical-intesystems-development-243f04f73fcd

翻譯自: https://towardsdatascience.com/applying-darwinian-evolution-to-feature-selection-with-kydavra-geneticalgorithmselector-378662fd1f5b

達爾文進化獎

總結

以上是生活随笔為你收集整理的达尔文进化奖_使用Kydavra GeneticAlgorithmSelector将达尔文进化应用于特征选择的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。