1단계: 데이터 수집하기
컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
데이터 수집은 지도 머신러닝 문제를 해결하는 데 가장 중요한 단계입니다. Text Classifier는 빌드의 기반이 되는 데이터 세트의 품질에 따라 달라집니다.
해결하려는 특정 문제가 없고 일반적으로 텍스트 분류를 살펴보는 데만 관심이 있는 경우 사용할 수 있는 다양한 오픈소스 데이터 세트가 있습니다. 일부 링크는 GitHub 저장소에서 찾을 수 있습니다. 반면에 특정 문제를 다루는 경우에는 필요한 데이터를 수집해야 합니다. 많은 조직에서 데이터 액세스를 위한 공개 API(예: X API 또는 NY Times API)를 제공합니다. 해결하려는 문제에 이러한 API를 활용할 수 있습니다.
데이터를 수집할 때 기억해야 할 몇 가지 중요한 사항은 다음과 같습니다.
- 공개 API를 사용하는 경우 사용하기 전에 API의 제한사항을 숙지하세요. 예를 들어 일부 API는 쿼리를 만들 수 있는 속도에 제한을 설정합니다.
- 학습 예 (이 가이드의 나머지 부분에서 샘플이라고 함)는 많을수록 좋습니다. 이렇게 하면 모델이 더 잘 일반화하는 데 도움이 됩니다.
- 모든 클래스 또는 주제의 샘플 수가 지나치게 불균형하지 않은지 확인합니다. 즉, 각 클래스에 비슷한 샘플 수가 있어야 합니다.
- 샘플에 일반적인 사례뿐만 아니라 가능한 입력 공간이 충분히 포함되었는지 확인하세요.
이 가이드에서는 인터넷 영화 데이터베이스 (IMDb) 영화 리뷰 데이터 세트를 사용하여 워크플로를 설명합니다. 이 데이터 세트에는 IMDb 웹사이트에 사람들이 게시한 영화 리뷰뿐만 아니라 리뷰 작성자가 영화를 좋아했는지 여부를 나타내는 라벨('긍정적' 또는 '부정적')이 포함되어 있습니다. 이것은 감정 분석 문제의 전형적인 예입니다
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[null,null,["최종 업데이트: 2025-07-27(UTC)"],[[["\u003cp\u003eHigh-quality data is crucial for building effective supervised machine learning text classifiers, with more training samples generally leading to better performance.\u003c/p\u003e\n"],["\u003cp\u003ePublic APIs and open-source datasets can be leveraged for data collection, but it's important to understand API limitations and ensure data balance across classes.\u003c/p\u003e\n"],["\u003cp\u003eAdequate data representation across all possible input variations is necessary, and the IMDb movie reviews dataset will be used to demonstrate text classification workflow for sentiment analysis.\u003c/p\u003e\n"],["\u003cp\u003eWhen collecting data, aim for a balanced dataset with a sufficient number of samples for each class to avoid imbalanced datasets and promote better model generalization.\u003c/p\u003e\n"]]],[],null,["# Step 1: Gather Data\n\nGathering data is the most important step in solving any supervised machine\nlearning problem. Your text classifier can only be as good as the dataset it is\nbuilt from.\n\nIf you don't have a specific problem you want to solve and are just interested\nin exploring text classification in general, there are plenty of open source\ndatasets available. You can find links to some of them in our [GitHub\nrepo](https://github.com/google/eng-edu/blob/master/ml/guides/text_classification/load_data.py).\nOn the other hand, if you are tackling a specific problem,\nyou will need to collect the necessary data. Many organizations provide public\nAPIs for accessing their data---for example, the\n[X API](https://developer.x.com/docs) or the\n[NY Times API](http://developer.nytimes.com/). You may be able to leverage\nthese APIs for the problem you are trying to solve.\n\nHere are some important things to remember when collecting data:\n\n- If you are using a public API, understand the *limitations* of the API before using them. For example, some APIs set a limit on the rate at which you can make queries.\n- The more training examples (referred to as *samples* in the rest of this guide) you have, the better. This will help your model [generalize](/machine-learning/glossary#generalization) better.\n- Make sure the number of samples for every *class* or topic is not overly [imbalanced](/machine-learning/glossary#class_imbalanced_data_set). That is, you should have comparable number of samples in each class.\n- Make sure that your samples adequately cover the *space of possible inputs*, not only the common cases.\n\nThroughout this guide, we will use the [Internet Movie Database (IMDb) movie\nreviews dataset](http://ai.stanford.edu/%7Eamaas/data/sentiment/) to illustrate\nthe workflow. This dataset contains movie reviews posted by people on the IMDb\nwebsite, as well as the corresponding labels (\"positive\" or \"negative\")\nindicating whether the reviewer liked the movie or not. This is a classic\nexample of a sentiment analysis problem."]]