{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "742dd25e", "metadata": { "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5", "execution": { "iopub.execute_input": "2025-04-09T14:57:34.588701Z", "iopub.status.busy": "2025-04-09T14:57:34.588348Z", "iopub.status.idle": "2025-04-09T14:57:36.465959Z", "shell.execute_reply": "2025-04-09T14:57:36.464971Z" }, "papermill": { "duration": 1.884778, "end_time": "2025-04-09T14:57:36.467568", "exception": false, "start_time": "2025-04-09T14:57:34.582790", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "import os\n", "import urllib.request\n", "import sys\n", "\n", "from sklearn.model_selection import train_test_split" ] }, { "cell_type": "code", "execution_count": 2, "id": "6376949e", "metadata": { "execution": { "iopub.execute_input": "2025-04-09T14:57:36.477658Z", "iopub.status.busy": "2025-04-09T14:57:36.477313Z", "iopub.status.idle": "2025-04-09T14:57:44.372695Z", "shell.execute_reply": "2025-04-09T14:57:44.371993Z" }, "papermill": { "duration": 7.901685, "end_time": "2025-04-09T14:57:44.374160", "exception": false, "start_time": "2025-04-09T14:57:36.472475", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "import torch\n", "import torch.nn as nn\n", "from torch.utils.data import Dataset, DataLoader\n", "import torch.nn.functional as f\n", "import torch.optim as optim\n", "\n", "import torchvision\n", "from torchvision.transforms import v2\n", "from torchvision import models\n", "from torchvision.models import resnet50, ResNet50_Weights\n", "import torch.optim.lr_scheduler as lr_scheduler\n", "\n", "import random\n", "from PIL import Image\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 3, "id": "c2c2efd2", "metadata": { "execution": { "iopub.execute_input": "2025-04-09T14:57:44.384169Z", "iopub.status.busy": "2025-04-09T14:57:44.383727Z", "iopub.status.idle": "2025-04-09T14:57:44.850886Z", "shell.execute_reply": "2025-04-09T14:57:44.849673Z" }, "papermill": { "duration": 0.474073, "end_time": "2025-04-09T14:57:44.852622", "exception": false, "start_time": "2025-04-09T14:57:44.378549", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "df = pd.read_csv('/kaggle/input/fakenews-fakedit/Dataset/df_balanced_resized.csv')" ] }, { "cell_type": "code", "execution_count": 4, "id": "cd73260e", "metadata": { "execution": { "iopub.execute_input": "2025-04-09T14:57:44.862381Z", "iopub.status.busy": "2025-04-09T14:57:44.862092Z", "iopub.status.idle": "2025-04-09T14:57:44.892519Z", "shell.execute_reply": "2025-04-09T14:57:44.891636Z" }, "papermill": { "duration": 0.036914, "end_time": "2025-04-09T14:57:44.894122", "exception": false, "start_time": "2025-04-09T14:57:44.857208", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\n", " | author | \n", "clean_title | \n", "created_utc | \n", "domain | \n", "hasImage | \n", "id | \n", "image_url | \n", "linked_submission_id | \n", "num_comments | \n", "score | \n", "subreddit | \n", "upvote_ratio | \n", "6_way_label | \n", "binary_label | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "BruxellesBlonde | \n", "sooooo satisfying | \n", "1.537968e+09 | \n", "i.redd.it | \n", "True | \n", "9j2gd1 | \n", "https://preview.redd.it/bjlftqsj3lo11.jpg?widt... | \n", "NaN | \n", "3.0 | \n", "15 | \n", "mildlyinteresting | \n", "0.75 | \n", "0 | \n", "0 | \n", "
1 | \n", "korkow | \n", "the chips fell out of this chocolate chip cookie | \n", "1.384738e+09 | \n", "i.imgur.com | \n", "True | \n", "1qv2m9 | \n", "https://external-preview.redd.it/ESPM-tTuK3wer... | \n", "NaN | \n", "4.0 | \n", "8 | \n", "misleadingthumbnails | \n", "0.59 | \n", "2 | \n", "1 | \n", "
2 | \n", "kyletheheroman | \n", "has anyone seen a square cloud before | \n", "1.551516e+09 | \n", "i.redd.it | \n", "True | \n", "awfsgw | \n", "https://preview.redd.it/trqkt1rx4oj21.jpg?widt... | \n", "NaN | \n", "6.0 | \n", "4 | \n", "mildlyinteresting | \n", "0.60 | \n", "0 | \n", "0 | \n", "
3 | \n", "FledPotato | \n", "it almost seems to smile back | \n", "1.522871e+09 | \n", "i.redd.it | \n", "True | \n", "89ssvs | \n", "https://preview.redd.it/yf1j0rvq4yp01.jpg?widt... | \n", "NaN | \n", "9.0 | \n", "212 | \n", "pareidolia | \n", "0.98 | \n", "2 | \n", "1 | \n", "
4 | \n", "allhundredyears | \n", "this tape deck has seen some shit | \n", "1.426363e+09 | \n", "imgur.com | \n", "True | \n", "2z1tha | \n", "https://external-preview.redd.it/QFHuRDeu_v1cm... | \n", "NaN | \n", "2.0 | \n", "6 | \n", "pareidolia | \n", "0.88 | \n", "2 | \n", "1 | \n", "
5 | \n", "spyder_19 | \n", "saw an interesting sign at the store so i got it | \n", "1.564682e+09 | \n", "i.redd.it | \n", "True | \n", "ckrv3k | \n", "https://preview.redd.it/ketwpycjmvd31.jpg?widt... | \n", "NaN | \n", "2.0 | \n", "32 | \n", "mildlyinteresting | \n", "0.87 | \n", "0 | \n", "0 | \n", "
6 | \n", "Not3Shabby | \n", "inherent paradox scrabeck | \n", "1.489213e+09 | \n", "imgur.com | \n", "True | \n", "5yrdcs | \n", "https://external-preview.redd.it/g3nNRMvtW8FCT... | \n", "NaN | \n", "0.0 | \n", "4 | \n", "fakealbumcovers | \n", "0.83 | \n", "1 | \n", "1 | \n", "
7 | \n", "mikewall | \n", "gop senate candidate kelli ward complained mcc... | \n", "1.535296e+09 | \n", "newsweek.com | \n", "True | \n", "9ag51l | \n", "https://external-preview.redd.it/3c79PddPA_og2... | \n", "NaN | \n", "15.0 | \n", "243 | \n", "nottheonion | \n", "0.95 | \n", "0 | \n", "0 | \n", "
8 | \n", "worldnews_SS | \n", "christians fleeing iraqs mosul region to provi... | \n", "1.458731e+09 | \n", "engadget.com | \n", "True | \n", "4bm0cs | \n", "https://external-preview.redd.it/xNKcWQsoGpWr3... | \n", "NaN | \n", "20.0 | \n", "10 | \n", "subredditsimulator | \n", "0.92 | \n", "3 | \n", "1 | \n", "
9 | \n", "todayilearned_SS | \n", "til pegi europes video game in only to turn to... | \n", "1.486354e+09 | \n", "nytimes.com | \n", "True | \n", "5sc05y | \n", "https://external-preview.redd.it/PL4PyhChdGdhF... | \n", "NaN | \n", "61.0 | \n", "5 | \n", "subredditsimulator | \n", "0.86 | \n", "3 | \n", "1 | \n", "