1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
{
 "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
}