Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions mikhail_makarov/.idea/mikhail_makarov.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions mikhail_makarov/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions mikhail_makarov/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions mikhail_makarov/.idea/thriftCompiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

435 changes: 435 additions & 0 deletions mikhail_makarov/.idea/workspace.xml

Large diffs are not rendered by default.

353 changes: 353 additions & 0 deletions mikhail_makarov/.ipynb_checkpoints/lazy-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,353 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [],
"source": [
"import copy\n",
"\n",
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"from sklearn.metrics import accuracy_score\n",
"from sklearn.metrics import precision_score\n",
"from sklearn.metrics import recall_score"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"def generators_naive(positive, negative, sample):\n",
" \"\"\"\n",
" If there is an intersection in positve class element\n",
" and sample and this intersection does not belong to\n",
" intersection of sample with element of negative class\n",
" then this positive element votes for this sample.\n",
" After that calculate proportion of votes in positive\n",
" and negative classes and make decision.\n",
" \"\"\"\n",
" \n",
" \n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"DATA_PATH = 'data/tic-tac/'\n",
"\n",
"# for cross-validation\n",
"K = 10\n",
"\n",
"TARGET_COL = ['V10', 'TARGET']"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {},
"outputs": [],
"source": [
"def prepare_data(data):\n",
" data = data.rename(columns={col: 'class' for col in TARGET_COL})\n",
" \n",
" data = data.replace(to_replace='positive', value=1)\n",
" data = data.replace(to_replace='negative', value=0)\n",
" \n",
" y = data['class']\n",
" data = data.drop(columns=['class'])\n",
" cols = data.columns\n",
" \n",
" one_hot_data = pd.concat([pd.get_dummies(data[col], prefix=col, prefix_sep='_') for col in cols], axis=1)\n",
" \n",
" return one_hot_data.astype(bool), y"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [
{
"data": {
"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>V1_x</th>\n",
" <th>V2_b</th>\n",
" <th>V2_x</th>\n",
" <th>V3_o</th>\n",
" <th>V3_x</th>\n",
" <th>V4_b</th>\n",
" <th>V4_o</th>\n",
" <th>V4_x</th>\n",
" <th>V5_b</th>\n",
" <th>V5_o</th>\n",
" <th>...</th>\n",
" <th>V6_o</th>\n",
" <th>V6_x</th>\n",
" <th>V7_b</th>\n",
" <th>V7_o</th>\n",
" <th>V7_x</th>\n",
" <th>V8_b</th>\n",
" <th>V8_o</th>\n",
" <th>V9_b</th>\n",
" <th>V9_o</th>\n",
" <th>V9_x</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>...</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>...</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>...</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>...</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>4 rows × 22 columns</p>\n",
"</div>"
],
"text/plain": [
" V1_x V2_b V2_x V3_o V3_x V4_b V4_o V4_x V5_b V5_o ... \\\n",
"0 True False True False True False False True False True ... \n",
"1 True False True False True False False True False True ... \n",
"2 True False True False True False False True False True ... \n",
"3 True False True False True False False True False True ... \n",
"\n",
" V6_o V6_x V7_b V7_o V7_x V8_b V8_o V9_b V9_o V9_x \n",
"0 True False False False True False True False True False \n",
"1 True False False True False False True False False True \n",
"2 True False False True False True False True False False \n",
"3 True False True False False False True True False False \n",
"\n",
"[4 rows x 22 columns]"
]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"train = pd.read_csv('data/tic-tac/train0.csv')\n",
"test = pd.read_csv('data/tic-tac/test0.csv')\n",
"\n",
"train, train_y = prepare_data(train)\n",
"test, test_y = prepare_data(test)\n",
"\n",
"positive = train[train_y == 1]\n",
"negative = train[train_y == 0]\n",
"positive.head()"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[False False True False False True False False True False False True\n",
" False True False False True False False True False False False True\n",
" False True False False True]\n",
"[False False True False False True False False True False False True\n",
" False True False True False False False True False True False False\n",
" False True False False True]\n",
"[False False True False False True False False True False True False\n",
" False True False False False True False True False False False True\n",
" False True False False True]\n",
"[False False True False False True False False True False True False\n",
" False True False True False False False False True False True False\n",
" True False False False True]\n",
"[False False True False False True False False True True False False\n",
" False True False True False False False True False False True False\n",
" False False True False True]\n"
]
}
],
"source": [
"test['predicted'] = test.apply(generators_naive, axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i in range(K):\n",
" "
]
}
],
"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
}
Binary file not shown.
Loading