{ "cells": [ { "cell_type": "markdown", "id": "8aaedbdb", "metadata": { "papermill": { "duration": 0.005717, "end_time": "2024-06-11T01:22:18.347444", "exception": false, "start_time": "2024-06-11T01:22:18.341727", "status": "completed" }, "tags": [] }, "source": [ "## 导入库" ] }, { "cell_type": "code", "execution_count": 1, "id": "3ae39628", "metadata": { "execution": { "iopub.execute_input": "2024-06-11T01:22:18.359092Z", "iopub.status.busy": "2024-06-11T01:22:18.358823Z", "iopub.status.idle": "2024-06-11T01:22:35.966839Z", "shell.execute_reply": "2024-06-11T01:22:35.966007Z" }, "papermill": { "duration": 17.616247, "end_time": "2024-06-11T01:22:35.969116", "exception": false, "start_time": "2024-06-11T01:22:18.352869", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2024-06-11 01:22:27.464735: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n", "2024-06-11 01:22:27.464834: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n", "2024-06-11 01:22:27.562994: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n" ] } ], "source": [ "import pandas as pd\n", "from transformers import AutoTokenizer\n", "from datasets import Dataset\n", "from transformers import AutoTokenizer, AutoModelForSequenceClassification, TrainingArguments, Trainer\n", "from sklearn.metrics import accuracy_score, precision_recall_fscore_support\n", "from sklearn.preprocessing import LabelEncoder\n", "import numpy as np" ] }, { "cell_type": "markdown", "id": "bd69f5f1", "metadata": { "papermill": { "duration": 0.00525, "end_time": "2024-06-11T01:22:35.980187", "exception": false, "start_time": "2024-06-11T01:22:35.974937", "status": "completed" }, "tags": [] }, "source": [ "## 数据预处理" ] }, { "cell_type": "code", "execution_count": 2, "id": "478805d5", "metadata": { "execution": { "iopub.execute_input": "2024-06-11T01:22:35.992687Z", "iopub.status.busy": "2024-06-11T01:22:35.992098Z", "iopub.status.idle": "2024-06-11T01:22:38.238822Z", "shell.execute_reply": "2024-06-11T01:22:38.237922Z" }, "papermill": { "duration": 2.255884, "end_time": "2024-06-11T01:22:38.241687", "exception": false, "start_time": "2024-06-11T01:22:35.985803", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\n", " | Unnamed: 0 | \n", "text | \n", "Emotion | \n", "
---|---|---|---|
0 | \n", "0 | \n", "i seriously hate one subject to death but now ... | \n", "hate | \n", "
1 | \n", "1 | \n", "im so full of life i feel appalled | \n", "neutral | \n", "
2 | \n", "2 | \n", "i sit here to write i start to dig out my feel... | \n", "neutral | \n", "
3 | \n", "3 | \n", "ive been really angry with r and i feel like a... | \n", "anger | \n", "
4 | \n", "4 | \n", "i feel suspicious if there is no one outside l... | \n", "neutral | \n", "
Epoch | \n", "Training Loss | \n", "Validation Loss | \n", "Accuracy | \n", "F1 | \n", "
---|---|---|---|---|
1 | \n", "1.251200 | \n", "1.222117 | \n", "0.692843 | \n", "0.567131 | \n", "
"
],
"text/plain": [
"