{ "cells": [ { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "from sklearn.datasets import make_regression\n", "from algorithms.utils import make_missing_mcar" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "# Generate random data with MCAR missingness\n", "X, y = make_regression(n_samples=500, n_features=20, n_informative=20, random_state=0)\n", "X_miss = make_missing_mcar(X, 0.5)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "# import the different available imputers: MissForest, DPP-MissForest, Deterministic DPP-Missforest,\\\n", "# MICE, DPP-MICE and Deterministic DPP-MICE\n", "\n", "from models.imputers import MissForest, DPPMissForest, DeterDPPMissForest\n", "from models.imputers import MiceRanger as MICE\n", "from models.imputers import DPPMiceRanger as DPPMICE\n", "from models.imputers import DeterDPPMiceRanger as DeterDPPMICE" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# run the determinisitc DPP MissForest imputer\n", "\n", "ddpp_mf = DeterDPPMissForest(batch_size=100, max_iter=5, n_estimators=10)\n", "\n", "X_imputed = ddpp_mf.fit_transform(X_miss)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3.12.0 ('dpp_imp')", "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.9.18" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "67bfe94fa74c97160cb3227fb064033b11c93431c39d85c0165f708bd8c58d70" } } }, "nbformat": 4, "nbformat_minor": 2 }