<?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 Sophia Scott on Medium]]></title>
        <description><![CDATA[Stories by Sophia Scott on Medium]]></description>
        <link>https://medium.com/@sophia1scott?source=rss-7928d61c0f5a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*c-Z-FMp_V0P5dq2h</url>
            <title>Stories by Sophia Scott on Medium</title>
            <link>https://medium.com/@sophia1scott?source=rss-7928d61c0f5a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 13:23:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sophia1scott/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[Defining Pawpularity through Image Analytics]]></title>
            <link>https://medium.com/@sophia1scott/defining-pawpularity-through-image-analytics-46c0549ad66e?source=rss-7928d61c0f5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/46c0549ad66e</guid>
            <dc:creator><![CDATA[Sophia Scott]]></dc:creator>
            <pubDate>Sat, 11 Dec 2021 03:12:30 GMT</pubDate>
            <atom:updated>2021-12-11T03:12:30.509Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Project By Sukeerth Cheruvu, Adam Hoard, Rohan Gard, Sophia Scott, and Jackie Solis</em></p><h3>Introduction</h3><p>Millions of stray animals suffer on the streets or are euthanized in shelters every day around the world. We believe that every pet needs a good, loving home, and with so many on the street, adoption is a way to save thousands of animals living in these conditions. PetFinder.my, a Malaysian welfare platform that collaborates closely with animal lovers, media, global corporate, and non-corporate organizations to improve animal welfare and promote adoption. PetFinder.my ranks over 180,000 animal photos and assigns them a “cuteness” rating.</p><p>The experimental stage of the algorithm currently analyzes picture composition and other description factors (e.g. face, eyes, picture blurriness, etc.) and compares it to the performance of thousands of pet profiles. While it probably is expected that pets with more attractive photos generate more interest and get adopted faster, what helps make a good picture?</p><h4>Our Goal</h4><p>Our goal is to be able to accurately determine a pet photo’s attractiveness (and thus consumer engagement), dubbed “Pawpularity”, and suggest recommendations to boost the current algorithm so that we may give these rescue animals a higher chance at adoption. In order to accomplish this, we will analyze raw images and metadata then train and test our model on PetFinder.my’s pet profiles so that we may obtain the highest level of accuracy.</p><p>We analyzed both metadata and raw image data in order to appropriately address our problem. Not only will we apply various data modeling techniques to improve our prediction on the target variable, Pawpularity, but we will see which photo metadata features are potentially useful at impacting the popularity of a photo. The models and parameters are discussed below in further detail; additionally, we will provide a comparison of model performance from which we will draw our conclusions and make recommendations for the organization.</p><h3>Data Collection and Description</h3><p>The data we worked with comes from Kaggle and consists of two parts — raw images and metadata. Within the dataset there are 180,000 pet profile images and metadata for each of the photos along with a unique id for each photo and an independent “Pawpularity score” that has been derived using an algorithm that normalizes the traffic data across different pages. Therefore our dataset consists of images and tabular data.</p><p>The photo metadata is manually labeled for each photo for key visual quality and composition parameters. Each photo within the training and test set is labeled with a binary value (0,1) for each of the following features:</p><ul><li><strong>Focus</strong> — Pet stands out against an uncluttered background, not too close / far</li><li><strong>Eyes</strong> — Both eyes are facing front or near-front, with at least 1 eye / pupil decently clear</li><li><strong>Face</strong> — Decently clear face, facing front or near-front</li><li><strong>Near</strong> — Single pet taking up a significant portion of the photo (roughly over 50% of photo width or height)</li><li><strong>Action</strong> — Pet in the middle of an action (e.g., jumping)</li><li><strong>Accessory</strong> — Accompanying physical or digital accessory / prop (i.e. toy, digital sticker), excluding collar and leash</li><li><strong>Group</strong> — More than 1 pet in the photo</li><li><strong>Collage</strong> — Digitally-retouched photo (i.e. with digital photo frame, combination of multiple photos)</li><li><strong>Human</strong> — Human in the photo</li><li><strong>Occlusion</strong> — Specific undesirable objects blocking part of the pet (i.e. human, cage or fence). Note that not all blocking objects are considered occlusion</li><li><strong>Info</strong> — Custom-added text or labels (i.e. pet name, description)</li><li><strong>Blur</strong> — Noticeably out of focus or noisy, especially for the pet’s eyes and face; For Blur entries, “Eyes” column is always set to 0</li></ul><p>Below are two images from our training data along with their hand-labeled metadata and Pawpularity Score. The photo on the left scored a 63 while the one on the right scored a 42.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*_rDxPv3xM7ErM0Ey3JAVjQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2k7oVEaYLqvdK5lG_K9_cQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1k8wJVbnkvoVPofE7-UCiA.png" /></figure><p>These labels acted as a supplement to our endeavor of predicting our own Pawpularity score, as we focused most of our attention on image processing for our analysis. The metadata better allows us to generate intelligent recommendations (i.e. show a closer frontal pet face, add accessories, increase subject focus, etc) and automatic enhancements (i.e. brightness, contrast) on the photos, so we are hoping to have predictions that are more easily interpretable.</p><h4>Data Cleaning</h4><p>We began the investigation of the data set by performing some pre-processing of data. We then renamed the image filenames to make them easier to access as we move forward. Then exploratory data analysis was performed so that we can make some general conclusions about the data.</p><h4><strong>Image Augmentation</strong></h4><p>The images in our data were taken at various angles, horizon shifts, zoom etc. and we hypothesized they could impact the performance of the model. We did some data preprocessing of the images to suppress undesired distortions and enhance some features (chosen subjectively on a per-image basis), which are necessary for particular applications, and finally output RedBlueGreen (RGB) images. Next, by utilizing tensorflow keras and resnet, we wrote over the data with processed images and returned the Pawpularity scores from the adjusted images. We then graphed these scores to visually see the mean and distribution of attractiveness among the photos.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*blyB5BZpidafTliJ" /><figcaption>The distribution is skewed due to the almost 300 entries with a Pawpularity score of 100. There is also a small bump of scores close to zero, but overall the data seems to roughly follow the shape of a normal distribution.</figcaption></figure><h4>Ordinary Least Squares Regression (OLS) and Ridge Regression</h4><p>As part of our exploratory data analysis, we decided to naively test linear models on our training data. While we do not think they will satisfy our goal, we felt it important to attempt and assess their results. We started with the OLS regression, but found it made very narrow Pawpularity predictions and consequently the model was not very accurate, giving us an RMSE of 20.4. We then decided to try a Ridge regression because it addresses some of the problems of OLS by imposing a penalty on the size of the coefficients. The Ridge model did not improve the OLS model and actually gave a slightly lower RMSE value of 20.9.</p><p>One thing to note about the Ridge model is the insight it gives regarding the feature parameters. It allows us to see which specific tags from the metadata hold more importance in the photos.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/0*WsL7G5ZUk6szSZ2Q" /><figcaption>Our model predicted that Blurriness, Face, Subject Focus, Eyes, and Accessory are important feature parameters on pet profile pictures.</figcaption></figure><p>While these features do not help predict Pawpularity score, understanding which are more important could help us analyze which photo elements people assess when they join the website. This conclusion can also benefit the organization because now they will be wary of what kinds of photos to upload to give the pet a better chance at adoption.</p><p>Now we will explore more sophisticated models that can better approximate and learn from the distribution of Pawpularity scores.</p><h3>Building Our Models</h3><h4>Data Preprocessing</h4><p>We followed a step-by-step process to train the complex models. We started by connecting the images to the dataset and performed some preprocessing with TensorFlow and Keras. Afterward, we split the original dataset into two separate training and test datasets, with the training dataset being 80% and the test dataset being 20% of the original data. Next, we initialized the learning rate, SGD method, batch size, number of epochs, and other training parameters needed. Different learning rates, epochs and batch sizes were applied through the model tuning process.</p><ul><li>Learning rate: .0001 to .1</li><li>Batch size: 32 to 64</li><li>Epochs: 1 to 100</li></ul><p>For our final output, we set the learning rate to .1, Batch size 64, and 1 Epoch to allow for a quicker run-through of the data. The SGD optimization method was set to Adam, since it is computationally efficient, has little memory requirement, is well suited for large amounts of data and parameters, and also can handle the diagonal scaling of the gradients well.</p><h4>Base Model</h4><p>For the base model, we chose to use ResNet152 by implementing the PreTrained Model ‘ResNet152V2_Top_ImageNet.h5’ which is a deep, convolutional neural network introduced recently in 2015, used for Image Recognition and Classification.</p><p>Residual Blocks, which are the basis for ResNet models, account for this problem of training very deep neural networks by adding direction connections in between, which skips some layers. This direct connection is called the “skip connection” and is the core foundation of residual blocks and thus ResNet. The skip connection changes the output of the layer and solves the problem of vanishing gradients in deep neural networks by allowing this alternate shortcut path (skip connection) for the gradient to flow through. Additionally, the skip connection enables the model to learn the identity functions which then ensures that the higher layer will perform at least as good as the lower layer, and not worse. Lastly, ResNet152 just means that there can be a maximum of 152 layers in the neural network model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/0*2SsXrgrM1VAOkkWv" /></figure><p>This model was then combined with Neural Nets (NN), Support Vector Regression (SVR), and XGBoost.</p><h4>Neural Network</h4><p>Neural Nets take advantage of the backpropagation process which allows the models to optimally set the weights and biases, letting it learn from the data. The NN model was built upon a nonlinear activation function, takes in several parameters, and can be thought of as a “universal function approximator”. We used ReLu as the activation function and MSE as the loss function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*pKJgy_Jy2LzWIUntA4c5tg.png" /><figcaption>Neural Network Layers</figcaption></figure><h4>Support Vector Regression</h4><p>SVR is a supervised learning technique that gives the flexibility of defining how much error is acceptable in the model and finding an appropriate hyperplane to fit the data. SVR also takes in several parameters, is a “universal function approximator”, and is more tolerant to outliers in the data. The SVR model used a C of 20, a gamma of 0.8, and a kernel of poly, rbf and sigmoid. The C value tells the user how much to avoid misclassifying each training sample. The larger the C, the optimizer will use a smaller margin hyperplane. The gamma value determines how much influence a single training example reaches. Low values mean the reach is far and high values mean the reach is low. Lastly the Kernel is the method that is used to transform the data. The ‘rbf’ method is the most commonly used. The logical values for the parameters were tested, and the group that provided the best RMSE was selected. For the SVM model, C= 20, Gamma = 0.8 and Kernel = ‘rbf’ .</p><h4>XGBoost</h4><p>XGBoost provides high performance implementation of gradient boosted decision trees, has awareness of sparse data, and utilizes parallel learning sparsity. The max depth for the XGBoost was 5, the min child weight was 6, the alpha was 6 in our first pass. The max depth determines how deep each tree will grow during any boosting round. The min child weight represents the conservativeness of the model. The higher the min child weight, the more conservative the model will be. Alpha is responsible for the L1 regularization on leaf weights. Alpha can range from 0 to infinity. The goal was to find the best depth, min child weight and alpha. This was done by iterating through logical values for each parameter and selecting the subset that resulted in the best RMSE. All of the models were built on the training dataset and then evaluated on the validation dataset.</p><h3>Analysis of Results</h3><p>The OLS and the Ridge Model which were regressed on the binary metadata and the target variable “Pawpularity”, had very similar RMSE values. The OLS had an RMSE of 20.466 and the Ridge Model had an RMSE of 20.957 on the validation dataset. The target variable ranged from 0–100, meaning this error was quite large. This is not surprising as these models are very naïve; it is unlikely that they would be able to accurately represent the data.</p><p>Our next model, the Neural Net Model slightly improved on this number, providing an RMSE of 20.113. The Neural Net Model was able to improve the RMSE because the nonlinear activation function was able to create decision boundaries more accurately than a standard OLS regression can. However, like the naïve models, the Neural Net RMSE is also very high. The R2 of this regression is 0, which means our model explains zero of the variance in the decision variable.</p><p>The SVR Model achieved an RMSE of 19.68. This model is more tolerant to outliers, whereas the Neural Net Model would have been more sensitive. This is likely the driving force of the increase in RMSE. The R2 is extremely close to zero in this model as well. A benefit of the SVR model is the reduction in computational power. Not only were the results better, but the model trained quicker as well.</p><p>The XGBoost Model achieved an RMSE of 18.807, the best of all our models. It showed the best performance in the training data, because it utilizes gradient boosting and parallel learning sparsity (or an aware algorithm). XGBoost captures non-linear relationships very well, which is likely another reason for the increased performance. Unfortunately, the R2 for this model was also very close to 0, meaning that it did not explain the variance of the decision variable well either.</p><p>Lastly, an ensemble model was created based on the RMSE score. XGBoost dominated the construction of the ensemble. 80% of the ensemble was the XGBoost, 10% was from the SVR and 10% was from the Neural Net. Below is a graph showing the aggregate RMSE using the ensemble method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*bZ0BZ144Rv7L9b21" /></figure><p>It is important to remember the dataset that was used in this problem. The target variable is a “cuteness rating” which is a very subjective statistic. One person could believe that a puppy is extremely cute, whereas someone else might believe another puppy is cuter. This causes problems as there are very few variables that can consistently predict performance. It is not surprising that our models are having trouble describing the variance of the decision variable, as two identical pictures could have vastly different cuteness ratings which actually did happen in the dataset. Understanding “Pawpularity” is a very difficult task, especially when humans can’t agree on what is cute or not to begin with.</p><h3>Final Conclusion and Insights Gained</h3><p>To start with, calculating pet popularity scores is tricky as cuteness is very subjective. Every user visiting Petfinder has their own set of preferences and these are hard to generalize for everyone. This could be the reason why the best RMSE in the contest was around 18 (very high!). It may be worthwhile to re-think if popularity score is the right target variable to predict. Predicting the number of views or photo clicks that measures user activity could be a better response variable.</p><p>However, we went ahead with popularity score as the target variable. We first used the metadata to run a simple linear regression to see how well we can predict scores. This gave us a fair idea of important features in the metadata dataset and also helped us set a baseline for RMSE. We then ran complex models that also included the images apart from metadata. These models looked for patterns in the images contributing to the popularity scores.</p><p>In our quest to build a popularity score model, we ran into a lot of challenges, each of which helped us learn something new. First things first, image processing is hard. Dealing with unstructured data requires a lot of effort to extract patterns and features. It requires complex models and is computationally expensive. It took a couple of hours to run the basic model. We can make use of distributed computing here to train the model much faster. Complex models have a lot of hyperparameters to tune. We have seen this in all of our models. The ability of any machine learning model to converge and perform better depends on how these knobs are set. Searching for the best hyperparameter set requires a lot of resources. It requires models to be run again and again with different values. These are easily available on the cloud. Additionally, the performance of models increases with more data points. Additional training images need to be collected to train the model even better. We plan on keeping these things in mind for our next image analytics project.</p><p>Overall, this project has been a great learning experience. We tried out new and complex models. As the final step, the final model needs to be productionized. Images uploaded to Petfinder will use this machine learning model to figure out which pets are more likely to be popular and which others are not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46c0549ad66e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>