<?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 Adebo Dolapo on Medium]]></title>
        <description><![CDATA[Stories by Adebo Dolapo on Medium]]></description>
        <link>https://medium.com/@theadedolapo?source=rss-f7f0629ac8fe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vMQFq6Al9qxMhdnp_Sjv4g.jpeg</url>
            <title>Stories by Adebo Dolapo on Medium</title>
            <link>https://medium.com/@theadedolapo?source=rss-f7f0629ac8fe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:21:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@theadedolapo/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[Building an Interactive Car Price Prediction App with Python and Gradio (Part 1)]]></title>
            <link>https://medium.com/@theadedolapo/building-an-interactive-car-price-prediction-app-with-python-and-gradio-part-1-5455842aed9c?source=rss-f7f0629ac8fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/5455842aed9c</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[gradio]]></category>
            <category><![CDATA[car-price-predictions]]></category>
            <category><![CDATA[hugging-face]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Adebo Dolapo]]></dc:creator>
            <pubDate>Thu, 17 Apr 2025 20:51:52 GMT</pubDate>
            <atom:updated>2025-04-17T20:51:52.650Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building an Interactive Car Price Prediction App with Python and Gradio(Part 1)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*96TQUgmnef7ZVav_QBrlsw.jpeg" /></figure><h3><strong>Introduction</strong></h3><p>Ever wondered how much your used car might be worth? Car price prediction isn’t just a cool machine learning problem, it’s also a useful one. That being said, I recently built a web app that predicts car prices based on specific details like brand, model, fuel type, mileage and the best part? It’s fully interactive thanks to Gradio. In this post, I’ll walk you through how I built it, from backend prediction logic to a user-friendly interface.</p><p>I will now walk you through the practical method to build a car price prediction model using machine learning algorithms. Let’s start by importing the necessary libraries.</p><p><strong>Import Libraries</strong></p><pre>import pandas as pd<br>import numpy as np<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br>import scipy<br>import time<br>import phik<br>import ppscore<br><br>from sklearn.model_selection import train_test_split, cross_val_score, KFold, GridSearchCV<br>from sklearn.linear_model import LinearRegression, Ridge<br>from sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor, HistGradientBoostingRegressor, VotingRegressor, StackingRegressor<br>from catboost import CatBoostRegressor<br><br>from sklearn.pipeline import Pipeline, make_pipeline<br>from sklearn.compose import ColumnTransformer<br><br>from sklearn.preprocessing import OneHotEncoder, StandardScaler, PolynomialFeatures<br>from sklearn.decomposition import PCA<br>from sklearn.feature_selection import SelectKBest, f_regression, RFECV <br>from category_encoders import TargetEncoder<br><br>from sklearn.metrics import r2_score, mean_squared_error<br>from functools import partial<br>rmse = partial(mean_squared_error, squared=False)<br><br>import warnings <br>warnings.filterwarnings(&quot;ignore&quot;)</pre><h3>Data Processing for Machine Learning</h3><p>Before jumping into model building, this project required a thoughtful and detailed data preprocessing pipeline. These include dealing with missing values, identifying and treating outliers and noisy data, encoding categorical features for model compatibility, and properly sampling and splitting the data to ensure robust evaluation. Each of these steps played a critical role in transforming raw, real-world data into a form that could drive accurate predictions.</p><p>The dataset contains an anonymised collection of adverts with information on vehicles such as brand, type, colour, mileage, as well as<br>the selling price. There are 402,005 rows and 12 columns.</p><p><strong>Dealing with missing values:</strong></p><p>Dealt with missing values in the Year_of_registration and Reg_Code columns by scraping the UK&#39;s car registration codes for age and year identifiers tables from the Wikipedia page <a href="https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_the_United_Kingdom">UK Vehicle Registration Codes</a> and mapping the reg_code to fill in the missing year of registration. For every <strong><em>NEW</em></strong> car, there&#39;s no year of registration and reg_code attached to it. This is because it hasn&#39;t been purchased and registered by any user. So, I filled the missing Year_of_registration for <strong>NEW</strong> cars with <strong><em>2020</em></strong> and Reg_Code for <strong><em>NEW</em></strong> cars with <strong><em>20</em></strong>. This is because the maximum year_of_registration in the dataset is 2020 and also the <strong>Public_reference</strong> column indicates the year, month, and day the advert was made, this also aids in my decision to use <strong><em>2020</em></strong> as the year of registration for new cars.</p><p>For body_type, fuel_type and standard_colour, missing values were detected and was handled using <strong>groupby()</strong> method. Below is the function used to do that:</p><pre>def fillna_with_mode(missing_col):<br>        df[missing_col] = df.groupby([&#39;standard_make&#39;, &#39;standard_model&#39;])[missing_col].apply(lambda x: x.fillna(scipy.stats.mode(x)[0][0]))<br>        return df<br><br>def refillna_with_mode(missing_col):<br>        missing_values = df[df[missing_col].isnull()]<br>        brand_model = missing_values[[&#39;standard_make&#39;,&#39;standard_model&#39;]]<br><br>        results = []<br>        for i, j in brand_model.iterrows():<br>            try:<br>                result = (df[(df[&#39;standard_make&#39;]==j[&#39;standard_make&#39;]) &amp; (df[&#39;standard_model&#39;]==j[&#39;standard_model&#39;])][missing_col]<br>                .value_counts().sort_values(ascending=False).index[0])<br>                results.append(result)<br>            except IndexError:<br>                results.append(&quot;no value&quot;)<br>        brand_model[missing_col] = results<br>        return brand_model</pre><p><strong>Dealing with Outliers and Noise</strong></p><p>In general, most modern cars can cross 200,000 miles without any major issues, provided the vehicle is being well-maintained but it is no surprise that many vehicles that have reached 400,000 and even 500,000 miles have received extraordinary care and maintenance, often with the owners doing the routine work themselves. From the boxplox below, for Mileage, I capped outliers for values greater than 200,000mph and replaced the outliers with value at 200,000mph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*_S5BkC11WBmpKn4iscomSA.png" /><figcaption>Identifying outliers</figcaption></figure><p>For price, most of the top outliers in the price feature are expensive and luxurious cars, with most of them having low mileage. Handling the outliers in price was a tricky one. The car prices classified as outliers are actually expensive cars. For the purpose of this project, I excluded these expensive cars. I handled outliers for each subsets of vehicle conditions, capping the quantiles at different values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TKFQqe2W59fC4gWT9MPhVA.png" /><figcaption>Mileage and price after handling outliers</figcaption></figure><p><strong>Categorical Encoding</strong></p><p>Before encoding, For standard_colour column, categories that had count less than 200 were grouped into a new category:Other_standard_colour. body_type categories with the word <strong><em>van</em></strong> were all grouped together into a new category: Vans. Features with extremely high cardinality, such as standard_make and standard_model, TargetEncoder() was used. For Other features like standard_colour, fuel_type, vehicle_condition, and body_type were encoded using OneHotEncoder().</p><p><strong>Feature Engineering</strong></p><p>A critical look at the Public_reference column shows the year, month, day, and some ID of each advert. I created a new column; advert_year by grabbing the first 4 digits from the public_reference column.</p><p>Vehicle_age column was created by subtracting the Year_of_registration from the advert_year. A third column was created for Avg_miles_per_year by dividing the mileage by the vehicle_age.</p><p>Additionaly, automated feature engineering was used to derive extra features. PolynomialFeatures a library from scikit-learn is a feature engineering technique that creates polynomial and interaction features from the original features. Polynomial and interaction features can help capture nonlinear relationships between features. However, interactions only was used (interaction_only=True) without setting a polynomial degree. Scaling was done after polynomial features.</p><p><strong>Preprocessing pipeline function</strong></p><p>To streamline the data preparation process for machine learning, I built a custom preprocessing pipeline using scikit-learn’s Pipeline and ColumnTransformer. For numeric features like mileage, registration year, and average miles per year, the pipeline first generates interaction-only polynomial features to capture potential relationships between variables, then standardizes them using StandardScaler. On the categorical side, features such as color, condition, body type, and fuel type are one-hot encoded, with smart handling for rare or binary categories using handle_unknown=&quot;infrequent_if_exist&quot; and drop=&#39;if_binary&#39;.</p><pre>def preprocessor_pipe():<br>    numeric_features = [&#39;mileage&#39;,&#39;year_of_registration&#39;,&#39;avg_miles_per_year&#39;,&#39;advert_year&#39;,&#39;standard_make&#39;,&#39;standard_model&#39;]<br>    numeric_transformer = Pipeline(<br>        steps=[<br>            # its a good practice to do the polynomial/interaction feature generation before scaling.<br>            (&quot;poly_int&quot;, PolynomialFeatures(interaction_only=True, include_bias=False)),<br>            (&quot;scaler&quot;, StandardScaler())<br>        ]<br>    ).set_output(transform=&#39;pandas&#39;)<br><br>    categorical_features = [&#39;standard_colour&#39;,&#39;vehicle_condition&#39;,&#39;body_type&#39;,&#39;fuel_type&#39;]<br>    categorical_transformer = Pipeline(<br>        steps=[<br>            (&quot;ohe&quot;, OneHotEncoder(handle_unknown=&quot;infrequent_if_exist&quot;, sparse_output=False, drop=&#39;if_binary&#39;)),<br>        ]<br>    ).set_output(transform=&#39;pandas&#39;)<br><br>    preprocessor = ColumnTransformer(<br>        transformers=[<br>            (&quot;num&quot;, numeric_transformer, numeric_features),<br>            (&quot;cat&quot;, categorical_transformer, categorical_features),<br>        ],<br>        remainder=&#39;passthrough&#39;,<br>        verbose_feature_names_out=False<br>    ).set_output(transform=&quot;pandas&quot;)<br><br>    return preprocessor</pre><h3>Model Building</h3><p>In this section, I built 4 regression models which are <strong>LinearRegression, RandomForestRegressor, Boosted Tree model (CatBoostRegressor), </strong>and a<strong> Voter Ensemble (VotingRegressor) Model</strong>. Top features generated by SelectKBestfrom scikit-learn was used across all models.</p><pre>def model_pipe(est):<br>    pipe = Pipeline(<br>        steps=[<br>            (&quot;pp&quot;, preprocessor_pipe()),<br>            (&quot;featsel&quot;, SelectKBest(f_regression, k=44)),<br>            (&quot;regr&quot;, est)<br>        ]<br>    ).set_output(transform=&quot;pandas&quot;)<br><br>    return pipe</pre><h3><strong>Model Evaluation and Analysis</strong></h3><p>Cross Validation was done to assess the performacne of models and see our it generalises on different data. It is important to cross validate our results so as to check if the models are not overfitting. The cross validation scores for each model was achieved on a 5 k-Fold splits which means when the data was splitted into 5 equal folds.</p><pre>|Model | RMSE|<br>|Linear Regression (LR) | 3977.50|<br>|Random Forest (RF) | 2650.35|<br>|CatBoost (CAT) | 2366.85|<br>|Ensemble (LR + RF + CAT) | 2269.01|<br>|Ensemble (RF + CAT) | 2424.93|</pre><p>Based on the provided cross-validation (RMSE) values, the CatBoost model has the lowest RMSE value of 2366.853. Catboost Regression model has the best overall model performance, i.e highest accuracy score, lowest mean root mean squared error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a46KonDWXgOgkJpEbcF24A.png" /><figcaption><em>True price vs Predicted price</em></figcaption></figure><h4>Global and Local Explanations with SHAP</h4><ul><li><strong>Global Explanantions with SHAP: </strong>Below are the important features of the model used. It is not surprising to see year_of_registration and milage among top 10 important features. Polynomial engineered features happens to be among the top 3 features, year_of_registraion being the common feature in all interactions. One would expect that the feature; year_of_registration standard_make and year_of_registration standard_model should determine the price of car.. Other features were genrerated after processing through encoding. It&#39;s not surprising that year_of _registration,standard_make, standard_model, and vehicle_condition are really good predictors of price.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*bO-5RPyDvRTOAHlpabTGeQ.png" /><figcaption>Shap feature importance</figcaption></figure><ul><li><strong>Local Explanantions with SHAP</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G3jw78_uGYHJX107hcxjPw.png" /></figure><p>In plot above, The predicted price is £28,738.10 and the actual price is £29,995. The feature contributing the most to the price of this Vehicle is the standard_make standard_model feature which conrtibuted drastically to the price of the car. The car is a Mercedes-Benz GLEclass. Other contributing features are year_of_registration standard_make and year_of_registration standard_model. However, the mileage and some interactions with mileage contributed to the reduction in the price of the car.</p><h4>Partial Dependency Plots</h4><p>Partial Dependency Plot (PDP) is a technique used to visualize the relationship between a target variable and a set of predictor variables in a It can show whether the relationship between target and a feature is linear, monotonic, or more complex[1]. It helps in understanding how the predicted outcome changes with variations in the values of specific features, while keeping all other features constant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*Rk-yhhaNtcRqn394ax7x7A.png" /></figure><p>Two features were selected years_of_registration and mileage. The selection of these features is based on their importance in the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7j3evC-6IpTJxLV4jLwQHw.png" /></figure><p>As the year_of_registration increases, the model predicts on average high car prices. potential buyers and seller can actually have any idea of how much a car will cost my knowing the yeart of registration of the car. In addition, the higher the mileage, the lesser the price of a car, which makes sense. Interestingly, the year_of_registration and mileage have an effect on the price of a vehicle whether the vehicle is new or used.</p><h3><strong>Conclusion</strong></h3><p>Building an interactive car price prediction app involved more than just throwing data into a machine learning model. it required careful preprocessing, smart feature engineering, and rigorous evaluation. From handling missing values and outliers to encoding complex categorical features and leveraging ensemble models. Through cross-validation, we saw that CatBoost stood out with the lowest RMSE, and ensemble approaches offered even better results.</p><p>In Part 2, I’ll show how I brought this model to life with a simple, clean Gradio interface, allowing users to interact with the app and get real-time car price predictions based on their inputs. Stay tuned to see how everything comes together in a fully functional web app!</p><p><strong>Please use the below comments section to ask any questions or leave any feedback.</strong></p><p>Here is the link to the GitHub repository: <a href="https://github.com/aadedolapo/Car-Price-Prediction/tree/main">aadedolapo/Car-Price-Prediction</a></p><p>References</p><p>[1]. <a href="https://christophm.github.io/interpretable-ml-book/pdp.html">https://christophm.github.io/interpretable-ml-book/pdp.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5455842aed9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Yoruba Proverb Generator Using Neural Network]]></title>
            <link>https://medium.com/@theadedolapo/yoruba-proverb-generator-using-neural-network-342fdad3dbcf?source=rss-f7f0629ac8fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/342fdad3dbcf</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[text-generation]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Adebo Dolapo]]></dc:creator>
            <pubDate>Fri, 21 Oct 2022 16:12:05 GMT</pubDate>
            <atom:updated>2023-02-10T17:26:02.895Z</atom:updated>
            <content:encoded><![CDATA[<h4>Generating proverbs using Double Layer LSTM Models</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4pRD33oX5w66hkD2zsDIig.jpeg" /></figure><h4>Introduction</h4><p>Proverbs are wise sayings that give advice about life. They are the gems of wisdom. We may sometimes not understand a big lecture, but we understand a small proverb very easily because the truth they speak can span the globe. They can also give a greater potency to what is being conveyed.</p><p>A Proverb Generator is the idea of making your device generate proverbs for you by giving it a word and this is really remarkably. This practice is referred to as <strong>Text Generation</strong> or <strong>Natural Language Generation</strong>, which is a subfield of Natural Language Processing (NLP).</p><p>A sentence generator is an application that takes in phrases or single words and generates a sentence from it. The Yoruba proverbs generator app uses the idea behind Text Generation in the sense that it takes in a keyword or phrase in Yoruba language and generates a proverb for you in Yoruba language from the given keyword/phrase.</p><p>The model uses keras tokenizer to generate tokens and a Sequential model by adding an embedding layer and two LSTM model.</p><p>We took into consideration, homonyms and language intonations to help the model generate a more readable proverb. In addition, using the deep-translator library, we added google translator API to help translate the generated Yoruba proverb to English Language for non-yoruba readers.</p><h4><strong>Yoruba Proverb Generation with Two LSTM Layers</strong></h4><p>We will now walk you through the practical method on how to build a proverb generator using TensorFlow and LSTM layers. TensorFlow is an open-source machine learning library for Deep Learning. This project was carried out on Google Colab so we could access the GPU.</p><p><strong>Importing Libraries</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c437ff94b37dd569edb07247565d535/href">https://medium.com/media/2c437ff94b37dd569edb07247565d535/href</a></iframe><p>This is self-explanatory. We are importing all libraries required for our study.</p><p><strong>Download and Load Data</strong></p><p>The dataset was downloaded from <a href="https://github.com/Niger-Volta-LTI/yoruba-text/blob/master/Owe/owe.txt">NIGER VOLTA LTI</a> GitHub repository. After loading the data, we immediately cleaned the data by removing extra spaces, numbers, and punctuations from the dataset. We also removed some English words and non-Yoruba lines of proverbs. Loaded the data list into a data frame.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d51e280f9d5de6af24fe418f2bcf639/href">https://medium.com/media/5d51e280f9d5de6af24fe418f2bcf639/href</a></iframe><p><strong>Data Preprocessing</strong></p><p>The following process were taken when preprocessing the data:</p><ul><li><strong>Removing Stopwords</strong>: Some words in the Yoruba Literature happens to be stop words in the English literature. We had to excluding these words while treating the removal of these stopwords. We also removed lines of proverbs containing English Words. Below is the function that performs the action above.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f19ec600c81a62b91992e6294165bd7/href">https://medium.com/media/6f19ec600c81a62b91992e6294165bd7/href</a></iframe><ul><li><strong>Tokenization</strong>: We generated unique token for each of the words. Repeating words in the corpus are assigned the same token. This was easily done using the TensorFlow’s Tokenizer.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/434257d4e8c7648c0efa736ba03a5d43/href">https://medium.com/media/434257d4e8c7648c0efa736ba03a5d43/href</a></iframe><ul><li><strong>Sequencing and Sequence Padding</strong>: We then generated <strong>n-gram </strong>sequences, the first two words of such proverb can be one sequence, the first three words can be the next sequence and so on. After the sequencing, length of each of these generated sequences are different, in other to maintain order, we did some pre-padding with zeros, using the <strong>pad_sequences()</strong> method from Keras.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8d8e49b882cf4d399b5731d5e8ec0cb/href">https://medium.com/media/d8d8e49b882cf4d399b5731d5e8ec0cb/href</a></iframe><ul><li><strong>Splitting the dataset</strong>: We want to predict the next word, for example, we split the sentence of length 10 to first 9 words as the Features and the last word as the Label. We also want to <strong>One-Hot encode</strong> the labels.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b45b8ad28673933630f89cb1ece18e6/href">https://medium.com/media/7b45b8ad28673933630f89cb1ece18e6/href</a></iframe><p><strong>Model Building</strong></p><p>We used a <strong>Sequential</strong> Model with several layers. The first layer is the <strong>Embedding Layer</strong>. This layer takes three arguments namely, the input dimension (the total number of unique words in our corpus), the output dimension (or the embedding dimension in which vectors will be mapped), and the input length (the length of each sequence that is fed) We added two <strong>LSTM</strong> layers of 400 units, and a <strong>dropout</strong> of 20% rate. A <strong>dense layer </strong>with the total words as the units.</p><p><strong>PS: One rule of thumb is that the embedding dimension should be approximately 1.6 times the square root of the number of unique elements in the category.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2cacc98d027736093e7ba7608f72cbc8/href">https://medium.com/media/2cacc98d027736093e7ba7608f72cbc8/href</a></iframe><ul><li><strong>Model compilation</strong>: Since the prediction of subsequent words is a multi-class classification issue, we select <strong>Categorical Cross-entropy </strong>as our loss function and <strong>Adam</strong> as our optimizer. We then train the model for 500 epochs.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/51386a989bee9c9f8e442dfdfd31768e/href">https://medium.com/media/51386a989bee9c9f8e442dfdfd31768e/href</a></iframe><p>We got a final loss of 0.2867 and an accuracy of 90.11%.</p><p><strong>Generating Proverbs Function</strong></p><p>Now, let’s generate some proverbs, for our model to understand the context in which we want it to generate proverbs, we must offer it some insights. For this, we gave an initial keyword or phrase to the model, which the model then performs the necessary preprocessing and generates proverbs based upon our input keyword or phrase. Accordingly, the model will predict the token for the next word and then convert that token back to the original word and finally, display the entire predicted proverb.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8014913540912481d31eab52db2c800/href">https://medium.com/media/d8014913540912481d31eab52db2c800/href</a></iframe><p>Now it may as well happen that the generated proverb may not be grammatically valid, but the overall gist of the proverb can be easily understood.</p><h3><strong>Project Challenges</strong></h3><ul><li><strong>Data</strong>: We were unable to get additional dataset and that was one of the issues we faced in this project.</li><li><strong>Computing Power</strong>: This was a deep learning project; we required a GPU to train the models. We used Google Colab for most of our modelling but with that, we spent about 2 hours to run the model each time we tweak the model.</li><li><strong>Diacritization</strong>: Diacritizing our input keyword for end user was a big problem for us. We came also came across a library called <a href="https://pypi.org/project/iranlowo/"><strong>Iranlowo</strong></a> to help us with this. But we were getting errors as the library was last updated in 2020.</li><li><strong>Reading The Generated Proverbs</strong>: We are not proud to say this, but we found it difficult reading the Yoruba language. Most times, we outsourced each generated proverb to an expert in the Yoruba Language.</li></ul><h3>Area Of Future Focus</h3><ul><li>Adding the interpretations of the generated proverbs as an output to end-users.</li><li>We want to improve the model accuracy and also reduce the loss function.</li><li>We also want to do the same of other Nigerian Languages (Igbo and Hausa).</li></ul><h3>Conclusion</h3><p>What makes a proverb generator more efficient is its capability to generate meaningful proverbs. After going through a bunch of processes, we successfully built a proverb generator using Sequential model with an embedding layer and 2 LSTM layers. Although, there are other several models that can be used for a text generation project such as GANs, Spacy, Encoder-Decoder Models, Transfer Learning (HuggingFace Transformers) and so on.</p><p><strong>Please use the below comments section to ask any questions or leave any feedback.</strong></p><p>Here is the link to the Team’s GitHub repository:</p><p><a href="https://github.com/aoluwatooni/sentence-generator-for-indigenous-nigerian-language">GitHub - aoluwatooni/sentence-generator-for-indigenous-nigerian-language</a></p><p><strong>WEB APP:</strong></p><p><a href="https://aadedolapo-sentence-generator-for-indigenous-nigeria-app-8vkc1t.streamlitapp.com/">https://aadedolapo-sentence-generator-for-indigenous-nigeria-app-8vkc1t.streamlitapp.com/</a></p><h3><strong>Contributors</strong></h3><ul><li>Mubar Dauda <a href="https://github.com/mubardauda">https://github.com/mubardauda</a></li><li>Samuel Iheagwam <a href="https://github.com/Psalmuel69">https://github.com/Psalmuel69</a></li><li>Oluwatooni Adebiyi <a href="https://github.com/aoluwatooni">https://github.com/aoluwatooni</a></li><li>Dolapo Adebo <a href="https://github.com/aadedolapo">https://github.com/aadedolapo</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=342fdad3dbcf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scraping Real Estate Properties With Python And Creating Beautiful Visualizations With It]]></title>
            <link>https://medium.com/@theadedolapo/scraping-real-estate-properties-with-python-and-creating-beautiful-visualizations-with-it-770223b3d74a?source=rss-f7f0629ac8fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/770223b3d74a</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[web-scraping]]></category>
            <dc:creator><![CDATA[Adebo Dolapo]]></dc:creator>
            <pubDate>Sat, 16 Oct 2021 04:43:38 GMT</pubDate>
            <atom:updated>2021-10-16T23:17:39.197Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w-bqugvXwcKPiItm" /><figcaption>Photo by <a href="https://unsplash.com/@filtergrade?utm_source=medium&amp;utm_medium=referral">FilterGrade</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Goal:</strong> I decided to use it as yet another incentive to improve my Python skills! In the end I want to be able to do two things:</p><p>· Scrape most of the search results from one of the main real estate websites in Lagos, Nigeria (where I live) and build a database with all the listings found.</p><p>· Use the collected listings to perform some EDA and Visualizations, and ultimately try to find insights from the visualizations.</p><p>The website I will be scraping is the real estate website <a href="http://www.privateproperty.com.ng/">Privateproperty.com.ng</a> in Lagos. They have a very large amount of real estate listings for us to scrape. Chances are you are using a different website, but you should be able to adapt the code very easily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tIPk_XVCmCpnywYOCamN5g.png" /><figcaption>landing page of privateproperty.com.ng</figcaption></figure><p>Before we begin with the code snippets, let me just give you a summary of what I will be doing. I will use the results page from a simple search in private property website where I can specify some parameters beforehand (like properties for rent) to query the whole list of results in Lagos.</p><p>We then need to use a command to request a response from the website. The result will be some html code, which we will then use to get the elements we want for our final table. After deciding what to take from each search result property, we need a for loop to open each of the search pages and perform the scraping.</p><p>That sounds pretty easy, right? Let’s Get started!</p><h3><strong>DATA SCRAPING PROCESS</strong></h3><p><strong>Import Libraries</strong></p><p>Like most projects, we need to import the modules to be used. I will use Beautiful Soup to take care of the html’s we will be fetching. Always make sure the site you are trying to access allows scraping. You can easily do that if you add “/robots.txt” to the original domain. Inside this file you can see if there are guidelines regarding what is allowed to scrape.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*H2lTYHM0zOanh7R32QMhEA.png" /></figure><p>Define the url path and now we can test if we can communicate with the website. One of the <em>issue</em> with <a href="http://docs.python-requests.org/en/master/">Python Requests</a> is that, if you don’t mention timeout, it will keep trying till it’s last breathe. This might be good for some certain conditions but not in majority cases. Therefore, it’s always good to set a timeout value for each request. You can get several codes from this command, but if you get “200” it’s usually a sign that you’re good to go. You can see a list of these codes <a href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*uLIWfTADWluKt1UKognf_w.png" /></figure><h4><strong>Time to make Soup!</strong></h4><p>Alright, we’re all set to start exploring whatever we get from the website. We need to define the Beautiful Soup object that will help us read this html.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*HKu0AGgXbHGiyNQAqWFXkQ.png" /></figure><p>An important part of building a web scraping tool is navigating through the source code of the web pages we’re scraping from. The chunk of text above is just a part of the whole page. You can also find out the position in the html document, of a particular object like the price of the properties. Right click it and select inspect or Ctrl +Shift + I.</p><p>Prettify() function in BeautifulSoup will enable us to view how the tags are nested in the document.</p><p>Before extracting the features, we want to be able to identify each result in the page. In order to know what tags we need to call, we can follow them from the price tag to the top until we reach something that looks like the main container for each result. We can see it below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2DXJ7LK5QZZvD1oOLvArHw.jpeg" /></figure><p>The examples below should be enough for you to do your own research. You can learned a lot just by messing around with the html structure and manipulating the values that were being returned until you get what you want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*yyC0C9a5XFP7nMKLoM1AKg.png" /><figcaption>Getting elements from the website</figcaption></figure><h4>let’s scrape some pages already!</h4><p>Once you’re comfortable with the fields to extract and you found a way to extract them all from each result container, it’s time to setup the base of our crawler. First, we need to check the number of pages available for scraping then we build the base crawler. As at the time of checking this, there are 2,863 lisitings and 114 pages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*M1jG-K01LFa5dJVzc3Cw4Q.png" /></figure><h4><strong>Building the base crawler</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/085138522635ad845f856afd2fad8818/href">https://medium.com/media/085138522635ad845f856afd2fad8818/href</a></iframe><p>We scraped more than 2,500 properties and now have an original dataset. There’s still some cleaning and pre processing to do, but we already completed the complicated part.</p><h3>Data Visualization</h3><ol><li><strong>How the number of bedrooms affects the price of the building.</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ddi6nXwN7-p8pJ9yte3rdg.png" /></figure><p><strong>2. This is a plot that shows cities with most properties available for rent.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v-lhRRIom7JdgjrJv6HrGA.png" /></figure><p><strong>3. This plot shows average prices of buildings for each city.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QmeRWvC4JQTdJbuCfMR_bg.png" /></figure><p><strong>4.This plot shows the average prices for different types of buildings.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uuXX3qVZ3zl95HXVr2Uqzw.png" /></figure><h3>In Conclusion</h3><p>This project demonstrated a simple way to get real estate properties data from a property website using beautiful soup, data preprocessing and cleaning, and data visualization using Seaborn and Matplotlib libraries.</p><p><em>Thanks for reading!</em></p><p><strong>WRITER</strong>: ADEBO DOLAPO</p><p><strong>Explanatory Notebook and dataset: </strong><a href="https://github.com/aadedolapo/SCRAPING-REAL-ESTATE-PROPERTIES-AND-CREATING-VISUALIZATIONS">aadedolapo/SCRAPING-REAL-ESTATE-PROPERTIES-AND-CREATING-VISUALIZATIONS (github.com)</a></p><p><strong>linkedIn profile</strong>: <a href="https://www.linkedin.com/in/dolapo-adebo-4a979687/">Adebo Dolapo</a></p><p><strong>twitter profile</strong>: <a href="http://www.twitter.com/theadedolapo">https://twitter.com/theadedolapo</a></p><p><strong>TAGS</strong>: #DATAENGINEERING #DATAVISUALIZATION #DATASCRAPING #PYTHON #PANDAS #BEAUTIFULSOUP #SEABORN #MATPLOTLIB</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=770223b3d74a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>