<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rajeswari Sridhar on Medium]]></title>
        <description><![CDATA[Stories by Rajeswari Sridhar on Medium]]></description>
        <link>https://medium.com/@rajisridhar0931?source=rss-139611122ef6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Rajeswari Sridhar on Medium</title>
            <link>https://medium.com/@rajisridhar0931?source=rss-139611122ef6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:57:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rajisridhar0931/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Predicting House Prices with Machine Learning]]></title>
            <link>https://medium.com/@rajisridhar0931/predicting-house-prices-with-machine-learning-de925bf7e5a1?source=rss-139611122ef6------2</link>
            <guid isPermaLink="false">https://medium.com/p/de925bf7e5a1</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Rajeswari Sridhar]]></dc:creator>
            <pubDate>Thu, 13 Nov 2025 04:34:45 GMT</pubDate>
            <atom:updated>2025-11-13T04:34:45.441Z</atom:updated>
            <content:encoded><![CDATA[<p>Predicting house prices is a classic data science problem and an excellent way to practice data exploration, feature engineering, and machine learning modeling. In this blog, I will walk you through my project where I predicted house prices using a dataset from Kaggle.</p><p><strong>Step 1: Understanding the Data</strong></p><p>First, we load the train and test datasets:</p><p>import pandas as pd</p><p>train = pd.read_csv(“train.csv”)<br>test = pd.read_csv(“test.csv”)</p><p>print(train.shape, test.shape)<br>train.head()</p><p>Train set: contains features and the target (SalePrice)</p><p>Test set: only features; we need to predict SalePrice</p><p><strong>Step 2: Exploratory Data Analysis (EDA)</strong><br>Target Distribution<br>import matplotlib.pyplot as plt<br>import seaborn as sns</p><p>sns.histplot(train[“SalePrice”], kde=True)<br>plt.title(“Distribution of SalePrice”)<br>plt.show()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nE1e1zmtIJqFQAlftKLRdQ.png" /></figure><p><strong>Observation: SalePrice is right-skewed. Most houses are lower-priced, with a few high-priced outliers.</strong></p><p>Numeric Features vs SalePrice<br>sns.scatterplot(x=’GrLivArea’, y=’SalePrice’, data=train)<br>plt.title(“GrLivArea vs SalePrice”)<br>plt.show()</p><p><strong>Observation: Houses with more living area (GrLivArea) tend to have higher prices.</strong></p><p>Other numeric relationships:</p><p>TotalBsmtSF (Basement area)</p><p>GarageCars (Number of cars in garage)</p><p>Categorical Features vs SalePrice<br>sns.boxplot(x=’Neighborhood’, y=’SalePrice’, data=train)<br>plt.xticks(rotation=90)<br>plt.title(“Neighborhood vs SalePrice”)<br>plt.show()</p><p><strong>Observation:Neighborhood and kitchen quality significantly affect house prices.</strong></p><p>Correlation Heatmap (Top Numeric Features)<br>num_cols = train.select_dtypes(include=’number’).columns<br>corr = train[num_cols].corr()[‘SalePrice’].sort_values(ascending=False)<br>top_features = corr.head(10).index</p><p>plt.figure(figsize=(8,6))<br>sns.heatmap(train[top_features].corr(), cmap=’coolwarm’, annot=True)<br>plt.title(“Top 10 Numeric Features Correlated with SalePrice”)<br>plt.show()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xRNEP2teheGPANAfAoXXWg.png" /></figure><p><strong>Step 3: Feature Selection<br>Numeric Features</strong></p><p>OverallQual, GrLivArea, GarageCars, TotalBsmtSF, 1stFlrSF, FullBath, YearBuilt</p><p><strong>Categorical Features</strong></p><p>Using Chi-square test, top categorical features most associated with SalePrice:</p><p>Neighborhood, ExterQual, KitchenQual, BsmtQual, GarageFinish, etc.</p><p>from scipy.stats import chi2_contingency</p><p>cat_cols = train.select_dtypes(exclude=np.number).columns<br>chi_results = []<br>for c in cat_cols:<br> contingency = pd.crosstab(train[c], pd.qcut(train[“SalePrice”], q=4))<br> chi2_stat, p, dof, ex = chi2_contingency(contingency)<br> chi_results.append((c, chi2_stat, p))<br>chi_df = pd.DataFrame(chi_results, columns=[“Feature”,”Chi2&quot;,”p_value”]).sort_values(“p_value”)<br>chi_df.head(10)</p><p><strong>Step 4: Handling Missing Values</strong></p><p>Numeric features: fill with median</p><p>Categorical features: fill with mode</p><p>train[‘TotalBsmtSF’].fillna(train[‘TotalBsmtSF’].median(), inplace=True)<br>train[‘BsmtQual’].fillna(train[‘BsmtQual’].mode()[0], inplace=True)</p><p><strong>Step 5: Preprocessing and Pipelines</strong></p><p>Prepare a machine learning pipeline:</p><p>from sklearn.compose import ColumnTransformer<br>from sklearn.pipeline import Pipeline<br>from sklearn.preprocessing import StandardScaler, OneHotEncoder<br>from sklearn.impute import SimpleImputer</p><p>num_cols = X.select_dtypes(include=’number’).columns<br>cat_cols = X.select_dtypes(exclude=’number’).columns</p><p>preprocessor = ColumnTransformer([<br> (“num”, Pipeline([<br> (‘imputer’, SimpleImputer(strategy=’median’)),<br> (‘scaler’, StandardScaler())<br> ]), num_cols),<br> <br> (“categorical”, Pipeline([<br> (‘imputer’, SimpleImputer(strategy=’most_frequent’)),<br> (‘onehot’, OneHotEncoder(handle_unknown=’ignore’, drop=’first’, sparse_output=False))<br> ]), cat_cols)<br>])</p><p><strong>Step 6: Model Training</strong><br><strong>1. Linear Regression</strong><br>from sklearn.linear_model import LinearRegression</p><p>lin_pipe = Pipeline([<br> (‘prep’, preprocessor),<br> (‘model’, LinearRegression())<br>])<br>lin_pipe.fit(X, y)</p><p><strong>Evaluate performance:</strong></p><p>from sklearn.metrics import mean_squared_error, r2_score<br>y_pred = lin_pipe.predict(X)<br>r2 = r2_score(y, y_pred)<br>rmse = np.sqrt(mean_squared_error(y, y_pred))<br>print(“R²:”, r2, “RMSE:”, rmse)</p><p><strong>2. SGD Regressor (Gradient Descent)</strong><br>from sklearn.linear_model import SGDRegressor</p><p>sgd_pipe = Pipeline([<br> (‘prep’, preprocessor),<br> (‘model’, SGDRegressor(loss=’squared_error’, max_iter=1000))<br>])<br>sgd_pipe.fit(X, y)</p><p><strong>Step 7: Predictions and Submission</strong><br>preds = lin_pipe.predict(X_test)<br>preds = np.clip(preds, 0, None) # Ensure no negative prices</p><p>submission = pd.DataFrame({‘Id’: test[‘Id’], ‘SalePrice’: preds})<br>submission.to_csv(“Submission_LR.csv”, index=False)</p><p><strong>Step 8: Model Saving</strong><br>import joblib<br>joblib.dump(lin_pipe, ‘houseprice_model.pkl’)</p><p><strong>Conclusion</strong></p><p>Top features influencing house price: OverallQual, GrLivArea, GarageCars, TotalBsmtSF, Neighborhood, KitchenQual</p><p>Linear Regression performs well on this dataset.</p><p>Using pipelines ensures preprocessing and modeling are clean and reproducible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de925bf7e5a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>