{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport os\nfrom sklearn.linear_model import Ridge\nfrom sklearn.impute import SimpleImputer\nfrom sklearn.pipeline import Pipeline\nfrom sklearn.preprocessing import StandardScaler","metadata":{"execution":{"iopub.status.busy":"2022-07-14T23:35:26.839522Z","iopub.execute_input":"2022-07-14T23:35:26.839899Z","iopub.status.idle":"2022-07-14T23:35:26.846375Z","shell.execute_reply.started":"2022-07-14T23:35:26.839867Z","shell.execute_reply":"2022-07-14T23:35:26.844928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.read_csv(\"../input/house-prices-advanced-regression-techniques/train.csv\")\ndf_test = pd.read_csv(\"../input/house-prices-advanced-regression-techniques/test.csv\")\ndf_total = pd.concat([df_train.drop(\"SalePrice\", axis = 1), df_test], axis = 0)\ndf_total = pd.get_dummies(df_total, drop_first = True)\ny_train = np.expand_dims(df_train[\"SalePrice\"].values, axis = 1)\nx_train = df_total.iloc[:1460,:]\nx_test = df_total.iloc[1460:,:]\nprint(x_train.shape)\nprint(y_train.shape)\nprint(x_test.shape)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T23:35:30.879257Z","iopub.execute_input":"2022-07-14T23:35:30.879648Z","iopub.status.idle":"2022-07-14T23:35:31.017811Z","shell.execute_reply.started":"2022-07-14T23:35:30.879617Z","shell.execute_reply":"2022-07-14T23:35:31.016547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"imp = SimpleImputer(missing_values = np.nan, strategy = \"mean\")\nscaler = StandardScaler()\nridge = Ridge(alpha = 0.1)\nsteps = [(\"imputation\", imp), (\"scaler\", scaler), (\"ridge\", ridge)]\npipeline = Pipeline(steps)\nparams = {'alpha' : [0.1, 0.2, 0.3, 0.4, 0.5]}","metadata":{"execution":{"iopub.status.busy":"2022-07-14T23:35:33.578214Z","iopub.execute_input":"2022-07-14T23:35:33.578615Z","iopub.status.idle":"2022-07-14T23:35:33.585514Z","shell.execute_reply.started":"2022-07-14T23:35:33.578583Z","shell.execute_reply":"2022-07-14T23:35:33.584464Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pipeline.fit(x_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T23:35:36.210696Z","iopub.execute_input":"2022-07-14T23:35:36.211077Z","iopub.status.idle":"2022-07-14T23:35:36.276641Z","shell.execute_reply.started":"2022-07-14T23:35:36.211046Z","shell.execute_reply":"2022-07-14T23:35:36.274863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = pipeline.predict(x_test)\nprint(predictions)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T23:35:38.651955Z","iopub.execute_input":"2022-07-14T23:35:38.652402Z","iopub.status.idle":"2022-07-14T23:35:38.681157Z","shell.execute_reply.started":"2022-07-14T23:35:38.652352Z","shell.execute_reply":"2022-07-14T23:35:38.679650Z"},"trusted":true},"execution_count":null,"outputs":[]}]}