{
  "fetched_at": "2026-10-19T08:57:52Z",
  "source_url": "https://www.kaggle.com/competitions/copy-of-simpsons-faces-but-3-app/data",
  "pages": [
    {
      "name": "data-description",
      "content": "This dataset is composed of more than 6000 images for training and nearly 600 for testing. Each image is associated with a class. The dataset offers 18 different classes, i.e. 18 different characters from The Simpsons.\n\n## Files\n\n*   **train.csv** - the training set information (with image name and associate class)\n*   **test.csv** - the test set information (with image name)\n*   **sample_submission.csv** - a sample submission file in the correct format\n\n## Expected columns for submissions\n\n*   `path` - image path\n*   `classId` - predicted class",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "Description",
      "content": "This page propose some indications for your work and how you can manage the simpsons dataset:\n\n\n## 1. Import and dataset read\n\n```python\nimport pandas as pd\nimport os\nimport h5py\nfrom skimage import io, color, exposure, transform\nimport numpy as np\n```\n\n``` python\n# read data from dataset\ndf = pd.read_csv('/kaggle/input/simpsons-faces/train.csv')\ndf.head()\n```\n\n## 2. Quick data separation\n\n```python\ndata       = df.sample(frac=1., axis=0, random_state=42)\ndata_train = data.sample(frac=0.8, axis=0, random_state=42)\ndata_test  = data.drop(data_train.index)\n```\n\n## 3.  Iterate over a dataframe in order to preprocess images\n\n\n\n```python\nout_x_train = []\nimg_size = (64, 64)\nfolder = '/kaggle/input/simpsons-faces/simpsons/train'\n\n# `df` is the current dataframe variable\nfor i, row in df.iterrows():\n        \n    img_path = os.path.join(folder, row['path'])\n    img_arr = io.imread(img_path)\n    \n    # resize the image\n    img_arr = transform.resize(img_arr, img_size, preserve_range=True)\n        \n    # TODO : do whatever you want in preprocessing\n    # See `skimage.transform` if needed\n\n    # normalize image\n    img_arr = img_arr / 255.\n        \n    out_x_train.append(img_arr)\n```\n\n## 4. Create dataset h5 file\n\nThe h5 file format makes it possible to quickly load a large database where pre-processing has been performed on data \n```python\noutput_folder = '/kaggle/working/datasets'\nos.makedirs(output_folder, exist_ok=True)\ndataset_file = os.path.join(output_folder, 'dataset_gray.h5')\n\n# `out_x_train` and `out_x_test` lists contain preprocessed images\n# => image normalization\n# => gray or rgb level images (or whatever you want)\nwith h5py.File(dataset_file, \"w\") as f:\n        f.create_dataset(\"x_train\", data=out_x_train)\n        f.create_dataset(\"y_train\", data=data_train.classId.to_numpy())\n        \n        # TODO: Do the same for test data \n        # f.create_dataset(\"x_test\",  data=out_x_test)\n        # f.create_dataset(\"y_test\",  data=data_test.classId.to_numpy())\n\n# read dataset h5 file\nwith h5py.File(dataset_file, 'r') as f:\n    x_train = f['x_train'][:]\n    y_train = f['y_train'][:]\n    \n    # TODO: Do the same for test data\n    # x_test  = f['x_test'][:]\n    # y_test  = f['y_test'][:]\n    \nprint(x_train.shape)\n```\n\n## 5. Manage inbalanced data\n\nIt may be necessary to weight minority class samples (low samples number) correctly when training as opposed to majority classes:\n\n```python\nfrom sklearn.utils.class_weight import compute_sample_weight\n\n# use of sample weight\nsamples_weight = compute_sample_weight(\"balanced\", y_train)\n    \nmodel.fit(..., sample_weight=samples_weight)\n``` \n",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "Evaluation",
      "content": "\n## Submission Format\n\nThe file should contain a header and have the following format:\n```\npath,classId\ntest_00001.png,1\n...\n```",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "rules",
      "content": " - Don't cheat!\n - Respect a model with at most 1M parameters (it will be checked)\n - Max dataset image size must be (64, 64)",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    }
  ]
}