Danh mục trong python

Xem các phiên từ Hội nghị chuyên đề WiML về các mô hình khuếch tán với KerasCV, ML trên thiết bị, v.v. Xem theo yêu cầu

  • TenorFlow
  • Học hỏi
  • Lõi TensorFlow
  • hướng dẫn

Phân loại dữ liệu có cấu trúc với các cột tính năng Sắp xếp ngăn nắp với các bộ sưu tập Lưu và phân loại nội dung dựa trên sở thích của bạn

Xem trên TensorFlow. org
Chạy trong Google Colab
Xem nguồn trên GitHub
Tải xuống sổ ghi chép
Cảnh báo. Mô-đun
import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
8 được mô tả trong hướng dẫn này không được khuyến nghị cho mã mới. Các lớp tiền xử lý máy ảnh bao gồm chức năng này, để biết hướng dẫn di chuyển, hãy xem hướng dẫn cột Tính năng di chuyển. Mô-đun
import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
8 được thiết kế để sử dụng với TF1
Downloading data from //storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip
1668792/1668792 [==============================] - 0s 0us/step
0. Nó nằm trong sự đảm bảo về khả năng tương thích của chúng tôi, nhưng sẽ không nhận được bản sửa lỗi nào ngoài các lỗ hổng bảo mật.

Hướng dẫn này trình bày cách phân loại dữ liệu có cấu trúc [e. g. dữ liệu dạng bảng trong CSV]. Chúng tôi sẽ sử dụng Keras để xác định mô hình và

Downloading data from //storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip
1668792/1668792 [==============================] - 0s 0us/step
1 làm cầu nối để ánh xạ từ các cột trong CSV tới các tính năng được sử dụng để đào tạo mô hình. Hướng dẫn này chứa mã hoàn chỉnh để

  • Tải tệp CSV bằng Pandas
  • Xây dựng một đường ống đầu vào để sắp xếp và xáo trộn các hàng bằng cách sử dụng tf. dữ liệu
  • Ánh xạ từ các cột trong CSV sang các tính năng được sử dụng để đào tạo mô hình bằng các cột tính năng
  • Xây dựng, đào tạo và đánh giá một mô hình bằng Keras

Bộ dữ liệu

Chúng tôi sẽ sử dụng phiên bản đơn giản hóa của bộ dữ liệu PetFinder. Có vài nghìn hàng trong CSV. Mỗi hàng mô tả một con vật cưng và mỗi cột mô tả một thuộc tính. Chúng tôi sẽ sử dụng thông tin này để dự đoán tốc độ nhận nuôi thú cưng

Sau đây là mô tả về tập dữ liệu này. Lưu ý rằng có cả cột số và phân loại. Có một cột văn bản miễn phí mà chúng tôi sẽ không sử dụng trong hướng dẫn này

ColumnDescriptionFeature TypeData TypeTypeType of animal [Dog, Cat]CategoricalstringAgeAge of the petNumericalintegerBreed1Primary breed of the petCategoricalstringColor1Color 1 of petCategoricalstringColor2Color 2 of petCategoricalstringMaturitySizeSize at maturityCategoricalstringFurLengthFur lengthCategoricalstringVaccinatedPet has been vaccinatedCategoricalstringSterilizedPet has been sterilizedCategoricalstringHealthHealth ConditionCategoricalstringFeeAdoption FeeNumericalintegerDescriptionProfile write-up for this petTextstringPhotoAmtTotal uploaded photos for this petNumericalintegerAdoptionSpeedSpeed ​​of adoptionClassificationinteger

Nhập TensorFlow và các thư viện khác

pip install sklearn
____5
2022-12-14 03:17:00.597681: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597783: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597793: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.

Sử dụng Pandas để tạo khung dữ liệu

Pandas là một thư viện Python với nhiều tiện ích hữu ích để tải và làm việc với dữ liệu có cấu trúc. Chúng tôi sẽ sử dụng Pandas để tải xuống tập dữ liệu từ một URL và tải nó vào một khung dữ liệu

import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
____2
dataframe.head[]

Tạo biến mục tiêu

Nhiệm vụ trong bộ dữ liệu gốc là dự đoán tốc độ mà thú cưng sẽ được nhận nuôi [e. g. , trong tuần đầu tiên, tháng đầu tiên, ba tháng đầu tiên, v.v.]. Hãy đơn giản hóa điều này cho hướng dẫn của chúng tôi. Ở đây, chúng tôi sẽ chuyển đổi vấn đề này thành một vấn đề phân loại nhị phân và chỉ cần dự đoán liệu thú cưng có được nhận nuôi hay không

Sau khi sửa đổi cột nhãn, 0 sẽ cho biết thú cưng không được nhận nuôi và 1 sẽ cho biết nó đã được

import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
0

Chia khung dữ liệu thành đào tạo, xác thực và kiểm tra

Tập dữ liệu chúng tôi đã tải xuống là một tệp CSV duy nhất. Chúng tôi sẽ chia phần này thành các tập huấn luyện, xác nhận và kiểm tra

import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
1
import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
2

Tạo một đường dẫn đầu vào bằng cách sử dụng tf. dữ liệu

Tiếp theo, chúng tôi sẽ bọc các khung dữ liệu bằng tf. dữ liệu. Điều này sẽ cho phép chúng tôi sử dụng các cột tính năng làm cầu nối để ánh xạ từ các cột trong khung dữ liệu Pandas tới các tính năng được sử dụng để đào tạo mô hình. Nếu chúng tôi đang làm việc với một tệp CSV rất lớn [lớn đến mức nó không vừa với bộ nhớ], chúng tôi sẽ sử dụng tf. dữ liệu để đọc trực tiếp từ đĩa. Điều đó không được đề cập trong hướng dẫn này

import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
3____50

Hiểu đường ống đầu vào

Bây giờ chúng ta đã tạo đường dẫn đầu vào, hãy gọi nó để xem định dạng của dữ liệu mà nó trả về. Chúng tôi đã sử dụng kích thước lô nhỏ để giữ cho đầu ra có thể đọc được

import numpy as np
import pandas as pd

import tensorflow as tf

from tensorflow import feature_column
from tensorflow.keras import layers
from sklearn.model_selection import train_test_split
1
import numpy as np
import pandas as pd

import tensorflow as tf

from tensorflow import feature_column
from tensorflow.keras import layers
from sklearn.model_selection import train_test_split
2

Chúng ta có thể thấy rằng tập dữ liệu trả về một từ điển tên cột [từ khung dữ liệu] ánh xạ tới các giá trị cột từ các hàng trong khung dữ liệu

Thể hiện một số loại cột tính năng

TensorFlow cung cấp nhiều loại cột tính năng. Trong phần này, chúng tôi sẽ tạo một số loại cột tính năng và trình bày cách chúng chuyển đổi một cột từ khung dữ liệu

import numpy as np
import pandas as pd

import tensorflow as tf

from tensorflow import feature_column
from tensorflow.keras import layers
from sklearn.model_selection import train_test_split
3____54

cột số

Đầu ra của một cột tính năng trở thành đầu vào của mô hình [sử dụng hàm demo được xác định ở trên, chúng ta sẽ có thể thấy chính xác cách mỗi cột từ khung dữ liệu được chuyển đổi]. Cột số là loại cột đơn giản nhất. Nó được sử dụng để đại diện cho các tính năng có giá trị thực. Khi sử dụng cột này, mô hình của bạn sẽ nhận được giá trị cột từ khung dữ liệu không thay đổi

import numpy as np
import pandas as pd

import tensorflow as tf

from tensorflow import feature_column
from tensorflow.keras import layers
from sklearn.model_selection import train_test_split
5
import numpy as np
import pandas as pd

import tensorflow as tf

from tensorflow import feature_column
from tensorflow.keras import layers
from sklearn.model_selection import train_test_split
6

Trong tập dữ liệu PetFinder, hầu hết các cột từ khung dữ liệu đều được phân loại

cột nhóm

Thông thường, bạn không muốn nhập trực tiếp một số vào mô hình mà thay vào đó, hãy chia giá trị của nó thành các danh mục khác nhau dựa trên phạm vi số. Xem xét dữ liệu thô đại diện cho tuổi của một người. Thay vì biểu thị độ tuổi dưới dạng cột số, chúng ta có thể chia độ tuổi thành nhiều nhóm bằng cách sử dụng cột được nhóm hóa. Lưu ý các giá trị một chiều bên dưới mô tả độ tuổi mà mỗi hàng phù hợp

import numpy as np
import pandas as pd

import tensorflow as tf

from tensorflow import feature_column
from tensorflow.keras import layers
from sklearn.model_selection import train_test_split
7
import numpy as np
import pandas as pd

import tensorflow as tf

from tensorflow import feature_column
from tensorflow.keras import layers
from sklearn.model_selection import train_test_split
8

cột phân loại

Trong bộ dữ liệu này, Loại được biểu diễn dưới dạng một chuỗi [e. g. 'Chó' hoặc 'Mèo']. Chúng tôi không thể cung cấp chuỗi trực tiếp cho một mô hình. Thay vào đó, trước tiên chúng ta phải ánh xạ chúng thành các giá trị số. Các cột từ vựng phân loại cung cấp một cách để biểu diễn các chuỗi dưới dạng một vectơ một chiều [giống như bạn đã thấy ở trên với các nhóm tuổi]. Từ vựng có thể được chuyển dưới dạng danh sách bằng cách sử dụng categorical_column_with_vocabulary_list hoặc được tải từ một tệp bằng cách sử dụng categorical_column_with_vocabulary_file

import numpy as np
import pandas as pd

import tensorflow as tf

from tensorflow import feature_column
from tensorflow.keras import layers
from sklearn.model_selection import train_test_split
9
2022-12-14 03:17:00.597681: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597783: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597793: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
0

Nhúng cột

Giả sử thay vì chỉ có một vài chuỗi có thể, chúng ta có hàng nghìn [hoặc nhiều hơn] giá trị cho mỗi danh mục. Vì một số lý do, khi số lượng danh mục tăng lên, việc huấn luyện mạng thần kinh sử dụng mã hóa one-hot trở nên không khả thi. Chúng ta có thể sử dụng cột nhúng để khắc phục hạn chế này. Thay vì biểu thị dữ liệu dưới dạng vectơ one-hot có nhiều chiều, cột nhúng biểu thị dữ liệu đó dưới dạng vectơ dày đặc, chiều thấp hơn, trong đó mỗi ô có thể chứa bất kỳ số nào, không chỉ 0 hoặc 1. Kích thước nhúng [8, trong ví dụ bên dưới] là một tham số phải được điều chỉnh

Điểm chính. sử dụng cột nhúng là tốt nhất khi cột phân loại có nhiều giá trị có thể. Chúng tôi đang sử dụng một cái ở đây cho mục đích trình diễn, vì vậy bạn có một ví dụ hoàn chỉnh mà bạn có thể sửa đổi cho một tập dữ liệu khác trong tương lai. ______61
2022-12-14 03:17:00.597681: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597783: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597793: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
2

Các cột tính năng được băm

Một cách khác để biểu thị cột phân loại có số lượng lớn giá trị là sử dụng categorical_column_with_hash_bucket. Cột tính năng này tính toán giá trị băm của đầu vào, sau đó chọn một trong các nhóm

Downloading data from //storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip
1668792/1668792 [==============================] - 0s 0us/step
2 để mã hóa chuỗi. Khi sử dụng cột này, bạn không cần cung cấp từ vựng và bạn có thể chọn làm cho số lượng hash_buckets nhỏ hơn đáng kể so với số lượng danh mục thực tế để tiết kiệm dung lượng

Điểm chính. Một nhược điểm quan trọng của kỹ thuật này là có thể xảy ra xung đột trong đó các chuỗi khác nhau được ánh xạ tới cùng một nhóm. Trong thực tế, điều này có thể hoạt động tốt đối với một số bộ dữ liệu bất kể. ______63
2022-12-14 03:17:00.597681: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597783: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597793: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
4

Cột tính năng chéo

Kết hợp các tính năng thành một tính năng duy nhất, hay còn gọi là tính năng chéo, cho phép một mô hình tìm hiểu các trọng số riêng biệt cho từng kết hợp tính năng. Ở đây, chúng tôi sẽ tạo một tính năng mới là dấu thập của Tuổi và Loại. Lưu ý rằng

Downloading data from //storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip
1668792/1668792 [==============================] - 0s 0us/step
3 không xây dựng bảng đầy đủ tất cả các kết hợp có thể [có thể rất lớn]. Thay vào đó, nó được hỗ trợ bởi một
Downloading data from //storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip
1668792/1668792 [==============================] - 0s 0us/step
4, vì vậy bạn có thể chọn kích thước của bảng

2022-12-14 03:17:00.597681: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597783: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597793: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
5
2022-12-14 03:17:00.597681: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597783: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597793: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
6

Chọn những cột sẽ sử dụng

Chúng tôi đã thấy cách sử dụng một số loại cột tính năng. Bây giờ chúng tôi sẽ sử dụng chúng để đào tạo một mô hình. Mục tiêu của hướng dẫn này là cho bạn thấy mã hoàn chỉnh [e. g. cơ khí] cần thiết để làm việc với các cột tính năng. Chúng tôi đã chọn một vài cột để đào tạo mô hình của chúng tôi bên dưới một cách tùy ý

Điểm chính. Nếu mục tiêu của bạn là xây dựng một mô hình chính xác, hãy thử tập dữ liệu lớn hơn của riêng bạn và suy nghĩ cẩn thận về những tính năng có ý nghĩa nhất để đưa vào và cách chúng nên được trình bày. ______67
2022-12-14 03:17:00.597681: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597783: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597793: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
8
2022-12-14 03:17:00.597681: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597783: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2022-12-14 03:17:00.597793: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
9
import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
0
import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
1

Tạo một lớp tính năng

Bây giờ chúng tôi đã xác định các cột tính năng của mình, chúng tôi sẽ sử dụng lớp DenseFeatures để nhập chúng vào mô hình Keras của chúng tôi

import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
2

Trước đó, chúng tôi đã sử dụng kích thước lô nhỏ để chứng minh cách hoạt động của các cột tính năng. Chúng tôi tạo một quy trình đầu vào mới với kích thước lô lớn hơn

import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
3

Tạo, biên dịch và huấn luyện mô hình

import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
4
import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
5
import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
6
import pathlib

dataset_url = '//storage.googleapis.com/download.tensorflow.org/data/petfinder-mini.zip'
csv_file = 'datasets/petfinder-mini/petfinder-mini.csv'

tf.keras.utils.get_file['petfinder_mini.zip', dataset_url,
                        extract=True, cache_dir='.']
dataframe = pd.read_csv[csv_file]
7Điểm mấu chốt. Thông thường, bạn sẽ thấy kết quả tốt nhất khi học sâu với các tập dữ liệu lớn hơn và phức tạp hơn nhiều. Khi làm việc với một tập dữ liệu nhỏ như tập dữ liệu này, chúng tôi khuyên bạn nên sử dụng cây quyết định hoặc rừng ngẫu nhiên làm cơ sở vững chắc. Mục tiêu của hướng dẫn này không phải là đào tạo một mô hình chính xác mà là để chứng minh cơ chế làm việc với dữ liệu có cấu trúc, vì vậy bạn có mã để sử dụng làm điểm bắt đầu khi làm việc với bộ dữ liệu của riêng mình trong tương lai.

Bước tiếp theo

Cách tốt nhất để tìm hiểu thêm về cách phân loại dữ liệu có cấu trúc là tự mình thử. Chúng tôi khuyên bạn nên tìm một tập dữ liệu khác để làm việc và đào tạo một mô hình để phân loại nó bằng cách sử dụng mã tương tự như trên. Để cải thiện độ chính xác, hãy suy nghĩ cẩn thận về những tính năng cần đưa vào mô hình của bạn và cách chúng nên được thể hiện

Chủ Đề