{ "cells": [ { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [], "source": [ "import tensorflow as tf\n", "import pandas as pd\n", "import numpy as np\n", "import cv2\n", "from PIL import Image\n", "import mediapipe as mp\n", "from sklearn.ensemble import RandomForestClassifier\n", "import plotly.express as px\n", "from sklearn.metrics import classification_report, confusion_matrix\n", "from sklearn.model_selection import train_test_split\n", "from tqdm.notebook import tqdm" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Load Model" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WARNING:tensorflow:No training configuration found in the save file, so the model was *not* compiled. Compile it manually.\n", "Model: \"Embedding\"\n", "_________________________________________________________________\n", " Layer (type) Output Shape Param # \n", "=================================================================\n", " input_14 (InputLayer) [(None, 478, 3)] 0 \n", " \n", " flatten_13 (Flatten) (None, 1434) 0 \n", " \n", " batch_normalization_13 (Bat (None, 1434) 5736 \n", " chNormalization) \n", " \n", " dense_78 (Dense) (None, 1024) 1469440 \n", " \n", " dropout_22 (Dropout) (None, 1024) 0 \n", " \n", " dense_79 (Dense) (None, 16) 16400 \n", " \n", "=================================================================\n", "Total params: 1,491,576\n", "Trainable params: 1,488,708\n", "Non-trainable params: 2,868\n", "_________________________________________________________________\n" ] } ], "source": [ "model = tf.keras.models.load_model('embedding_model_2023-06-03.h5')\n", "model.summary()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Preprocessing Helper Functions" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO: Created TensorFlow Lite XNNPACK delegate for CPU.\n" ] } ], "source": [ "from model import LandmarkExtractor\n", "lmk_extractor = LandmarkExtractor()\n", "\n", "def preprocess(landmark_extractor: LandmarkExtractor, image: bytes) -> np.ndarray:\n", " array_repr = np.asarray(bytearray(image), dtype=np.uint8)\n", " # Decode the image. If there is no color, cv2.IMREAD_GRAYSCALE can be used\n", " try:\n", " decoded_img = cv2.imdecode(array_repr, flags=cv2.IMREAD_COLOR)\n", " except:\n", " decoded_img = cv2.imdecode(array_repr, flags=cv2.IMREAD_GRAYSCALE)\n", " landmarks = landmark_extractor.extract_landmarks_flat(decoded_img)\n", " if landmarks is None:\n", " return None\n", " return pd.DataFrame([landmarks]).to_numpy().reshape(1, 478, -1)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "def extract_face(face_detection, image):\n", " mp_face_detection = mp.solutions.face_detection\n", " image = cv2.imdecode(image, cv2.IMREAD_COLOR)\n", "\n", " # Convert the image to RGB\n", " image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n", "\n", " # Initialize the face detection model\n", "\n", " # Run the face detection model on the image\n", " results = face_detection.process(image)\n", " # If a face is detected, crop the image to the face box\n", " if results.detections:\n", " for detection in results.detections:\n", " x, y, w, h = (\n", " int(\n", " detection.location_data.relative_bounding_box.xmin * image.shape[1]\n", " ),\n", " int(\n", " detection.location_data.relative_bounding_box.ymin * image.shape[0]\n", " ),\n", " int(\n", " detection.location_data.relative_bounding_box.width * image.shape[1]\n", " ),\n", " int(\n", " detection.location_data.relative_bounding_box.height\n", " * image.shape[0]\n", " ),\n", " )\n", " cropped_image = image[y : y + h, x : x + w]\n", " return cv2.cvtColor(cropped_image, cv2.COLOR_RGB2BGR)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "def embed(model, image):\n", " landmarks = preprocess(lmk_extractor, image)\n", " if landmarks is None:\n", " return None\n", " return model.predict(landmarks)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Load Datasets\n", "### FER 2013" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [], "source": [ "fer_df = pd.read_csv(\"data/fer2013/labels.clean.csv\", index_col=0)" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [], "source": [ "def extract_label(row: pd.Series):\n", " return row.drop([\"Usage\"]).sort_values(ascending=False).index[0]" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "import os\n", "\n", "\n", "def load_fer_dataset(df: pd.DataFrame, mode: str = \"Training\"):\n", " embeddings = []\n", " labels = []\n", " df = df[df[\"Usage\"] == mode]\n", " for image_name, row in tqdm(df.iterrows(), total=len(df)):\n", " with open(os.path.join(\"data\", \"fer2013\", \"FER2013Test\" if mode == \"Test\" else \"FER2013Train\", image_name), \"rb\") as f:\n", " image = f.read()\n", " embeddings.append(\n", " embed(model, image)\n", " )\n", " labels.append(\n", " extract_label(row)\n", " )\n", " X = np.array(embeddings)\n", " y = np.array(labels)\n", " return X, y" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "89cdc346b673429e8031850a9a6e8550", "version_major": 2, "version_minor": 0 }, "text/plain": [ "0it [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "X_train, y_train = load_fer_dataset(fer_df, mode=\"Training\")\n", "# X_test, y_test = load_fer_dataset(fer_df, mode=\"Testing\")" ] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "outputs": [], "source": [ "X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.2)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Train Classifier" ] }, { "cell_type": "code", "execution_count": 120, "metadata": {}, "outputs": [], "source": [ "# from sklearn.model_selection import GridSearchCV\n", "# param_grid = {\n", "# 'bootstrap': [True],\n", "# 'max_depth': [80, 90, 100, 110],\n", "# 'max_features': [2, 3, 4, 5],\n", "# 'min_samples_leaf': [3, 4, 5],\n", "# 'min_samples_split': [8, 10, 12],\n", "# 'n_estimators': [100, 200, 300, 1000]\n", "# }\n", "# rf = RandomForestClassifier()\n", "# clf = GridSearchCV(estimator = rf, param_grid = param_grid, cv = 3, verbose = 2, n_jobs = -1)\n", "# clf.fit(X_train.squeeze(), y_train)" ] }, { "cell_type": "code", "execution_count": 121, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "RandomForestClassifier()" ] }, "execution_count": 121, "metadata": {}, "output_type": "execute_result" } ], "source": [ "clf = RandomForestClassifier()\n", "clf.fit(X_train.squeeze(), y_train)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Evaluate Classifier" ] }, { "cell_type": "code", "execution_count": 122, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " precision recall f1-score support\n", "\n", " anger 0.62 0.24 0.34 432\n", " contempt 0.75 0.10 0.17 31\n", " disgust 1.00 0.19 0.32 31\n", " fear 0.88 0.13 0.23 116\n", " happiness 0.71 0.75 0.73 1460\n", " neutral 0.59 0.86 0.70 1939\n", " sadness 0.51 0.17 0.26 623\n", " surprise 0.69 0.57 0.62 680\n", " unknown 1.00 0.14 0.24 22\n", "\n", " accuracy 0.63 5334\n", " macro avg 0.75 0.35 0.40 5334\n", "weighted avg 0.64 0.63 0.60 5334\n", "\n" ] } ], "source": [ "print(classification_report(y_test, clf.predict(X_test.squeeze())))" ] }, { "cell_type": "code", "execution_count": 123, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "coloraxis": "coloraxis", "hovertemplate": "x: %{x}
y: %{y}
color: %{z}", "name": "0", "type": "heatmap", "x": [ "anger", "contempt", "disgust", "fear", "happiness", "neutral", "sadness", "surprise", "unknown" ], "xaxis": "x", "y": [ "anger", "contempt", "disgust", "fear", "happiness", "neutral", "sadness", "surprise", "unknown" ], "yaxis": "y", "z": [ [ 0.6167664670658682, 0, 0, 0, 0.0645577792123951, 0.06609808102345416, 0.03333333333333333, 0.06382978723404255, 0 ], [ 0, 0.75, 0, 0, 0.005810200129115558, 0.006751954513148543, 0, 0, 0 ], [ 0.011976047904191617, 0, 1, 0, 0.005164622336991607, 0.005330490405117271, 0, 0, 0 ], [ 0.023952095808383235, 0, 0, 0.8823529411764706, 0.012911555842479019, 0.01847903340440654, 0.014285714285714285, 0.03900709219858156, 0 ], [ 0.10179640718562874, 0, 0, 0, 0.7101355713363461, 0.10163468372423597, 0.08571428571428572, 0.06914893617021277, 0 ], [ 0.07784431137724551, 0.25, 0, 0.058823529411764705, 0.08650742414460942, 0.589907604832978, 0.319047619047619, 0.11170212765957446, 0 ], [ 0.041916167664670656, 0, 0, 0.058823529411764705, 0.07295029051000645, 0.13432835820895522, 0.5142857142857142, 0.028368794326241134, 0 ], [ 0.11976047904191617, 0, 0, 0, 0.040025823111684955, 0.07320540156361052, 0.023809523809523808, 0.6861702127659575, 0 ], [ 0.005988023952095809, 0, 0, 0, 0.001936733376371853, 0.0042643923240938165, 0.009523809523809525, 0.0017730496453900709, 1 ] ] } ], "layout": { "coloraxis": { "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Confusion Matrix - Precision" }, "xaxis": { "anchor": "y", "constrain": "domain", "domain": [ 0, 1 ], "scaleanchor": "y", "side": "top", "title": { "text": "Predicted" } }, "yaxis": { "anchor": "x", "autorange": "reversed", "constrain": "domain", "domain": [ 0, 1 ], "title": { "text": "Actual" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "cm = confusion_matrix(y_test, clf.predict(X_test.squeeze()), labels=clf.classes_, normalize=\"pred\")\n", "fig = px.imshow(cm, x=clf.classes_, y=clf.classes_, title=\"Confusion Matrix - Precision\")\n", "fig.update_xaxes(side=\"top\", title=\"Predicted\")\n", "fig.update_yaxes(title=\"Actual\")\n", "fig.show()\n", "fig.write_image(\"confusion_matrix_precision.svg\")" ] }, { "cell_type": "code", "execution_count": 124, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "coloraxis": "coloraxis", "hovertemplate": "x: %{x}
y: %{y}
color: %{z}", "name": "0", "type": "heatmap", "x": [ "anger", "contempt", "disgust", "fear", "happiness", "neutral", "sadness", "surprise", "unknown" ], "xaxis": "x", "y": [ "anger", "contempt", "disgust", "fear", "happiness", "neutral", "sadness", "surprise", "unknown" ], "yaxis": "y", "z": [ [ 0.23842592592592593, 0, 0, 0, 0.23148148148148148, 0.4305555555555556, 0.016203703703703703, 0.08333333333333333, 0 ], [ 0, 0.0967741935483871, 0, 0, 0.2903225806451613, 0.6129032258064516, 0, 0, 0 ], [ 0.06451612903225806, 0, 0.1935483870967742, 0, 0.25806451612903225, 0.4838709677419355, 0, 0, 0 ], [ 0.034482758620689655, 0, 0, 0.12931034482758622, 0.1724137931034483, 0.4482758620689655, 0.02586206896551724, 0.1896551724137931, 0 ], [ 0.011643835616438357, 0, 0, 0, 0.7534246575342466, 0.1958904109589041, 0.012328767123287671, 0.02671232876712329, 0 ], [ 0.006704486848891181, 0.0005157297576070139, 0, 0.0005157297576070139, 0.06910778751933987, 0.8561113976276431, 0.03455389375966993, 0.032490974729241874, 0 ], [ 0.011235955056179775, 0, 0, 0.0016051364365971107, 0.18138041733547353, 0.6067415730337079, 0.17335473515248795, 0.025682182985553772, 0 ], [ 0.029411764705882353, 0, 0, 0, 0.09117647058823529, 0.3029411764705882, 0.007352941176470588, 0.5691176470588235, 0 ], [ 0.045454545454545456, 0, 0, 0, 0.13636363636363635, 0.5454545454545454, 0.09090909090909091, 0.045454545454545456, 0.13636363636363635 ] ] } ], "layout": { "coloraxis": { "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Confusion Matrix - Recall" }, "xaxis": { "anchor": "y", "constrain": "domain", "domain": [ 0, 1 ], "scaleanchor": "y", "side": "top", "title": { "text": "Predicted" } }, "yaxis": { "anchor": "x", "autorange": "reversed", "constrain": "domain", "domain": [ 0, 1 ], "title": { "text": "Actual" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "cm = confusion_matrix(y_test, clf.predict(X_test.squeeze()), labels=clf.classes_, normalize=\"true\")\n", "fig = px.imshow(cm, x=clf.classes_, y=clf.classes_, title=\"Confusion Matrix - Recall\")\n", "fig.update_xaxes(side=\"top\", title=\"Predicted\")\n", "fig.update_yaxes(title=\"Actual\")\n", "fig.show()\n", "fig.write_image(\"confusion_matrix_recall.svg\")" ] }, { "cell_type": "code", "execution_count": 125, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "False Positive Rate=%{x}
True Positive Rate=%{y}", "legendgroup": "", "line": { "color": "lightgrey", "dash": "dot" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "", "orientation": "v", "showlegend": false, "type": "scatter", "x": [ 0, 1 ], "xaxis": "x", "y": [ 0, 1 ], "yaxis": "y" }, { "name": "anger", "type": "scatter", "x": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0002039983680130559, 0.0002039983680130559, 0.0006119951040391676, 0.0008159934720522236, 0.0012239902080783353, 0.0014279885760913912, 0.0018359853121175031, 0.002039983680130559, 0.002243982048143615, 0.002243982048143615, 0.0024479804161566705, 0.0026519787841697267, 0.0032639738882088943, 0.003875968992248062, 0.00448796409628723, 0.006119951040391677, 0.006527947776417789, 0.006731946144430845, 0.008363933088535292, 0.009383924928600572, 0.011015911872705019, 0.011831905344757242, 0.013055895552835577, 0.014891880864953081, 0.015707874337005302, 0.018971848225214197, 0.020195838433292534, 0.021215830273357814, 0.02427580579355365, 0.02672378620971032, 0.029783761729906162, 0.031619747042023666, 0.03773969808241534, 0.04202366381068951, 0.04814361485108119, 0.05752753977968176, 0.06466748266013872, 0.07588739290085679, 0.08935128518971848, 0.10607915136678907, 0.12219502243982049, 0.142390860873113, 0.16360669114647083, 0.19298245614035087, 0.22031823745410037, 0.2658098735210118, 0.31476948184414527, 0.3729090167278662, 0.44104447164422683, 0.5203998368013056, 0.6144430844553244, 0.7195022439820481, 0.8339453284373725, 0.9359445124439004, 1 ], "y": [ 0, 0.0023148148148148147, 0.004629629629629629, 0.009259259259259259, 0.016203703703703703, 0.020833333333333332, 0.027777777777777776, 0.03009259259259259, 0.034722222222222224, 0.037037037037037035, 0.05092592592592592, 0.06944444444444445, 0.07407407407407407, 0.0763888888888889, 0.08564814814814815, 0.09259259259259259, 0.09953703703703703, 0.10416666666666667, 0.11342592592592593, 0.11805555555555555, 0.12268518518518519, 0.125, 0.125, 0.13425925925925927, 0.1412037037037037, 0.14351851851851852, 0.14351851851851852, 0.14814814814814814, 0.1550925925925926, 0.1712962962962963, 0.18055555555555555, 0.18287037037037038, 0.19212962962962962, 0.19907407407407407, 0.2037037037037037, 0.20601851851851852, 0.2175925925925926, 0.2222222222222222, 0.2337962962962963, 0.2337962962962963, 0.23842592592592593, 0.24537037037037038, 0.25462962962962965, 0.2638888888888889, 0.2777777777777778, 0.2847222222222222, 0.2986111111111111, 0.3055555555555556, 0.31712962962962965, 0.3263888888888889, 0.33796296296296297, 0.3472222222222222, 0.36574074074074076, 0.3888888888888889, 0.39814814814814814, 0.4097222222222222, 0.44212962962962965, 0.4583333333333333, 0.4861111111111111, 0.5162037037037037, 0.5370370370370371, 0.5555555555555556, 0.5787037037037037, 0.5972222222222222, 0.6550925925925926, 0.6967592592592593, 0.7569444444444444, 0.8101851851851852, 0.8703703703703703, 0.8958333333333334, 0.9236111111111112, 0.9583333333333334, 0.9814814814814815, 1 ] }, { "name": "contempt", "type": "scatter", "x": [ 0, 0, 0, 0.00018857250612860644, 0.00018857250612860644, 0.00018857250612860644, 0.0005657175183858194, 0.0016971525551574581, 0.003017160098057703, 0.0035828776164435225, 0.004714312653215161, 0.006222892702244013, 0.008108617763530078, 0.013011502922873844, 0.021120120686403922, 0.03564020365830662, 0.059966056948896854, 0.12822930416745237, 0.3043560248915708, 1 ], "y": [ 0, 0.03225806451612903, 0.06451612903225806, 0.06451612903225806, 0.0967741935483871, 0.16129032258064516, 0.16129032258064516, 0.16129032258064516, 0.16129032258064516, 0.16129032258064516, 0.16129032258064516, 0.16129032258064516, 0.16129032258064516, 0.16129032258064516, 0.1935483870967742, 0.22580645161290322, 0.3225806451612903, 0.41935483870967744, 0.5806451612903226, 1 ] }, { "name": "disgust", "type": "scatter", "x": [ 0, 0, 0, 0, 0.00018857250612860644, 0.00018857250612860644, 0.0013200075429002452, 0.002074297567414671, 0.0026400150858004903, 0.0035828776164435225, 0.005280030171600981, 0.007731472751272865, 0.010560060343201961, 0.013954365453516877, 0.01810296058834622, 0.028285875919290968, 0.04525740147086555, 0.07674900999434282, 0.13954365453516876, 0.3049217424099566, 1 ], "y": [ 0, 0.03225806451612903, 0.12903225806451613, 0.1935483870967742, 0.1935483870967742, 0.25806451612903225, 0.25806451612903225, 0.25806451612903225, 0.25806451612903225, 0.25806451612903225, 0.2903225806451613, 0.2903225806451613, 0.2903225806451613, 0.2903225806451613, 0.2903225806451613, 0.2903225806451613, 0.3225806451612903, 0.3225806451612903, 0.3870967741935484, 0.5161290322580645, 1 ] }, { "name": "fear", "type": "scatter", "x": [ 0, 0, 0, 0, 0, 0, 0, 0.0003832886163280951, 0.0003832886163280951, 0.0011498658489842851, 0.0011498658489842851, 0.0015331544653123803, 0.0017247987734764277, 0.002491376006132618, 0.0034495975469528554, 0.0045994633959371405, 0.006899195093905711, 0.008240705251054043, 0.009965504024530471, 0.013031812955155231, 0.01686469911843618, 0.022039095438865466, 0.028363357608279034, 0.0346876197776926, 0.046186278267535456, 0.06305097738597164, 0.08681487159831353, 0.11345343043311613, 0.15619011115369874, 0.21636642391720967, 0.3049060942889996, 0.4350325795323879, 0.6435415868148716, 1 ], "y": [ 0, 0.017241379310344827, 0.07758620689655173, 0.10344827586206896, 0.11206896551724138, 0.12931034482758622, 0.13793103448275862, 0.13793103448275862, 0.14655172413793102, 0.16379310344827586, 0.1724137931034483, 0.1896551724137931, 0.19827586206896552, 0.19827586206896552, 0.20689655172413793, 0.20689655172413793, 0.21551724137931033, 0.22413793103448276, 0.22413793103448276, 0.2413793103448276, 0.25862068965517243, 0.27586206896551724, 0.28448275862068967, 0.3017241379310345, 0.3448275862068966, 0.3879310344827586, 0.4224137931034483, 0.4827586206896552, 0.5172413793103449, 0.6206896551724138, 0.75, 0.8448275862068966, 0.9051724137931034, 1 ] }, { "name": "happiness", "type": "scatter", "x": [ 0, 0, 0.0002581311306143521, 0.0002581311306143521, 0.0007743933918430562, 0.0010325245224574084, 0.0015487867836861124, 0.002065049044914817, 0.0023231801755291687, 0.002581311306143521, 0.002581311306143521, 0.002581311306143521, 0.002839442436757873, 0.0038719669592152815, 0.004646360351058337, 0.004646360351058337, 0.004646360351058337, 0.005678884873515746, 0.006453278265358802, 0.0074858027878162104, 0.008260196179659268, 0.009034589571502324, 0.010583376355188436, 0.010841507485802787, 0.011615900877645843, 0.0123902942694889, 0.012906556530717605, 0.014971605575632421, 0.016520392359318535, 0.017811048012390293, 0.01987609705730511, 0.020908621579762518, 0.021424883840991223, 0.022715539494062985, 0.02348993288590604, 0.024264326277749097, 0.02607124419204956, 0.02710376871450697, 0.028652555498193084, 0.030459473412493547, 0.031233866804336603, 0.03252452245740836, 0.03536396489416624, 0.037945276200309755, 0.03949406298399587, 0.040268456375838924, 0.04155911202891069, 0.04336602994321115, 0.04568921011874032, 0.04827052142488384, 0.05162622612287042, 0.05420753742901394, 0.058079504388229224, 0.060918946824987094, 0.06375838926174497, 0.06659783169850284, 0.06866288074341766, 0.07098606091894683, 0.07356737222509034, 0.07769747031491998, 0.08182756840474961, 0.0867320598864223, 0.09034589571502323, 0.09473412493546722, 0.09989674754775425, 0.10325245224574084, 0.10764068146618483, 0.11590087764584409, 0.12132163138874548, 0.12700051626226122, 0.13319566339700567, 0.14042333505420754, 0.14713474445018068, 0.156169334021683, 0.1644295302013423, 0.17268972638100155, 0.18198244708311823, 0.1933402168301497, 0.2057305110996386, 0.21889519876097058, 0.23154362416107382, 0.24754775425916364, 0.2638100154878678, 0.2798141455859577, 0.2947857511615901, 0.3141455859576665, 0.3335054207537429, 0.35389778007227674, 0.38229220443985545, 0.408363448631905, 0.43469282395456893, 0.4692823954568921, 0.5012906556530717, 0.5451729478575116, 0.5890552400619514, 0.6381001548786783, 0.6892101187403201, 0.7449664429530202, 0.8100154878678368, 0.8822922044398555, 0.9509550851832731, 1 ], "y": [ 0, 0.004794520547945206, 0.023287671232876714, 0.038356164383561646, 0.056164383561643834, 0.07328767123287672, 0.09246575342465753, 0.11643835616438356, 0.13767123287671232, 0.1541095890410959, 0.17602739726027397, 0.19383561643835617, 0.21095890410958903, 0.22534246575342465, 0.23835616438356164, 0.2547945205479452, 0.2705479452054795, 0.28013698630136985, 0.2945205479452055, 0.3061643835616438, 0.31575342465753425, 0.32945205479452055, 0.3445205479452055, 0.3595890410958904, 0.3726027397260274, 0.38082191780821917, 0.3972602739726027, 0.40342465753424656, 0.4089041095890411, 0.41575342465753423, 0.4273972602739726, 0.436986301369863, 0.4520547945205479, 0.4657534246575342, 0.47534246575342465, 0.48424657534246573, 0.4958904109589041, 0.5082191780821917, 0.5184931506849315, 0.5287671232876713, 0.541095890410959, 0.552054794520548, 0.5561643835616439, 0.5595890410958904, 0.5678082191780822, 0.5808219178082191, 0.5924657534246576, 0.6013698630136987, 0.6089041095890411, 0.6171232876712329, 0.6287671232876713, 0.6383561643835617, 0.6458904109589041, 0.6506849315068494, 0.6616438356164384, 0.6671232876712329, 0.673972602739726, 0.6801369863013699, 0.689041095890411, 0.6965753424657535, 0.7068493150684931, 0.7123287671232876, 0.7171232876712329, 0.7232876712328767, 0.7315068493150685, 0.7397260273972602, 0.7452054794520548, 0.7520547945205479, 0.7623287671232877, 0.7691780821917809, 0.7753424657534247, 0.7856164383561643, 0.7945205479452054, 0.802054794520548, 0.8089041095890411, 0.8171232876712329, 0.8267123287671233, 0.8376712328767123, 0.8431506849315068, 0.8541095890410959, 0.8650684931506849, 0.8705479452054794, 0.8815068493150685, 0.8883561643835617, 0.8972602739726028, 0.9034246575342466, 0.9116438356164384, 0.9198630136986301, 0.9294520547945205, 0.9376712328767123, 0.947945205479452, 0.958904109589041, 0.963013698630137, 0.9684931506849315, 0.9767123287671233, 0.9828767123287672, 0.9883561643835617, 0.9917808219178083, 0.9952054794520548, 0.9972602739726028, 0.9993150684931507, 1 ] }, { "name": "neutral", "type": "scatter", "x": [ 0, 0, 0, 0, 0, 0, 0, 0, 0.0002945508100147275, 0.0014727540500736377, 0.002061855670103093, 0.00235640648011782, 0.003240058910162003, 0.00471281296023564, 0.006480117820324006, 0.008836524300441826, 0.009720176730486009, 0.012371134020618556, 0.013254786450662739, 0.015905743740795286, 0.01796759941089838, 0.021207658321060384, 0.02533136966126657, 0.03004418262150221, 0.033873343151693665, 0.03858615611192931, 0.04477172312223859, 0.048600883652430045, 0.05419734904270987, 0.05949926362297496, 0.06597938144329897, 0.07187039764359351, 0.07717231222385862, 0.08306332842415316, 0.0910162002945508, 0.10279823269513991, 0.11251840942562592, 0.11899852724594992, 0.1272459499263623, 0.13932253313696613, 0.14904270986745213, 0.15964653902798231, 0.17025036818851252, 0.18055964653902798, 0.18792341678939617, 0.19764359351988217, 0.206480117820324, 0.21561119293078057, 0.22503681885125185, 0.23446244477172312, 0.24477172312223858, 0.25537555228276876, 0.26480117820324006, 0.275699558173785, 0.282179675994109, 0.29013254786450665, 0.3004418262150221, 0.3089837997054492, 0.31752577319587627, 0.32430044182621504, 0.3328424153166421, 0.3399116347569956, 0.34963181148748157, 0.35670103092783506, 0.3670103092783505, 0.3764359351988218, 0.3867452135493373, 0.3949926362297496, 0.40471281296023565, 0.41502209131075113, 0.42209131075110456, 0.43122238586156114, 0.442120765832106, 0.44860088365243006, 0.4592047128129602, 0.4703976435935199, 0.4810014727540501, 0.49543446244477174, 0.5057437407952872, 0.5166421207658322, 0.5325478645066274, 0.5452135493372606, 0.5575846833578793, 0.5699558173784978, 0.5885125184094256, 0.5994108983799705, 0.6147275405007364, 0.6297496318114875, 0.6506627393225332, 0.6783505154639176, 0.7078055964653903, 0.7443298969072165, 0.7849779086892489, 0.8318114874815906, 0.9083946980854197, 1 ], "y": [ 0, 0.0010314595152140279, 0.0030943785456420837, 0.0036101083032490976, 0.0046415678184631255, 0.008767405879319236, 0.010314595152140279, 0.012893243940175348, 0.019082001031459517, 0.028365136668385766, 0.033522434244455904, 0.0407426508509541, 0.04951005673027334, 0.06549767921609077, 0.07323362558019597, 0.08818978855079938, 0.10159876224858175, 0.11191335740072202, 0.12532233109850438, 0.13976276431150078, 0.15317173800928313, 0.16915936049510058, 0.18772563176895307, 0.20629190304280556, 0.22279525528623, 0.2439401753481176, 0.2619907168643631, 0.28313563692625066, 0.30582774626095927, 0.31975244971634864, 0.34244455905105725, 0.36204228984012377, 0.37493553378029915, 0.3965961835997937, 0.4151624548736462, 0.43063434760185665, 0.44971634863331617, 0.46828261990716863, 0.4847859721505931, 0.5090252707581228, 0.5286230015471892, 0.5492521918514698, 0.5673027333677153, 0.591026302217638, 0.6126869520371325, 0.6322846828261991, 0.6518824136152656, 0.6740587931923672, 0.6915936049510056, 0.7101598762248582, 0.7307890665291388, 0.7478081485301702, 0.7596699329551315, 0.7756575554409489, 0.7875193398659103, 0.8060856111397627, 0.815368746776689, 0.8236204228984012, 0.8421866941722538, 0.850438370293966, 0.8586900464156781, 0.8684889118102115, 0.8834450747808148, 0.890149561629706, 0.8953068592057761, 0.9014956162970603, 0.9092315626611656, 0.9164517792676637, 0.9216090768437338, 0.9283135636926251, 0.9350180505415162, 0.9391438886023724, 0.9443011861784425, 0.9489427539969056, 0.9525528623001547, 0.9571944301186178, 0.961835997937081, 0.9638989169675091, 0.9654461062403301, 0.9675090252707581, 0.9695719443011862, 0.9716348633316142, 0.9747292418772563, 0.9773078906652913, 0.9804022692109334, 0.9819494584837545, 0.9824651882413615, 0.9840123775141826, 0.9865910263022176, 0.9896854048478597, 0.9922640536358948, 0.9953584321815369, 0.9953584321815369, 0.9979370809695719, 0.998968540484786, 1 ] }, { "name": "sadness", "type": "scatter", "x": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0004245383145828911, 0.0006368074718743367, 0.0006368074718743367, 0.0006368074718743367, 0.0006368074718743367, 0.0008490766291657822, 0.0008490766291657822, 0.0008490766291657822, 0.0008490766291657822, 0.0008490766291657822, 0.0010613457864572277, 0.0014858841010401188, 0.002334960730205901, 0.0025472298874973467, 0.0031840373593716833, 0.003396306516663129, 0.0036085756739545746, 0.004245383145828911, 0.006792613033326258, 0.008915304606240713, 0.010825727021863723, 0.011462534493738059, 0.013160687752069624, 0.013585226066652516, 0.014646571853109743, 0.015920186796858415, 0.018679685841647208, 0.021651454043727446, 0.02334960730205901, 0.025047760560390576, 0.027807259605179366, 0.030779027807259607, 0.03459987263850563, 0.04118021651454044, 0.04542559966036935, 0.04945871364890681, 0.05540225005306729, 0.06283167055826788, 0.07111016769263426, 0.0764168966249204, 0.085756739545744, 0.09573338993844195, 0.10549777117384844, 0.1169603056675865, 0.1290596476331989, 0.14328168117172574, 0.16047548291233285, 0.18042878369772872, 0.20399066015707917, 0.22776480577372107, 0.257270218637232, 0.28592655487157714, 0.31713012099341964, 0.3515177244746338, 0.39460836340479727, 0.4347272341328805, 0.47675652727658674, 0.5281256633411165, 0.5816174909785609, 0.64168966249204, 0.7032477181065592, 0.7633198896200382, 0.8210571004033114, 0.8853746550626194, 0.9426873275313097, 1 ], "y": [ 0, 0.0032102728731942215, 0.004815409309791332, 0.009630818619582664, 0.011235955056179775, 0.01765650080256822, 0.019261637239165328, 0.02247191011235955, 0.024077046548956663, 0.027287319422150885, 0.033707865168539325, 0.04333868378812199, 0.04654895666131621, 0.052969502407704656, 0.05778491171749599, 0.06581059390048154, 0.06741573033707865, 0.07062600321027288, 0.0754414125200642, 0.07704654895666131, 0.08667736757624397, 0.09309791332263243, 0.09309791332263243, 0.09309791332263243, 0.09309791332263243, 0.09470304975922954, 0.09470304975922954, 0.09630818619582665, 0.10112359550561797, 0.10112359550561797, 0.11396468699839486, 0.12680577849117175, 0.13001605136436598, 0.13643659711075443, 0.13964686998394862, 0.15248796147672553, 0.15569823434991975, 0.15730337078651685, 0.1637239165329053, 0.17174959871589085, 0.1781701444622793, 0.19101123595505617, 0.20385232744783308, 0.20706260032102727, 0.21348314606741572, 0.2231139646869984, 0.23595505617977527, 0.2504012841091493, 0.27608346709470305, 0.2857142857142857, 0.30337078651685395, 0.33226324237560195, 0.3467094703049759, 0.36757624398073835, 0.39807383627608345, 0.42857142857142855, 0.4606741573033708, 0.48314606741573035, 0.507223113964687, 0.5296950240770465, 0.5489566613162119, 0.5810593900481541, 0.5987158908507223, 0.6276083467094703, 0.6581059390048154, 0.6837881219903692, 0.7255216693418941, 0.7544141252006421, 0.7881219903691814, 0.8202247191011236, 0.8619582664526485, 0.8956661316211878, 0.9149277688603531, 0.9438202247191011, 0.9630818619582665, 0.9839486356340289, 0.9951845906902087, 1 ] }, { "name": "surprise", "type": "scatter", "x": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.00021486892995272884, 0.0004297378599054577, 0.0004297378599054577, 0.0006446067898581865, 0.0006446067898581865, 0.0006446067898581865, 0.0008594757198109154, 0.0008594757198109154, 0.0008594757198109154, 0.001289213579716373, 0.0015040825096691017, 0.0017189514396218307, 0.0019338203695745595, 0.002793296089385475, 0.002793296089385475, 0.0030081650193382035, 0.0040825096691018475, 0.004941985388912763, 0.004941985388912763, 0.0053717232488182205, 0.0058014611087236784, 0.006016330038676407, 0.006446067898581865, 0.006875805758487323, 0.007950150408250967, 0.008165019338203695, 0.008594757198109154, 0.009454232917920068, 0.009883970777825527, 0.010313708637730984, 0.01095831542758917, 0.011817791147400086, 0.012247529007305543, 0.01289213579716373, 0.013966480446927373, 0.015255694026643748, 0.015470562956596476, 0.01675977653631285, 0.017834121186076492, 0.01847872797593468, 0.019338203695745595, 0.019767941555651054, 0.02191663085517834, 0.022776106574989255, 0.024280189084658357, 0.02556940266437473, 0.026643747314138374, 0.028577567683712935, 0.03094112591319295, 0.03330468414267297, 0.03545337344220026, 0.03824666953158573, 0.04061022776106575, 0.04254404813064031, 0.04555221314997851, 0.047700902449505804, 0.05156854318865492, 0.05500644606789858, 0.05951869359690589, 0.06446067898581866, 0.06940266437473142, 0.07391491190373872, 0.08079071766222604, 0.08551783412118608, 0.09110442629995702, 0.09798023205844435, 0.10550064460678986, 0.11388053287494629, 0.12204555221314999, 0.13107004727116459, 0.14331757627847014, 0.15900300816501933, 0.17533304684142673, 0.19058874086807048, 0.2058444348947142, 0.23227331327889988, 0.2617103566824237, 0.29329608938547486, 0.33175762784701335, 0.3760206274172755, 0.4230769230769231, 0.48667812634293084, 0.5620971207563387, 0.6504082509669102, 0.7556940266437473, 0.8725827245380318, 1 ], "y": [ 0, 0.010294117647058823, 0.011764705882352941, 0.014705882352941176, 0.027941176470588237, 0.03235294117647059, 0.03823529411764706, 0.04264705882352941, 0.052941176470588235, 0.0661764705882353, 0.07647058823529412, 0.08529411764705883, 0.09117647058823529, 0.10441176470588236, 0.11470588235294117, 0.125, 0.13088235294117648, 0.13970588235294118, 0.15, 0.16176470588235295, 0.17058823529411765, 0.18235294117647058, 0.2, 0.21176470588235294, 0.22058823529411764, 0.23088235294117648, 0.24705882352941178, 0.2514705882352941, 0.25588235294117645, 0.2676470588235294, 0.2823529411764706, 0.2911764705882353, 0.2985294117647059, 0.31029411764705883, 0.3220588235294118, 0.33088235294117646, 0.3352941176470588, 0.3397058823529412, 0.35, 0.3588235294117647, 0.36911764705882355, 0.37941176470588234, 0.38529411764705884, 0.3911764705882353, 0.40147058823529413, 0.4102941176470588, 0.4176470588235294, 0.42058823529411765, 0.4279411764705882, 0.4338235294117647, 0.43676470588235294, 0.4441176470588235, 0.45, 0.4602941176470588, 0.47058823529411764, 0.47205882352941175, 0.47794117647058826, 0.48823529411764705, 0.5, 0.5029411764705882, 0.5117647058823529, 0.5235294117647059, 0.5323529411764706, 0.5397058823529411, 0.55, 0.5558823529411765, 0.5632352941176471, 0.5705882352941176, 0.5794117647058824, 0.5955882352941176, 0.6073529411764705, 0.6191176470588236, 0.6338235294117647, 0.65, 0.6647058823529411, 0.6779411764705883, 0.6911764705882353, 0.7, 0.7102941176470589, 0.7161764705882353, 0.7220588235294118, 0.7338235294117647, 0.7426470588235294, 0.7617647058823529, 0.775, 0.7867647058823529, 0.8, 0.8117647058823529, 0.8191176470588235, 0.8397058823529412, 0.8588235294117647, 0.8676470588235294, 0.8808823529411764, 0.9029411764705882, 0.9235294117647059, 0.9352941176470588, 0.9529411764705882, 0.9632352941176471, 0.9691176470588235, 0.975, 0.9882352941176471, 1 ] }, { "name": "unknown", "type": "scatter", "x": [ 0, 0, 0, 0.0007530120481927711, 0.0013177710843373493, 0.0015060240963855422, 0.0018825301204819277, 0.0026355421686746986, 0.0028237951807228916, 0.003953313253012048, 0.006400602409638554, 0.008847891566265061, 0.012989457831325301, 0.021649096385542167, 0.03765060240963856, 0.06532379518072289, 0.13328313253012047, 0.3205948795180723, 1 ], "y": [ 0, 0.045454545454545456, 0.13636363636363635, 0.13636363636363635, 0.13636363636363635, 0.13636363636363635, 0.13636363636363635, 0.13636363636363635, 0.13636363636363635, 0.13636363636363635, 0.13636363636363635, 0.18181818181818182, 0.18181818181818182, 0.18181818181818182, 0.18181818181818182, 0.3181818181818182, 0.36363636363636365, 0.5909090909090909, 1 ] } ], "layout": { "legend": { "tracegroupgap": 0 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "ROC Curve" }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "False Positive Rate" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "True Positive Rate" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# plot roc curve using plotly express\n", "from cv2 import line\n", "from sklearn.metrics import roc_curve, auc\n", "\n", "y_score = clf.predict_proba(X_test.squeeze())\n", "fpr = dict()\n", "tpr = dict()\n", "roc_auc = dict()\n", "for i, class_name in enumerate(clf.classes_):\n", " fpr[i], tpr[i], _ = roc_curve(y_test == clf.classes_[i], y_score[:, i])\n", " roc_auc[class_name] = auc(fpr[i], tpr[i])\n", "\n", "# plot roc curve\n", "fig = px.line(\n", " x=[0, 1],\n", " y=[0, 1],\n", " title=\"ROC Curve\",\n", " labels=dict(x=\"False Positive Rate\", y=\"True Positive Rate\"),\n", " color_discrete_sequence=[\"lightgrey\"],\n", " line_dash_sequence=[\"dot\"],\n", ")\n", "for i in range(len(clf.classes_)):\n", " fig.add_scatter(\n", " x=fpr[i],\n", " y=tpr[i],\n", " name=f\"{clf.classes_[i]}\",\n", " )\n", "fig.show()\n", "fig.write_image(\"roc_curve.svg\")" ] }, { "cell_type": "code", "execution_count": 126, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'anger': 0.7750016055427112,\n", " 'contempt': 0.6764034964992427,\n", " 'disgust': 0.6472994592227163,\n", " 'fear': 0.7823449333209975,\n", " 'happiness': 0.9045211844329247,\n", " 'neutral': 0.8308803636084676,\n", " 'sadness': 0.7416447554696789,\n", " 'surprise': 0.8969975226876312,\n", " 'unknown': 0.6664199411281488}" ] }, "execution_count": 126, "metadata": {}, "output_type": "execute_result" } ], "source": [ "roc_auc" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.9" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }