Skip to content

Instantly share code, notes, and snippets.

@ssugiyama
Created March 22, 2018 17:58
Show Gist options
  • Save ssugiyama/096c18094f515e5677fc533556e671b9 to your computer and use it in GitHub Desktop.
Save ssugiyama/096c18094f515e5677fc533556e671b9 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 180,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"from sklearn.linear_model import LinearRegression\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('shojisu_kaiten2.csv')"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"x = df.iloc[:, 0:8].values\n",
"y = df.iloc[:, 8].values.reshape(-1, 1)"
]
},
{
"cell_type": "code",
"execution_count": 315,
"metadata": {},
"outputs": [],
"source": [
"x0 = x[x[:, 0] == 0]\n",
"y0 = y[x[:, 0] == 0]\n",
"x1 = x[x[:, 0] == 1]\n",
"y1 = y[x[:, 0] == 1]"
]
},
{
"cell_type": "code",
"execution_count": 316,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import KFold\n",
"kfold = KFold(5, shuffle=True)\n",
"split = kfold.split(x1)\n",
"split = list(split)"
]
},
{
"cell_type": "code",
"execution_count": 281,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(42, 8)"
]
},
"execution_count": 281,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x0.shape"
]
},
{
"cell_type": "code",
"execution_count": 317,
"metadata": {},
"outputs": [],
"source": [
"def get_dataset(i, _x, _y):\n",
" return _x[split[i][0]], _y[split[i][0]], _x[split[i][1]], _y[split[i][1]]"
]
},
{
"cell_type": "code",
"execution_count": 275,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/lib/python3.6/site-packages/scipy/linalg/basic.py:223: RuntimeWarning: scipy.linalg.solve\n",
"Ill-conditioned matrix detected. Result is not guaranteed to be accurate.\n",
"Reciprocal condition number: 9.221851574618809e-20\n",
" ' condition number: {}'.format(rcond), RuntimeWarning)\n"
]
},
{
"data": {
"text/plain": [
"KernelRidge(alpha=0, coef0=1, degree=3, gamma=1e-07, kernel='linear',\n",
" kernel_params=None)"
]
},
"execution_count": 275,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn.kernel_ridge import KernelRidge\n",
"kr = KernelRidge(alpha=0, kernel='linear', gamma=0.0000001)\n",
"kr.fit(train_x, train_y)"
]
},
{
"cell_type": "code",
"execution_count": 96,
"metadata": {},
"outputs": [],
"source": [
"pred_y = kr.predict(test_x)"
]
},
{
"cell_type": "code",
"execution_count": 97,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"147994343.75911847"
]
},
"execution_count": 97,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.mean((test_y-pred_y)**2)"
]
},
{
"cell_type": "code",
"execution_count": 326,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"668407725.634\n",
"1079674157.31\n",
"804429459.959\n",
"2453905269.86\n",
"3136958186.14\n"
]
},
{
"data": {
"text/plain": [
"64065937.272935063"
]
},
"execution_count": 326,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pred_ys = []\n",
"for i in range(5):\n",
" train_x, train_y, test_x, test_y = get_dataset(i, x1, y1)\n",
" kr = KernelRidge(alpha=1000, kernel='poly', degree=2)\n",
" # kr = LinearRegression(normalize=False) \n",
" kr.fit(train_x, train_y)\n",
" pred_y = kr.predict(test_x)\n",
" print(np.mean((test_y-pred_y)**2))\n",
" pred_y = kr.predict(x1)\n",
" pred_ys.append(pred_y)\n",
"np.mean((np.mean(pred_ys, axis=0) - y1)**2)"
]
},
{
"cell_type": "code",
"execution_count": 327,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.collections.PathCollection at 0x11b36a400>"
]
},
"execution_count": 327,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAY8AAAD8CAYAAACPWyg8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAGKJJREFUeJzt3X+Q3PV93/Hn2yeBL07DgdEQOIlKHmvkEaW18A4W404nwTYSTgZUSlNoUhSHhmltzyRxRo1UOmNwmAFXndAywU6Y4kZ2XQuMqZCx3asMzGSmHTCnyiAEKJyhNjqwkQ2CJFaxJN79Yz8nVqdb3X1v925/3PMxs6Pvfr6f3f1+7wv72u/nx/cbmYkkSVW8o9MbIEnqPYaHJKkyw0OSVJnhIUmqzPCQJFVmeEiSKjM8JEmVGR6SpMoMD0lSZYs6vQFz5eyzz87ly5d3ejMkqafs3r37J5m5ZLp6fRsey5cvZ3R0tNObIUk9JSJ+MJN6NltJkiozPCRJlRkekqTKDA9JUmWGhySpsr4dbdUvduwZZ+vIfl46dJjzhgbZtG4VG9YMd3qzJC1whkcX27FnnC337+XwkWMAjB86zJb79wIYIJI6ymarLrZ1ZP/x4Jhw+Mgxto7s79AWSVKd4dHFXjp0uFK5JM0Xw6OLnTc0WKlckuZLy+EREe+MiO9GxBMRsS8ibi7lKyLisYgYi4h7IuK0Un56eT5W1i9veK8tpXx/RKxrKF9fysYiYnOr29wrNq1bxeDigRPKBhcPsGndqg5tkSTVtePM403g0sz8B8D7gfURsRb4HHB7Zr4XeA24vtS/HnitlN9e6hERq4FrgAuA9cDnI2IgIgaAO4HLgdXAtaVu39uwZphbr7qQ4aFBAhgeGuTWqy60s1xSx7U82iozE/ib8nRxeSRwKfDPS/k24CbgC8CVZRngPuBPIyJK+fbMfBN4ISLGgItLvbHMfB4gIraXuk+3uu29YMOaYcNCUtdpS59HOUP4HvAKsAv4PnAoM4+WKgeAiW/AYeBFgLL+deDdjeWTXtOsXJLUIW0Jj8w8lpnvB5ZSP1t4Xzvet6qIuCEiRiN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otlib.figure.Figure at 0x11b1b4d68>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.scatter(y0, (np.mean(pred_ys, axis=0))-y1)"
]
},
{
"cell_type": "code",
"execution_count": 312,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ -260.09582989, 1253.14800558, -623.23894678, -2100.5579591 ,\n",
" 2096.04043716, -1370.39462547, 70.471288 , 2061.18171313,\n",
" 210.27182744, -924.13772215, -1939.32669674, 109.78702867,\n",
" -215.15916274, 299.37574509, 63.85001686, -50.66809427,\n",
" 263.72994123, 671.91824185, 181.97868203, 715.65134855,\n",
" 36.57555645, 121.47592863, -280.29311864, 407.80912381,\n",
" 590.11777997, -2111.80080431, -845.19197236, 214.94107447,\n",
" -721.85117123, -840.04805598, 197.87427703, 2895.46423512,\n",
" -750.12368083, -536.93128617, 1168.90487671, -1788.80896264,\n",
" 786.72263237, -67.72275628, -2891.4098957 , 661.3327594 ])"
]
},
"execution_count": 312,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(((np.mean(pred_ys, axis=0))-y0).flatten())"
]
},
{
"cell_type": "code",
"execution_count": 270,
"metadata": {},
"outputs": [],
"source": [
"y0 = np.delete(y0, 39)"
]
},
{
"cell_type": "code",
"execution_count": 296,
"metadata": {},
"outputs": [],
"source": [
"x0 = np.delete(x0, 39, axis=0)\n",
"y0 = np.delete(y0, 39, axis=0)"
]
},
{
"cell_type": "code",
"execution_count": 287,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(42, 8)"
]
},
"execution_count": 287,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x0.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment