{"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":"# 1. Getting Data\nimport pandas as pd\n\n# Load the dataset\ndata = pd.read_csv('/kaggle/input/housing-data/house.csv')\n\n# Print the first few rows of the dataset\nprint(data.head())\n\n# 2. Visualize Data\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n# Visualize the distribution of the target variable (housing prices)\nsns.histplot(data['price'])\nplt.title('Distribution of Housing Prices')\nplt.xlabel('Price')\nplt.ylabel('Count')\nplt.show()\n\n# Visualize the relationship between different features and the target variable\nsns.pairplot(data, x_vars=['latitude', 'longitude', 'room_type'], y_vars=['price'], height=5)\nplt.title('Relationship between Features and Price')\nplt.show()\n\n# 4. Model Data (Regression)\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.metrics import mean_squared_error\n\n# Split the data into features (X) and target variable (y)\ndata = pd.get_dummies(data, columns=['room_type'])\n\n# Split the data into features (X) and target variable (y)\nX = data[['latitude', 'longitude', 'room_type_Entire home/apt', 'room_type_Private room', 'room_type_Shared room']]\ny = data['price']\n\n# Split the data into training and testing sets\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n\n# Create and train the linear regression model\nmodel = LinearRegression()\nmodel.fit(X_train, y_train)\n\n# Make predictions on the test set\ny_pred = model.predict(X_test)\n\n# Calculate the root mean squared error (RMSE)\nrmse = mean_squared_error(y_test, y_pred, squared=False)\nprint('Root Mean Squared Error:', rmse)\n\n# 5. Presentation of Results\n# Create visualizations to present the results\n\n# Scatter plot of actual prices vs. predicted prices\nplt.scatter(y_test, y_pred)\nplt.plot([min(y_test), max(y_test)], [min(y_test), max(y_test)], 'r--')\nplt.xlabel('Actual Price')\nplt.ylabel('Predicted Price')\nplt.title('Actual vs. Predicted Prices')\nplt.show()\n\n# Display the coefficients of the linear regression model\ncoefficients = pd.DataFrame({'Feature': X.columns, 'Coefficient': model.coef_})\nprint(coefficients)\n\n# Generate a summary report or slide deck summarizing the findings and conclusions","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-10-22T20:34:39.617013Z","iopub.execute_input":"2023-10-22T20:34:39.617363Z","iopub.status.idle":"2023-10-22T20:34:43.308932Z","shell.execute_reply.started":"2023-10-22T20:34:39.617335Z","shell.execute_reply":"2023-10-22T20:34:43.307837Z"},"trusted":true},"execution_count":null,"outputs":[]}]}