簡體   English   中英

使用 LSTM 構建二進制分類 model

[英]build a binary classification model with LSTM

我有一個 csv 格式的數據集,有 49 列,其中一些是字符串,其中一些是整數。

我添加了一個新列用作 label,稱為“輸入”,適當的 label 為 0 和 1。

這是數據集的示例: 在此處輸入圖像描述

要求是考慮 model 訓練的所有這些特征列。

我必須訓練這個 model 有哪些選擇? 我應該遵循哪些步驟? 任何資源(文章、視頻等)將不勝感激。

謝謝你,

這里有兩個教程可能會對您有所幫助:

https://towardsdatascience.com/machine-learning-recurrent-neural-networks-and-long-short-term-memory-lstm-python-keras-example-86001ceaaebc

https://stackabuse.com/time-series-analysis-with-lstm-using-pythons-keras-library/

本教程是關於混合數據的: https://www.pyimagesearch.com/2019/02/04/keras-multiple-inputs-and-mixed-data/

如果您不使用未提及的其他東西,我建議您嘗試 Keras 以熟悉如何訓練它。

只需在 google 中寫下您的問題,就可以幫助您找到許多具體的教程!

編輯:來自 keras 文檔:

keras.utils.to_categorical(y, num_classes=None, dtype='float32')

將 class 向量(整數)轉換為二進制 class 矩陣。 例如與 categorical_crossentropy 一起使用。 Arguments

  • y:要轉換為矩陣的 class 向量(從 0 到 num_classes 的整數)。
  • num_classes:類的總數。
  • dtype:輸入期望的數據類型,作為字符串(float32、float64、int32...)

回報:

輸入的二進制矩陣表示。 類軸放在最后。

# Consider an array of 5 labels out of a set of 3 classes {0, 1, 2}:
> labels
array([0, 2, 1, 2, 0])
# `to_categorical` converts this into a matrix with as many
# columns as there are classes. The number of rows
# stays the same.
> to_categorical(labels)
array([[ 1.,  0.,  0.],
       [ 0.,  0.,  1.],
       [ 0.,  1.,  0.],
       [ 0.,  0.,  1.],
       [ 1.,  0.,  0.]], dtype=float32)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM