Skip to content

Commit d4c2b28

Browse files
committed
submodules converted to normal repo
1 parent a30bd70 commit d4c2b28

40 files changed

+57552
-3
lines changed

ml

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import pandas as pd\n",
10+
"import matplotlib.pyplot as plt\n",
11+
"import seaborn as sns\n",
12+
"import numpy as np"
13+
]
14+
},
15+
{
16+
"cell_type": "code",
17+
"execution_count": 4,
18+
"metadata": {},
19+
"outputs": [
20+
{
21+
"data": {
22+
"text/plain": [
23+
"count 1460.000000\n",
24+
"mean 180921.195890\n",
25+
"std 79442.502883\n",
26+
"min 34900.000000\n",
27+
"25% 129975.000000\n",
28+
"50% 163000.000000\n",
29+
"75% 214000.000000\n",
30+
"max 755000.000000\n",
31+
"Name: SalePrice, dtype: float64"
32+
]
33+
},
34+
"execution_count": 4,
35+
"metadata": {},
36+
"output_type": "execute_result"
37+
}
38+
],
39+
"source": [
40+
"df = pd.read_csv('train.csv')"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": null,
46+
"metadata": {},
47+
"outputs": [],
48+
"source": []
49+
}
50+
],
51+
"metadata": {
52+
"kernelspec": {
53+
"display_name": "Python 3",
54+
"language": "python",
55+
"name": "python3"
56+
},
57+
"language_info": {
58+
"codemirror_mode": {
59+
"name": "ipython",
60+
"version": 3
61+
},
62+
"file_extension": ".py",
63+
"mimetype": "text/x-python",
64+
"name": "python",
65+
"nbconvert_exporter": "python",
66+
"pygments_lexer": "ipython3",
67+
"version": "3.6.8"
68+
}
69+
},
70+
"nbformat": 4,
71+
"nbformat_minor": 2
72+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 32,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import pandas as pd\n",
10+
"import matplotlib.pyplot as plt\n",
11+
"import seaborn as sns\n",
12+
"import numpy as np\n",
13+
"from sklearn.model_selection import cross_val_score, train_test_split\n",
14+
"from sklearn.preprocessing import StandardScaler\n",
15+
"from sklearn.linear_model import RidgeCV, Ridge, LassoCV\n",
16+
"from scipy.stats import skew"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 42,
22+
"metadata": {},
23+
"outputs": [],
24+
"source": [
25+
"train = pd.read_csv('train.csv')\n",
26+
"# log transform target\n",
27+
"train['SalePrice'] = np.log1p(train['SalePrice'])\n",
28+
"test = pd.read_csv('test.csv')\n",
29+
"data = pd.concat((train.loc[:,'MSSubClass':'SaleCondition'],test.loc[:,'MSSubClass':'SaleCondition']))\n",
30+
"# log transform skewed numeric features\n",
31+
"num_features = data.dtypes[data.dtypes != 'object'].index\n",
32+
"skewed_feats = train[num_features].apply(lambda x: skew(x.dropna()))\n",
33+
"skewed_feats = skewed_feats[skewed_feats > 0.75].index\n",
34+
"data = pd.get_dummies(data)\n",
35+
"data = data.fillna(data.mean())\n",
36+
"data[skewed_feats] = np.log1p(data[skewed_feats])\n",
37+
"Xtrain = data[:train.shape[0]].values\n",
38+
"Xtest = data[train.shape[0]:].values\n",
39+
"y = train.SalePrice.values"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": 47,
45+
"metadata": {},
46+
"outputs": [],
47+
"source": [
48+
"def rmse_cv(model):\n",
49+
" rmse = np.sqrt(-cross_val_score(model, Xtrain, y, scoring='neg_mean_squared_error', cv = 5))\n",
50+
" return(rmse)"
51+
]
52+
},
53+
{
54+
"cell_type": "code",
55+
"execution_count": 53,
56+
"metadata": {},
57+
"outputs": [],
58+
"source": [
59+
"model_lasso = LassoCV(alphas = [1, 0.1, 0.001, 0.0005], cv = 5).fit(Xtrain, y)\n",
60+
"preds = np.expm1(model_lasso.predict(Xtest))\n",
61+
"solution = pd.DataFrame({\"id\":test.Id, \"SalePrice\":preds})\n",
62+
"solution.to_cs"
63+
]
64+
},
65+
{
66+
"cell_type": "code",
67+
"execution_count": null,
68+
"metadata": {},
69+
"outputs": [],
70+
"source": []
71+
}
72+
],
73+
"metadata": {
74+
"kernelspec": {
75+
"display_name": "Python 3",
76+
"language": "python",
77+
"name": "python3"
78+
},
79+
"language_info": {
80+
"codemirror_mode": {
81+
"name": "ipython",
82+
"version": 3
83+
},
84+
"file_extension": ".py",
85+
"mimetype": "text/x-python",
86+
"name": "python",
87+
"nbconvert_exporter": "python",
88+
"pygments_lexer": "ipython3",
89+
"version": "3.7.1"
90+
}
91+
},
92+
"nbformat": 4,
93+
"nbformat_minor": 2
94+
}

0 commit comments

Comments
 (0)