mirror of
https://github.com/ArthurDanjou/ArtStudies.git
synced 2026-01-14 13:54:06 +01:00
209 lines
4.8 KiB
Plaintext
209 lines
4.8 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "8226e658",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import pandas as pd"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"id": "7e95cb09",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"application/vnd.microsoft.datawrangler.viewer.v0+json": {
|
|
"columns": [
|
|
{
|
|
"name": "index",
|
|
"rawType": "int64",
|
|
"type": "integer"
|
|
},
|
|
{
|
|
"name": "X1",
|
|
"rawType": "float64",
|
|
"type": "float"
|
|
},
|
|
{
|
|
"name": "X2",
|
|
"rawType": "float64",
|
|
"type": "float"
|
|
},
|
|
{
|
|
"name": "Y",
|
|
"rawType": "float64",
|
|
"type": "float"
|
|
}
|
|
],
|
|
"ref": "018727a2-2342-424f-8395-021f40817c5a",
|
|
"rows": [
|
|
[
|
|
"0",
|
|
"-0.8363543",
|
|
"4.520502",
|
|
"-19.868094121443526"
|
|
],
|
|
[
|
|
"1",
|
|
"0.4020083",
|
|
"3.252834",
|
|
"-10.46598545005849"
|
|
],
|
|
[
|
|
"2",
|
|
"-0.2492138",
|
|
"3.610425",
|
|
"-12.91499193423918"
|
|
],
|
|
[
|
|
"3",
|
|
"-0.6257167",
|
|
"4.58877",
|
|
"-20.67839639765537"
|
|
],
|
|
[
|
|
"4",
|
|
"-0.9899948",
|
|
"4.893924",
|
|
"-22.99404413854238"
|
|
]
|
|
],
|
|
"shape": {
|
|
"columns": 3,
|
|
"rows": 5
|
|
}
|
|
},
|
|
"text/html": [
|
|
"<div>\n",
|
|
"<style scoped>\n",
|
|
" .dataframe tbody tr th:only-of-type {\n",
|
|
" vertical-align: middle;\n",
|
|
" }\n",
|
|
"\n",
|
|
" .dataframe tbody tr th {\n",
|
|
" vertical-align: top;\n",
|
|
" }\n",
|
|
"\n",
|
|
" .dataframe thead th {\n",
|
|
" text-align: right;\n",
|
|
" }\n",
|
|
"</style>\n",
|
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|
" <thead>\n",
|
|
" <tr style=\"text-align: right;\">\n",
|
|
" <th></th>\n",
|
|
" <th>X1</th>\n",
|
|
" <th>X2</th>\n",
|
|
" <th>Y</th>\n",
|
|
" </tr>\n",
|
|
" </thead>\n",
|
|
" <tbody>\n",
|
|
" <tr>\n",
|
|
" <th>0</th>\n",
|
|
" <td>-0.836354</td>\n",
|
|
" <td>4.520502</td>\n",
|
|
" <td>-19.868094</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>1</th>\n",
|
|
" <td>0.402008</td>\n",
|
|
" <td>3.252834</td>\n",
|
|
" <td>-10.465985</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>2</th>\n",
|
|
" <td>-0.249214</td>\n",
|
|
" <td>3.610425</td>\n",
|
|
" <td>-12.914992</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>3</th>\n",
|
|
" <td>-0.625717</td>\n",
|
|
" <td>4.588770</td>\n",
|
|
" <td>-20.678396</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>4</th>\n",
|
|
" <td>-0.989995</td>\n",
|
|
" <td>4.893924</td>\n",
|
|
" <td>-22.994044</td>\n",
|
|
" </tr>\n",
|
|
" </tbody>\n",
|
|
"</table>\n",
|
|
"</div>"
|
|
],
|
|
"text/plain": [
|
|
" X1 X2 Y\n",
|
|
"0 -0.836354 4.520502 -19.868094\n",
|
|
"1 0.402008 3.252834 -10.465985\n",
|
|
"2 -0.249214 3.610425 -12.914992\n",
|
|
"3 -0.625717 4.588770 -20.678396\n",
|
|
"4 -0.989995 4.893924 -22.994044"
|
|
]
|
|
},
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"data = pd.read_excel(\"./data/data_pdp.xlsx\")\n",
|
|
"data.head()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"id": "4e9a9a97",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"def partial_dependant_function(data: pd.DataFrame, model: object, feature: str, grid_points: list) -> list:\n",
|
|
" \"\"\"Compute the Partial Dependence Plot (PDP) for a given feature.\"\"\"\n",
|
|
" pdp = []\n",
|
|
" for val in grid_points:\n",
|
|
" data_temp = data.copy()\n",
|
|
" data_temp[feature] = val\n",
|
|
" preds = model.predict(data_temp)\n",
|
|
" pdp.append(preds.mean())\n",
|
|
" return pdp"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "9553a1d8",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "studies",
|
|
"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.13.9"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|