{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":41880,"databundleVersionId":5677426,"sourceType":"competition"}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv\n\nfrom sklearn.datasets import load_wine\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input/'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2024-11-22T17:47:14.926981Z","iopub.execute_input":"2024-11-22T17:47:14.927441Z","iopub.status.idle":"2024-11-22T17:47:15.410989Z","shell.execute_reply.started":"2024-11-22T17:47:14.927403Z","shell.execute_reply":"2024-11-22T17:47:15.409715Z"},"_kg_hide-input":false},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!ls ../input/tlvmc-parkinsons-freezing-gait-prediction/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T18:11:41.224792Z","iopub.execute_input":"2024-12-09T18:11:41.225888Z","iopub.status.idle":"2024-12-09T18:11:42.40581Z","shell.execute_reply.started":"2024-12-09T18:11:41.225806Z","shell.execute_reply":"2024-12-09T18:11:42.404389Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def dataframe_info(dataframe):\n    \"\"\"\n    Функция для получения информации о датафрейме.\n    \"\"\"\n    # Вывод общей информации о датафрейме\n    print(\"Информация о датафрейме:\")\n    display(dataframe.info())\n    # Вывод статистической информации о числовых столбцах\n    print(\"\\nСтатистика по числовым столбцам:\")\n    display(dataframe.describe())\n    # Вывод информации о пропущенных значениях\n    print(\"\\nПропущенные значения:\")\n    print(dataframe.isnull().sum())\n    # Вывод первых 5 строк датафрейма\n    print(\"\\nПервые 5 строк датафрейма:\")\n    display(dataframe.head())\n    \ndef uninformative_features(df):\n    \"\"\"\n    Функция для определения неинформативных признаков в датафрейме.\n    \n    Признаки считаются неинформативными, если одно значение встречается более чем в 95%\n    случаев или если более 95% значений являются уникальными.\n    \"\"\"\n    uninformative_features = []\n    \n    for column in df.columns:\n        if df[column].nunique() == 1 or df[column].nunique() / df[column].count() > 0.95:\n            uninformative_features.append(column)\n    \n    if len(uninformative_features) > 0:\n        return uninformative_features\n    else:\n        return \"Неинформативных особенностей не обнаружено.\"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-22T17:47:15.412795Z","iopub.execute_input":"2024-11-22T17:47:15.413161Z","iopub.status.idle":"2024-11-22T17:47:15.421225Z","shell.execute_reply.started":"2024-11-22T17:47:15.413126Z","shell.execute_reply":"2024-11-22T17:47:15.419986Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Загрузка датасета\ndf = pd.read_csv('/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/subjects.csv')\n\n# Общий обзор сборного датасета\ndataframe_info(df)\n# Неинформативные признаки\nprint(f'Неинформативные признаки: {uninformative_features(df)}')\n\n# Вывод информации о структуре датасета\nprint(f'Количество признаков: {df.shape[1]}')\nprint(f'Количество объектов: {df.shape[0]}')\n\n# Определение типов признаков\ncategorical_features = df.select_dtypes(include=['object']).columns.tolist()\nnumerical_features = df.select_dtypes(include=['number']).columns.tolist()\n\nprint(f'Количество категориальных признаков: {len(categorical_features)}')\nprint(f'Количество численных признаков: {len(numerical_features)}')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-22T17:47:15.422783Z","iopub.execute_input":"2024-11-22T17:47:15.423268Z","iopub.status.idle":"2024-11-22T17:47:15.491104Z","shell.execute_reply.started":"2024-11-22T17:47:15.423219Z","shell.execute_reply":"2024-11-22T17:47:15.489972Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 1. График распределения по полу\nplt.figure(figsize=(8, 5))\nax = sns.countplot(data=df, x='Sex', palette='Set2')\n\n# Подсчет общего количества пациентов\ntotal = len(df)\n\n# Добавление процентного соотношения на график\nfor p in ax.patches:\n    percentage = f'{100 * p.get_height() / total:.1f}%'\n    x = p.get_x() + p.get_width() / 2\n    y = p.get_height()\n    ax.annotate(percentage, (x, y), ha='center', va='bottom')\n\nplt.title('Распределение по полу')\nplt.xlabel('Пол')\nplt.ylabel('Количество пациентов')\nplt.show()\n\n# 2. График распределения по возрасту\nplt.figure(figsize=(10, 6))\nsns.histplot(df['Age'], bins=20, kde=True, color='blue')\nplt.title('Распределение по возрасту')\nplt.xlabel('Возраст')\nplt.ylabel('Частота')\nplt.show()\n\n# 3. График распределения по факту приема препаратов (UPDRSIII_On и UPDRSIII_Off)\nplt.figure(figsize=(10, 5))\n\n# Создаем подграфики для ON и OFF\nplt.subplot(1, 2, 1)\nsns.histplot(df['UPDRSIII_On'], bins=20, kde=True, color='orange')\nplt.title('UPDRSIII (On)')\nplt.xlabel('Оценка UPDRSIII (On)')\nplt.ylabel('Частота')\n\nplt.subplot(1, 2, 2)\nsns.histplot(df['UPDRSIII_Off'], bins=20, kde=True, color='green')\nplt.title('UPDRSIII (Off)')\nplt.xlabel('Оценка UPDRSIII (Off)')\nplt.ylabel('Частота')\n\nplt.tight_layout()\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-22T17:47:15.493179Z","iopub.execute_input":"2024-11-22T17:47:15.493524Z","iopub.status.idle":"2024-11-22T17:47:16.908275Z","shell.execute_reply.started":"2024-11-22T17:47:15.493491Z","shell.execute_reply":"2024-11-22T17:47:16.90705Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(12, 8))\nsns.heatmap(df.corr(), annot=True)\nplt.title(\"Correlation Matrix for Train Data\")\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-22T17:47:16.909827Z","iopub.execute_input":"2024-11-22T17:47:16.910212Z","iopub.status.idle":"2024-11-22T17:47:16.991834Z","shell.execute_reply.started":"2024-11-22T17:47:16.910176Z","shell.execute_reply":"2024-11-22T17:47:16.990377Z"}},"outputs":[],"execution_count":null}]}