Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
13af166e8a |
6
.ipynb_checkpoints/Untitled-checkpoint.ipynb
Normal file
6
.ipynb_checkpoints/Untitled-checkpoint.ipynb
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"cells": [],
|
||||
"metadata": {},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
251
.ipynb_checkpoints/solution-checkpoint.ipynb
Normal file
251
.ipynb_checkpoints/solution-checkpoint.ipynb
Normal file
@ -0,0 +1,251 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import numpy as np\n",
|
||||
"from pathlib import Path\n",
|
||||
"import seaborn as sns\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import numpy as np\n",
|
||||
"from sklearn.linear_model import LinearRegression"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## TRENING"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"NAMES = [\"Price\",\"Mileage\",\"Year\",\"Brand\",\"EngineType\",\"EngineCapacity\"]\n",
|
||||
"TRAIN_BASE = pd.read_csv(\"train/train.tsv\", sep ='\\t', names=NAMES)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"Y_TRAIN = np.array(TRAIN_BASE[\"Price\"])\n",
|
||||
"X_TRAIN = np.array(TRAIN_BASE[[\"Mileage\",\"Year\",\"EngineCapacity\"]])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"MODEL = LinearRegression().fit(X_TRAIN,Y_TRAIN)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## DEV-0"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"NAMES = [\"Mileage\",\"Year\",\"Brand\",\"EngineType\",\"EngineCapacity\"]\n",
|
||||
"FILE_BASE = pd.read_csv(\"dev-0/in.tsv\", sep ='\\t', names=NAMES)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"X_TEST = np.array(FILE_BASE[[\"Mileage\",\"Year\",\"EngineCapacity\"]])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"Y_TEST = MODEL.predict(X_TEST)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"VALUES = np.array2string(Y_TEST, precision=5, separator='\\n',suppress_small=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"VALUES = VALUES.split(\".\\n\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"OUTFILE = open(\"dev-0/out.tsv\", \"w\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {
|
||||
"scrolled": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for x in VALUES:\n",
|
||||
" RESULT = x.replace(\" \",\"\")\n",
|
||||
" RESULT = RESULT.replace(\"[\",\"\")\n",
|
||||
" RESULT = RESULT.replace(\"]\",\"\")\n",
|
||||
" OUTFILE.write(str(RESULT)+\"\\n\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"OUTFILE.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## TEST A"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"NAMES = [\"Mileage\",\"Year\",\"Brand\",\"EngineType\",\"EngineCapacity\"]\n",
|
||||
"FILE_BASE = pd.read_csv(\"test-A/in.tsv\", sep ='\\t', names=NAMES)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"X_TEST = np.array(FILE_BASE[[\"Mileage\",\"Year\",\"EngineCapacity\"]])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"Y_TEST = MODEL.predict(X_TEST)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"VALUES = np.array2string(Y_TEST, precision=5, separator='\\n',suppress_small=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"VALUES = VALUES.split(\".\\n\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"OUTFILE = open(\"test-A/out.tsv\", \"w\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for x in VALUES:\n",
|
||||
" RESULT = x.replace(\" \",\"\").replace(\"[\",\"\").replace(\"]\",\"\")\n",
|
||||
" OUTFILE.write(str(RESULT) )"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"OUTFILE.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"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.8.5"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
1000
dev-0/out.tsv
Normal file
1000
dev-0/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
253
solution.ipynb
Normal file
253
solution.ipynb
Normal file
@ -0,0 +1,253 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import numpy as np\n",
|
||||
"from pathlib import Path\n",
|
||||
"import seaborn as sns\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import numpy as np\n",
|
||||
"from sklearn.linear_model import LinearRegression"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## TRENING"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"NAMES = [\"Price\",\"Mileage\",\"Year\",\"Brand\",\"EngineType\",\"EngineCapacity\"]\n",
|
||||
"TRAIN_BASE = pd.read_csv(\"train/train.tsv\", sep ='\\t', names=NAMES)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"Y_TRAIN = np.array(TRAIN_BASE[\"Price\"])\n",
|
||||
"X_TRAIN = np.array(TRAIN_BASE[[\"Mileage\",\"Year\",\"EngineCapacity\"]])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"MODEL = LinearRegression().fit(X_TRAIN,Y_TRAIN)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## DEV-0"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"NAMES = [\"Mileage\",\"Year\",\"Brand\",\"EngineType\",\"EngineCapacity\"]\n",
|
||||
"FILE_BASE = pd.read_csv(\"dev-0/in.tsv\", sep ='\\t', names=NAMES)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"X_TEST = np.array(FILE_BASE[[\"Mileage\",\"Year\",\"EngineCapacity\"]])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"Y_TEST = MODEL.predict(X_TEST)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"VALUES = np.array2string(Y_TEST, precision=5, separator='\\n',suppress_small=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"VALUES = VALUES.split(\".\\n\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"OUTFILE = open(\"dev-0/out.tsv\", \"w\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {
|
||||
"scrolled": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for x in VALUES:\n",
|
||||
" RESULT = x.replace(\" \",\"\")\n",
|
||||
" RESULT = RESULT.replace(\"[\",\"\")\n",
|
||||
" RESULT = RESULT.replace(\"]\",\"\")\n",
|
||||
" OUTFILE.write(str(RESULT))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"OUTFILE.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## TEST A"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"NAMES = [\"Mileage\",\"Year\",\"Brand\",\"EngineType\",\"EngineCapacity\"]\n",
|
||||
"FILE_BASE = pd.read_csv(\"test-A/in.tsv\", sep ='\\t', names=NAMES)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"X_TEST = np.array(FILE_BASE[[\"Mileage\",\"Year\",\"EngineCapacity\"]])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"Y_TEST = MODEL.predict(X_TEST)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"VALUES = np.array2string(Y_TEST, precision=5, separator='\\n',suppress_small=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"VALUES = VALUES.split(\".\\n\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"OUTFILE = open(\"test-A/out.tsv\", \"w\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for x in VALUES:\n",
|
||||
" RESULT = x.replace(\" \",\"\")\n",
|
||||
" RESULT = RESULT.replace(\"[\",\"\")\n",
|
||||
" RESULT = RESULT.replace(\"]\",\"\")\n",
|
||||
" OUTFILE.write(str(RESULT) )"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"OUTFILE.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"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.8.5"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
152
solution.py
Normal file
152
solution.py
Normal file
@ -0,0 +1,152 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
# In[1]:
|
||||
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
import seaborn as sns
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from sklearn.linear_model import LinearRegression
|
||||
|
||||
|
||||
# ## TRENING
|
||||
|
||||
# In[2]:
|
||||
|
||||
|
||||
NAMES = ["Price","Mileage","Year","Brand","EngineType","EngineCapacity"]
|
||||
TRAIN_BASE = pd.read_csv("train/train.tsv", sep ='\t', names=NAMES)
|
||||
|
||||
|
||||
# In[3]:
|
||||
|
||||
|
||||
Y_TRAIN = np.array(TRAIN_BASE["Price"])
|
||||
X_TRAIN = np.array(TRAIN_BASE[["Mileage","Year","EngineCapacity"]])
|
||||
|
||||
|
||||
# In[4]:
|
||||
|
||||
|
||||
MODEL = LinearRegression().fit(X_TRAIN,Y_TRAIN)
|
||||
|
||||
|
||||
# ## DEV-0
|
||||
|
||||
# In[5]:
|
||||
|
||||
|
||||
NAMES = ["Mileage","Year","Brand","EngineType","EngineCapacity"]
|
||||
FILE_BASE = pd.read_csv("dev-0/in.tsv", sep ='\t', names=NAMES)
|
||||
|
||||
|
||||
# In[6]:
|
||||
|
||||
|
||||
X_TEST = np.array(FILE_BASE[["Mileage","Year","EngineCapacity"]])
|
||||
|
||||
|
||||
# In[7]:
|
||||
|
||||
|
||||
Y_TEST = MODEL.predict(X_TEST)
|
||||
|
||||
|
||||
# In[8]:
|
||||
|
||||
|
||||
VALUES = np.array2string(Y_TEST, precision=5, separator='\n',suppress_small=True)
|
||||
|
||||
|
||||
# In[9]:
|
||||
|
||||
|
||||
VALUES = VALUES.split(".\n")
|
||||
|
||||
|
||||
# In[10]:
|
||||
|
||||
|
||||
OUTFILE = open("dev-0/out.tsv", "w")
|
||||
|
||||
|
||||
# In[11]:
|
||||
|
||||
|
||||
for x in VALUES:
|
||||
RESULT = x.replace(" ","")
|
||||
RESULT = RESULT.replace("[","")
|
||||
RESULT = RESULT.replace("]","")
|
||||
OUTFILE.write(str(RESULT))
|
||||
|
||||
|
||||
# In[12]:
|
||||
|
||||
|
||||
OUTFILE.close()
|
||||
|
||||
|
||||
# ## TEST A
|
||||
|
||||
# In[13]:
|
||||
|
||||
|
||||
NAMES = ["Mileage","Year","Brand","EngineType","EngineCapacity"]
|
||||
FILE_BASE = pd.read_csv("test-A/in.tsv", sep ='\t', names=NAMES)
|
||||
|
||||
|
||||
# In[14]:
|
||||
|
||||
|
||||
X_TEST = np.array(FILE_BASE[["Mileage","Year","EngineCapacity"]])
|
||||
|
||||
|
||||
# In[15]:
|
||||
|
||||
|
||||
Y_TEST = MODEL.predict(X_TEST)
|
||||
|
||||
|
||||
# In[16]:
|
||||
|
||||
|
||||
VALUES = np.array2string(Y_TEST, precision=5, separator='\n',suppress_small=True)
|
||||
|
||||
|
||||
# In[17]:
|
||||
|
||||
|
||||
VALUES = VALUES.split(".\n")
|
||||
|
||||
|
||||
# In[18]:
|
||||
|
||||
|
||||
OUTFILE = open("test-A/out.tsv", "w")
|
||||
|
||||
|
||||
# In[19]:
|
||||
|
||||
|
||||
for x in VALUES:
|
||||
RESULT = x.replace(" ","")
|
||||
RESULT = RESULT.replace("[","")
|
||||
RESULT = RESULT.replace("]","")
|
||||
OUTFILE.write(str(RESULT) )
|
||||
|
||||
|
||||
# In[20]:
|
||||
|
||||
|
||||
OUTFILE.close()
|
||||
|
||||
|
||||
# In[ ]:
|
||||
|
||||
|
||||
|
||||
|
1000
test-A/out.tsv
Normal file
1000
test-A/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user