<?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 Kavengik on Medium]]></title>
        <description><![CDATA[Stories by Kavengik on Medium]]></description>
        <link>https://medium.com/@kavengik?source=rss-b34c8112e05------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OdL93feNmdfg_bNQxHqfKQ.png</url>
            <title>Stories by Kavengik on Medium</title>
            <link>https://medium.com/@kavengik?source=rss-b34c8112e05------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 11:19:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kavengik/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[Prediction Error Plot: Prediction Versus Reality]]></title>
            <link>https://medium.com/@kavengik/prediction-error-plot-prediction-versus-reality-77701b7f69be?source=rss-b34c8112e05------2</link>
            <guid isPermaLink="false">https://medium.com/p/77701b7f69be</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[r-squared]]></category>
            <category><![CDATA[predictions]]></category>
            <dc:creator><![CDATA[Kavengik]]></dc:creator>
            <pubDate>Fri, 02 Jan 2026 05:02:28 GMT</pubDate>
            <atom:updated>2026-01-02T05:02:28.086Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3b9RxPcaFXlGlrDF" /><figcaption>Photo by <a href="https://unsplash.com/@oldceltic?utm_source=medium&amp;utm_medium=referral">Brian Kungu</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A prediction error plot in machine learning is akin to the <strong>‘what you ordered versus what you received’</strong> analogy. The ‘what you ordered’ refers to the actual values of the target value (dependent variable), whereas ‘the what you got’ refers to the predicted values. <a href="https://www.scikit-yb.org/en/latest/api/regressor/peplot.html"><strong><em>The Prediction Error Plot visualizer in Yellowbrick</em></strong></a> allows us to easily plot this visualization.</p><p><strong><em>Example 1: Appropriate model</em></strong></p><p>To understand how this visualizer works, let us first implement it, using the code block blow. Explanation for each line of code, is captured by the details in the green font.</p><pre>#1.Import model<br>from sklearn.ensemble import RandomForestRegressor<br><br>#2.Data splitting<br>from sklearn.model_selection import train_test_split<br><br>#3.Import dataset<br>from yellowbrick.datasets import load_concrete<br><br>#4.Import prediction error plot visualizer<br>from yellowbrick.regressor import prediction_error<br><br>#5.Load dataset<br>X, y = load_concrete()<br><br>#6.Split data into train and test<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<br><br>#7.Instantiate model<br>model = RandomForestRegressor()<br><br>#8.Instantiate visualizer (pass model,train data.test data)<br>visualizer = prediction_error(model, X_train, y_train, X_test, y_test)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*YRirjSQJrrS5-M4olHjlIg.png" /><figcaption>Figure 1 : Prediction error plot</figcaption></figure><p>As can be seen, the model fits the data quite well. The points seem to cluster around the 45-degree line denoted by the faint dashed line marked as identity. At the 45-degree line, predicted values are equal to actual values. Also, the R-Squared is pretty high, supporting model suitability.</p><p><strong><em>Example 2: Poor model fit</em></strong></p><pre>#1.Model<br>from sklearn.linear_model import Ridge<br><br>#2.Data splitting<br>from sklearn.model_selection import train_test_split<br><br>#3.Import dataset<br>from yellowbrick.datasets import load_bikeshare<br><br>#4.Import prediction error plot visualizer<br>from yellowbrick.regressor import prediction_error<br><br>#5.Load dataset<br>X, y = load_bikeshare()<br><br>#6.Split data into train and test<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<br><br>#7.Instantiate model<br>model = Ridge()<br><br>#8.Instantiate visualizer (pass model,train data.test data)<br>visualizer = prediction_error(model, X_train, y_train, X_test, y_test)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*eCv9DEe-oioVZaGC6bEmqw.png" /></figure><p>As is evident, the model is a poor fit. The points do not cluster around the 45-degree line, to the contrary they are all over the place. Moreover, the R-Squared value is very low as well.</p><p><strong><em>End!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77701b7f69be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Model Evaluation: Residual Plots in Yellowbrick (part 3)]]></title>
            <link>https://medium.com/@kavengik/model-evaluation-residual-plots-in-yellowbrick-part-3-b427cce0511f?source=rss-b34c8112e05------2</link>
            <guid isPermaLink="false">https://medium.com/p/b427cce0511f</guid>
            <category><![CDATA[residual]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[yellow-brick]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[q-q-plot]]></category>
            <dc:creator><![CDATA[Kavengik]]></dc:creator>
            <pubDate>Fri, 19 Dec 2025 05:02:16 GMT</pubDate>
            <atom:updated>2025-12-19T05:02:16.600Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Cv4vTI1736HUqfF" /><figcaption>Photo by <a href="https://unsplash.com/@ediop?utm_source=medium&amp;utm_medium=referral">E. Diop</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Previously, we saw how to implement the <a href="https://www.scikit-yb.org/en/latest/api/regressor/residuals.html"><strong>residuals plot visualizer</strong></a><strong> </strong>from the <a href="https://www.scikit-yb.org/en/latest/index.html"><strong>Yellowbrick library</strong></a>. In this article, we shall experiment with additional tweaks to this visualizer.</p><p><strong>Tweak 1: Quick Method</strong></p><p>In the previous article we used the long method to plot the visualizer. In the long method, we proceed as follows:</p><ol><li>First, we instantiate the model.</li><li>Second, we instantiate the <strong><em>ResidualsPlot</em></strong> method, pass the model within the argument and assign this to the variable ‘visualizer’.</li><li>Then we fit the visualizer to the training data.</li><li>Finally, we fit it to the test data.</li></ol><pre>#1.Import model<br>from sklearn.linear_model import Ridge<br><br>#2.Import train test split for splitting dataset<br>from sklearn.model_selection import train_test_split<br><br>#3.Import load_concrete dataset<br>from yellowbrick.datasets import load_concrete<br><br>#4.Import Residual Plot visualizer<br>from yellowbrick.regressor import ResidualsPlot<br><br>#5.Load data<br>X, y = load_concrete()<br><br>#6.Split data into train and test<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<br><br>#7.Instantiate the linear model <br>model = Ridge()<br><br>#8.Instantiate Residual Plot visualizer<br>visualizer = ResidualsPlot(model)<br><br>#9.Fit visualizer to training data<br>visualizer.fit(X_train, y_train)<br><br>#10.Fit visualizer to test data for evaluation<br>visualizer.score(X_test, y_test)<br><br>#11.Display visualizer<br>visualizer.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*49Pna2_Ydw1K1fKKlde9hw.png" /></figure><p>In contrast, the short method uses the <strong><em>residuals_plot</em></strong> method. Within this method all stages are performed at once: we pass the model, pass the training data, pass the test data and then display the visualizer. The code block is as below.</p><pre>#1.Import model<br>from sklearn.linear_model import Ridge<br><br>#2.Import train test split for splitting dataset<br>from sklearn.model_selection import train_test_split<br><br>#3.Import load_concrete dataset<br>from yellowbrick.datasets import load_concrete<br><br>#4.Import Residual Plot visualizer<br>from yellowbrick.regressor import residuals_plot<br><br>#5.Load data<br>X, y = load_concrete()<br><br>#6.Split data into train and test<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<br><br>#7.residual_plot : short method<br>visualizer =  residuals_plot(Ridge(), X_train, y_train, X_test, y_test)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*49Pna2_Ydw1K1fKKlde9hw.png" /><figcaption>Figure 1: Residuals plot (Long method)</figcaption></figure><p><strong>Tweak two: Inserting the Q-Q plot instead of a histogram</strong></p><p>Instead of a histogram, one may wish to display a Q-Q plot instead. In this case the tweak is implemented within the residuals_plot argument, by passing True to the qqplot argument and False to hist.</p><pre>#1.Import model<br>from sklearn.linear_model import Ridge<br><br>#2.Import train test split for splitting dataset<br>from sklearn.model_selection import train_test_split<br><br>#3.Import load_concrete dataset<br>from yellowbrick.datasets import load_concrete<br><br>#4.Import Residual Plot visualizer<br>from yellowbrick.regressor import residuals_plot<br><br>#5.Load data<br>X, y = load_concrete()<br><br>#6.Split data into train and test<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<br><br>#7.Residuals_plot : short method<br>visualizer =  residuals_plot(Ridge(), X_train, y_train, X_test, y_test,hist=False,qqplot=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*nY4agF8L9a6pHQMwaDB4Tw.png" /><figcaption>Figure 2: Residuals plot (short method)</figcaption></figure><p><strong>Tweak three: Color change, one plot.</strong></p><p>It is possible to change the colors to the plot as well as have only the residuals plot. This tweak is implemented within the residuals_plot argument, by passing False to hist and desired colors to the train and test arguments. The full code is show below.</p><pre>#1.Import model<br>from sklearn.linear_model import Ridge<br><br>#2.Import train test split for splitting dataset<br>from sklearn.model_selection import train_test_split<br><br>#3.Import load_concrete dataset<br>from yellowbrick.datasets import load_concrete<br><br>#4.Import Residual Plot visualizer<br>from yellowbrick.regressor import residuals_plot<br><br>#5.Load data<br>X, y = load_concrete()<br><br>#6.Split data into train and test<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<br><br>#7.residual_plot : short method<br>visualizer =  residuals_plot(Ridge(), X_train, y_train, X_test, y_test,train_color=&#39;m&#39;,test_color=&#39;c&#39;,hist=False)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/1*NiGThl-6QTmY4nmBhf4QAQ.png" /><figcaption>Figure 3: Residuals plot (color change, no adjoining plot)</figcaption></figure><p><strong><em>End!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b427cce0511f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Model Evaluation: Residual Plots in Yellowbrick (part 2)]]></title>
            <link>https://medium.com/@kavengik/model-evaluation-residual-plots-in-yellowbrick-part-2-cbb2770824b5?source=rss-b34c8112e05------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbb2770824b5</guid>
            <category><![CDATA[yellow-brick]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[heteroskedasticity]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[visualization]]></category>
            <dc:creator><![CDATA[Kavengik]]></dc:creator>
            <pubDate>Fri, 05 Dec 2025 05:02:32 GMT</pubDate>
            <atom:updated>2025-12-05T05:02:32.308Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p-HSvugqfryui8w_" /><figcaption>Photo by <a href="https://unsplash.com/@callieopperman?utm_source=medium&amp;utm_medium=referral">Callie Opperman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Previously, we implemented Yellowbricks’s Residual Plot visualizer on different datasets, but using the same model. In this article, we shall implement different models, one linear the other non-linear and see how the plots compare in terms of model appropriateness.</p><p><strong>Example 1 : Ridge regression</strong></p><p>In this example, we experiment with the Ridge model on the load_bikeshare dataset. We leverage the Residuals Plot visualizer to evaluate the performance of the model. The full code is as below.</p><pre>#1.Import model<br>from sklearn.linear_model import Ridge<br><br>#2.Import train test split for splitting dataset<br>from sklearn.model_selection import train_test_split<br><br>#3.Import load_concrete dataset<br>from yellowbrick.datasets import load_bikeshare<br><br>#4.Import Residual Plot visualizer<br>from yellowbrick.regressor import ResidualsPlot<br><br>#5.Load data<br>X, y = load_bikeshare()<br><br>#6.Split data into train and test<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<br><br>#7.Instantiate the linear model <br>model = Ridge()<br><br>#8.Instantiate Residual Plot visualizer<br>visualizer = ResidualsPlot(model)<br><br>#9.Fit visualizer to training data<br>visualizer.fit(X_train, y_train)<br><br>#10.Fit visualizer to test data for evaluation<br>visualizer.score(X_test, y_test)<br><br>#11.Display visualizer<br>visualizer.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*FcKVROIPRee8w5WhoYXRnQ.png" /><figcaption>Figure 1 : Residual plot (Ridge Model)</figcaption></figure><p>As is evident, the Ridge model, performs poorly. This is evident through the following: 1) a low R-squared value on both training and test data; 2) cone shape distribution of the residuals that indicates a non-constant variance, instead residuals are an increasing function of the predicted value; and, 3) a skewed distribution of the residuals as seen in the adjacent histogram around the zero point.</p><p><strong>Example 2: Random forest regressor</strong></p><p>Now let us experiment with a non-linear regressor on the same dataset and compare the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*8FKyrDNoV8TzPLwJ0MBpig.png" /><figcaption>Figure 2 : Residual Plot (Random Forrest Regressor)</figcaption></figure><p>In contrast, the Random Forrest Regressor seems more suited to this dataset. This is evident through the following: 1) a very high R-squared value on both training and test data; 2) a random distribution of the residuals; and, 3) an approximate normal distribution of the residuals around zero as seen in the adjacent histogram.</p><p><strong>Conclusion</strong></p><p>Visualizations offer a convenient and appealing way to inspect the suitability of a regressor and make needed tweaks.</p><p><strong><em>End!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbb2770824b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Model Evaluation: Residual plots in Yellowbrick (part 1)]]></title>
            <link>https://medium.com/@kavengik/model-evaluation-residual-plots-in-yellowbrick-part-1-a750f964bdb0?source=rss-b34c8112e05------2</link>
            <guid isPermaLink="false">https://medium.com/p/a750f964bdb0</guid>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[yellow-brick]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[residual]]></category>
            <dc:creator><![CDATA[Kavengik]]></dc:creator>
            <pubDate>Fri, 21 Nov 2025 05:02:01 GMT</pubDate>
            <atom:updated>2025-11-21T05:02:01.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ivkojDeidvx4MyBX" /><figcaption>Photo by <a href="https://unsplash.com/@mariolagr?utm_source=medium&amp;utm_medium=referral">MARIOLA GROBELSKA</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Assessing the suitability of your linear model is imperative in machine learning. Depending on your assessment you may decide to stick with your model or use an alternative regressor in search of better results.</p><p>In tandem with the saying that a ‘picture is more than a thousand words’, the <a href="https://www.scikit-yb.org/en/latest/index.html"><strong>Yellowbrick library</strong></a> offers a convenient visualizer for this, namely, the residual plot visualizer.<a href="https://www.scikit-yb.org/en/latest/api/regressor/residuals.html"> <strong>The residuals plot visualizer </strong></a>plots the residuals on the y-axis against the predicted value of the dependent variable on the x-axis. Residuals refer to the difference between the observed and predicted value of the dependent variable (prediction error).</p><p>A random distribution of the residuals around the x-axis is indicative of the appropriateness of the linear model, whereas an otherwise distribution would suggest experimentation with a non-linear model. Another useful indicator within the plot is the R-squared value: a high value signaling that a high proportion of the variation in the target variable can be explained by the feature variables, whereas a low value says otherwise.</p><p>In this tutorial, we shall plot the visualizer with two different datasets and compare the results.</p><p><strong><em>Example 1</em></strong></p><p>In this particular case we shall use the <a href="https://www.scikit-yb.org/en/latest/api/regressor/residuals.html">exact example from Yellowbrick</a>. The code block is as below. Each line of code is preceded by an explanation (green font).</p><pre>#1.Import model<br>from sklearn.linear_model import Ridge<br><br>#2.Import train test split for splitting dataset<br>from sklearn.model_selection import train_test_split<br><br>#3.Import load_concrete dataset<br>from yellowbrick.datasets import load_concrete<br><br>#4.Import Residual Plot visualizer<br>from yellowbrick.regressor import ResidualsPlot<br><br>#5.Load data<br>X, y = load_concrete()<br><br>#6.Split data into train and test<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<br><br>#7.Instantiate the linear model <br>model = Ridge()<br><br>#8.Instantiate Residual Plot visualizer<br>visualizer = ResidualsPlot(model)<br><br>#9.Fit visualizer to training data<br>visualizer.fit(X_train, y_train)<br><br>#10.Fit visualizer to test data for evaluation<br>visualizer.score(X_test, y_test)<br><br>#11.Display visualizer<br>visualizer.show()        </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*49Pna2_Ydw1K1fKKlde9hw.png" /><figcaption>Figure 1 : Residual plot with load_concrete dataset</figcaption></figure><p><strong><em>Example 2</em></strong></p><p>In this example, we use a different dataset, namely, the bikeshare dataset. The rest of the code remains the same.</p><pre>#1.Import model<br>from sklearn.linear_model import Ridge<br><br>#2.Import train test split for splitting dataset<br>from sklearn.model_selection import train_test_split<br><br>#3.Import load_concrete dataset<br>from yellowbrick.datasets import load_bikeshare<br><br>#4.Import Residual Plot visualizer<br>from yellowbrick.regressor import ResidualsPlot<br><br>#5.Load data<br>X, y = load_bikeshare()<br><br>#6.Split data into train and test<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<br><br>#7.Instantiate the linear model <br>model = Ridge()<br><br>#8.Instantiate Residual Plot visualizer<br>visualizer = ResidualsPlot(model)<br><br>#9.Fit visualizer to training data<br>visualizer.fit(X_train, y_train)<br><br>#10.Fit visualizer to test data for evaluation<br>visualizer.score(X_test, y_test)<br><br>#11.Display visualizer<br>visualizer.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*FcKVROIPRee8w5WhoYXRnQ.png" /><figcaption>Residual plot with load_bikeshare dataset</figcaption></figure><p><strong><em>Discussion</em></strong></p><ol><li><strong>Distribution of residuals</strong>: An evaluation of the two examples, indicates that a linear model is more appropriate in example 1, whereas a non-linear regressor would be more appropriate for example two. In example 1, the distribution of residuals seems to follow a uniform, random pattern. Moreover, the distribution of the residuals in the adjoining histogram indicates a normal distribution around the zero point for the error. In contrast, the residuals in Example 2, are neither uniformly nor randomly distributed. An examination of the histogram also demonstrates a skewed distribution of the error around the zero point.</li><li><strong>R-squared value:</strong> In Example 1, the R-Squared value is much higher than it is in Example 2.</li></ol><p><strong><em>End!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a750f964bdb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Yellowbrick : Discrimination Threshold Visualizer]]></title>
            <link>https://medium.com/@kavengik/yellowbrick-discrimination-threshold-visualizer-f0105391efae?source=rss-b34c8112e05------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0105391efae</guid>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[yellow-brick]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[threshold]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <dc:creator><![CDATA[Kavengik]]></dc:creator>
            <pubDate>Fri, 07 Nov 2025 05:01:59 GMT</pubDate>
            <atom:updated>2025-11-07T05:01:59.717Z</atom:updated>
            <content:encoded><![CDATA[<h3>Yellowbrick : Discrimination Threshold Visualizer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qe0XhmCO6BzAwvYW" /><figcaption>Photo by <a href="https://unsplash.com/@evgenslavin?utm_source=medium&amp;utm_medium=referral">EVGEN SLAVIN</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Use cases involving binary classification are commonplace in machine learning. A common practice after fitting a binary classifier is to evaluate its performance against a set of metrics such as precision, recall and the f1 score.</p><p>Generally, these metrics are based on the default discrimination threshold of 0.5, such that observations are assigned to the positive class if their probability exceeds or equals 0.5 and the negative class otherwise. However, this threshold is not always optimal, hence why evaluation of the aforementioned metrics at different thresholds is desirable.</p><p>The <a href="https://www.scikit-yb.org/en/latest/api/classifier/threshold.html"><strong><em>Yellowbrick library</em></strong></a> has a convenient visualizer for this task. The <strong><em>discrimination threshold visualizer</em></strong> enables one to see how these metrics fair across diverse thresholds. Its implementation, as shown below, is pretty simple.</p><p><strong>Import libraries</strong></p><pre>#1.Import discrimination threshold visualizer<br>from yellowbrick.classifier.threshold import discrimination_threshold<br>#2.Import occupancy dataset<br>from yellowbrick.datasets import load_occupancy<br>#3.Importing the logistic regression model<br>from sklearn.linear_model import LogisticRegression</pre><p><strong>Model implementation and discrimination threshold visualization</strong></p><pre>#4.Load dataset<br>X, y = load_occupancy()<br>#5.Instantiate model<br>model = LogisticRegression()<br>#6.Instantiate visualizer,specify model and dataset within arguments<br>discrimination_threshold(model, X, y)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*VxbD34cmBxodMHqZPJc36w.png" /><figcaption>Discrimination threshold visualizer</figcaption></figure><p><strong>Conclusion</strong></p><p>From the diagram, it can be observed that the optimal threshold is slightly below 0.6, as indicated by the dashed line, and not the default 0.5.</p><p><strong>Note</strong></p><p>As indicated on the website, this visualizer only works with binary, probabilistic classifiers that leverage either of the following methods: <em>decision_function</em> or <em>predict_proba</em>.</p><p><strong><em>End!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0105391efae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Class Prediction Error visualizer: Multi-class classification]]></title>
            <link>https://medium.com/@kavengik/class-prediction-error-visualizer-multi-class-classification-9bf11b87b37f?source=rss-b34c8112e05------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bf11b87b37f</guid>
            <category><![CDATA[decision-tree]]></category>
            <category><![CDATA[evaluation]]></category>
            <category><![CDATA[multiclass-classification]]></category>
            <category><![CDATA[yellow-brick]]></category>
            <category><![CDATA[random-forest]]></category>
            <dc:creator><![CDATA[Kavengik]]></dc:creator>
            <pubDate>Fri, 24 Oct 2025 05:01:56 GMT</pubDate>
            <atom:updated>2025-10-24T05:01:56.524Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oEujeakBvVChw3YC" /><figcaption>Photo by <a href="https://unsplash.com/@phaelnogueira?utm_source=medium&amp;utm_medium=referral">Raphael Nogueira</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Building off previous tutorials, lets extend the <a href="https://www.scikit-yb.org/en/latest/api/classifier/class_prediction_error.html">Class Prediction Error visualizer in Yellowbrick</a> to a multi-class classification problem. We implement it as below.</p><p><strong>1.Multi-class classification: Random Forest</strong></p><pre>#1.Import necessary libraries<br>from sklearn.datasets import make_classification<br>from sklearn.model_selection import train_test_split<br>from sklearn.ensemble import RandomForestClassifier<br>from yellowbrick.classifier import ClassPredictionError<br><br>#2.Create dataset<br>X, y = make_classification(<br>    n_samples=1000, n_classes=5, n_informative=3, n_clusters_per_class=1,<br>    random_state=36,<br>)<br><br>#3.Name classes<br>classes = [&quot;embe&quot;, &quot;parachichi&quot;, &quot;papai&quot;, &quot;ndizi&quot;, &quot;chungwa&quot;]<br><br>#4. Perform 80/20 training/test split<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20,random_state=1)<br><br>#5.Instantiate classifier and visualizer<br>visualizer = ClassPredictionError(<br>    RandomForestClassifier(random_state=42, n_estimators=10), classes=classes<br>)<br><br>#6.Fit the training data to the visualizer<br>visualizer.fit(X_train, y_train)<br><br>#7.Evaluate model on test data<br>visualizer.score(X_test, y_test)<br><br>#7. Display visualizer<br>visualizer.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*y0IA0A-GqHugqGwffQ1NNw.png" /><figcaption>Figure 1: Class Prediction Error -Random Forest (multi-class)</figcaption></figure><p><strong>2.Multi-class class classification: Decision Tree Classifier</strong></p><pre>#1.Import ibraries<br><br>from sklearn.datasets import make_classification<br>from sklearn.model_selection import train_test_split<br>from sklearn.tree import DecisionTreeClassifier<br>from yellowbrick.classifier import ClassPredictionError<br><br><br>#2.Create dataset<br>X, y = make_classification(<br>    n_samples=1000, n_classes=5, n_informative=3, n_clusters_per_class=1,<br>    random_state=36,<br>)<br><br>#3.Name classes<br>classes = [&quot;embe&quot;, &quot;parachichi&quot;, &quot;papai&quot;, &quot;ndizi&quot;, &quot;chungwa&quot;]<br><br>#4. Perform 80/20 training/test split<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20,<br>                                                    random_state=1)<br><br>#5.Instantiate classifier and visualizer<br>visualizer = ClassPredictionError(DecisionTreeClassifier(), classes=classes)<br><br>#6. Fit the training data to the visualizer<br>visualizer.fit(X_train, y_train)<br><br>#7.Evaluate model on test data<br>visualizer.score(X_test, y_test)<br><br>#8. Display visualizer<br>visualizer.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*6A-cH1pcybkImxP0SA18eQ.png" /><figcaption>Figure 2: Class Prediction Error -Decision Tree (multi-class)</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bf11b87b37f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Class Prediction Error visualizer across algorithms: Yellowbrick library]]></title>
            <link>https://medium.com/@kavengik/class-prediction-error-visualizer-across-algorithms-yellowbrick-library-70ca183326fa?source=rss-b34c8112e05------2</link>
            <guid isPermaLink="false">https://medium.com/p/70ca183326fa</guid>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[evaluation]]></category>
            <category><![CDATA[yellow-brick]]></category>
            <category><![CDATA[random-forest]]></category>
            <category><![CDATA[classpredictionerror]]></category>
            <dc:creator><![CDATA[Kavengik]]></dc:creator>
            <pubDate>Fri, 10 Oct 2025 05:02:02 GMT</pubDate>
            <atom:updated>2025-10-10T05:02:02.675Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ILxV5oKVh3tFBaqJ" /><figcaption>Photo by <a href="https://unsplash.com/@mhphotography13?utm_source=medium&amp;utm_medium=referral">Mosharraf Hossain</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Classification in Machine Learning is an iterative task, often involving experimentation with different algorithms. So how well did your select algorithms do with respect to class prediction? <a href="https://www.scikit-yb.org/en/latest/api/classifier/class_prediction_error.html">Yellowbrick’s Class Prediction Error</a> offers a convenient way to visualize algorithm performance. In this tutorial, we demonstrate how to implement this visualizer with two algorithms — Random Forest and Logistic regression.</p><p><strong>Load data and machine learning modules</strong></p><p>We load the occupancy dataset. Then we load essential machine learning libraries for performance of essential tasks i.e. splitting the dataset, classification and visualization of classification results.</p><pre>#1.Load data<br>from yellowbrick.datasets import load_occupancy<br><br>#2.Load important ML modules<br>from sklearn.model_selection import train_test_split<br>from sklearn.ensemble import RandomForestClassifier<br>from sklearn.linear_model import LogisticRegression<br><br>#3.Load Yellowbrick&#39;s Class Prediction Error visualizer<br>from yellowbrick.classifier import ClassPredictionError<br></pre><p><strong>Split dataset</strong></p><p>We then proceed to load the data into respective categories i.e. feature and target. Then we assign the class categories to the target variable. Finally, we perform a 80/20 split on the feature and target datasets.</p><pre>#4.Split data into feature and target classes<br>X, y = load_occupancy()<br><br>#5.Assign the target classes as per the dataset<br>classes = [&#39;unoccupied&#39;, &#39;occupied&#39;]<br><br>#6. Split data into train and test (80/20)<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20,random_state=1)</pre><p><strong>Class Prediction Error: Random Forest Classifier</strong></p><p>We instantiate the Class Prediction Error visualizer, in which we also instantiate our first classification model i.e. Random Forest and also pass the target classes. Then we fit the visualizer to the train dataset and assess its performance on the test data.</p><pre>#7. Instantiate the classification model and visualizer<br>visualizer = ClassPredictionError(<br>    RandomForestClassifier(n_estimators=10), classes=classes)<br><br>#8.Fit training data to the visualizer<br>visualizer.fit(X_train, y_train)<br><br>#9.Model evaluation on test data<br>visualizer.score(X_test, y_test)<br><br>#10.Display visualizer<br>visualizer.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*QsJzzhNCEx6NRVXh5l2ZDA.png" /><figcaption>Figure 1: Class Prediction Error-Random Forest Classifier</figcaption></figure><p><strong>Class Prediction Error: Logistic Regression</strong></p><p>In this case, we instantiate our second classification model i.e. Logistic Regression and also pass the classes. Then we fit the visualizer to the train dataset and assess its performance on the test data.</p><pre>#11.Instantiate the classification model and visualizer<br>visualizer = ClassPredictionError(LogisticRegression(), classes=classes)<br><br>#12.Fit the training data to the visualizer<br>visualizer.fit(X_train, y_train)<br><br>#13.Evaluate the model on the test data<br>visualizer.score(X_test, y_test)<br><br>#14.Draw visualization<br>visualizer.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*4h4FDrW9soA2BHpqMH2PJw.png" /><figcaption>Figure 2: Class Prediction Error-Logistic Regression</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70ca183326fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Class Prediction Error Visualizer: Yellowbrick library]]></title>
            <link>https://medium.com/@kavengik/class-prediction-error-visualizer-yellowbrick-library-fd43a92a5f40?source=rss-b34c8112e05------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd43a92a5f40</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[yellow-brick]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[predictions]]></category>
            <dc:creator><![CDATA[Kavengik]]></dc:creator>
            <pubDate>Fri, 26 Sep 2025 05:01:54 GMT</pubDate>
            <atom:updated>2025-09-26T05:01:54.192Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KhhnZewo6XPGRm_V" /><figcaption>Photo by <a href="https://unsplash.com/@serrah?utm_source=medium&amp;utm_medium=referral">Serrah Galos</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>How well is your model doing at predicting each class? An easy visualizer for this scenario would be <a href="https://www.scikit-yb.org/en/latest/api/classifier/class_prediction_error.html"><strong>Yellowbrick’s Class Prediction Error visualizer</strong></a><strong>.</strong> Implementing it is very easy as illustrated in the code block below.</p><p><strong>Load data and machine learning modules</strong></p><p>We load the occupancy dataset. Then we load essential machine learning libraries for performance of essential tasks i.e. splitting the dataset, classification and visualization of classification results.</p><pre>#1.Load data<br>from yellowbrick.datasets import load_occupancy<br><br>#2.Load important ML modules<br>from sklearn.model_selection import train_test_split<br>from sklearn.ensemble import RandomForestClassifier<br><br>#3.Load Yellowbrick&#39;s Class Prediction Error visualizer<br>from yellowbrick.classifier import ClassPredictionError</pre><p><strong>Split dataset</strong></p><p>We then proceed to load the data into respective categories i.e. feature and target. Then we assign the class categories to the target variable. Finally, we perform an 80/20 split on the feature and target datasets.</p><pre>#4.Split data into feature and target classes<br>X, y = load_occupancy()<br><br>#5.Assign the target classes as per the dataset<br>classes = [&#39;unoccupied&#39;, &#39;occupied&#39;]<br><br>#6. Split data into train and test (80/20)<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20,<br>                                                    random_state=1)</pre><p><strong>Perform classification and display visualizer</strong></p><p>We instantiate the Class Prediction Error visualizer, in which we also instantiate our classification model i.e. Random Forest and also pass target classes. Then we fit the visualizer to the train dataset and assess its performance on the test data.</p><pre>#7. Instantiate the classification model and visualizer<br>visualizer = ClassPredictionError(<br>    RandomForestClassifier(n_estimators=10), classes=classes)<br><br>#8.Fit training data to the visualizer<br>visualizer.fit(X_train, y_train)<br><br>#9.Model evaluation on test data<br>visualizer.score(X_test, y_test)<br><br>#10.Display visualizer<br>visualizer.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*QsJzzhNCEx6NRVXh5l2ZDA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd43a92a5f40" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The things you only see when you slow down]]></title>
            <link>https://medium.com/@kavengik/the-things-you-only-see-when-you-slow-down-b156e918fa96?source=rss-b34c8112e05------2</link>
            <guid isPermaLink="false">https://medium.com/p/b156e918fa96</guid>
            <category><![CDATA[taking-time-out]]></category>
            <category><![CDATA[slowing-down]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Kavengik]]></dc:creator>
            <pubDate>Mon, 22 Sep 2025 05:01:53 GMT</pubDate>
            <atom:updated>2025-09-22T05:01:53.793Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HXxzJSa0YLNpzh_r" /><figcaption>Photo by <a href="https://unsplash.com/@emilbruckner?utm_source=medium&amp;utm_medium=referral">Emil Bruckner</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I spent the whole of last week hitting a wall on a final LLM project. So, after making no progress past a certain code block, I decided to set the notebook aside, and focus on other important things: basking in the sun, drinking black tea and eating millet flatbread. Needless to say, a week later, in a very unanticipated manner, a thought came to me. Turns out, my API link was incomplete, hence why I could never get past that particular code block.</p><p>The main takeaway for me was that some (if not many) solutions can only come when you slow down, which can be difficult to do when under pressure. Paradoxically, it is exactly that pressure, that can hamper problem-solving. Aside from pressure, slowing down is also unfortunately still associated with ‘laziness’ or ‘doing nothing’, which may explain why we would rather continue hitting a wall despite no results. In my opinion this is mainly ‘corporate sector logic’ i.e. the need to constantly appear to be on the go!</p><p>But if we are going by results, i.e. getting a solution to the problem, which was achieved by slowing down, then surely it is worth considering.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b156e918fa96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Precision-Recall Curve visualization: Yellowbrick]]></title>
            <link>https://medium.com/@kavengik/precision-recall-curve-visualization-yellowbrick-e111bc79c0a8?source=rss-b34c8112e05------2</link>
            <guid isPermaLink="false">https://medium.com/p/e111bc79c0a8</guid>
            <category><![CDATA[yellow-brick]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[precision]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[recall]]></category>
            <dc:creator><![CDATA[Kavengik]]></dc:creator>
            <pubDate>Fri, 12 Sep 2025 05:01:50 GMT</pubDate>
            <atom:updated>2025-09-12T05:01:50.899Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3XwVx_lEAQkY9m7H" /><figcaption>Photo by <a href="https://unsplash.com/@martin_lostak?utm_source=medium&amp;utm_medium=referral">Martin Lostak</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Precision and recall are important metrics in assessing the performance of a classification model. Precision is calculated by dividing true positives by the sum of true positives and false positives: TP/(TP+FP). Recall on the other hand is calculated by dividing true positives by the sum of true positives and false negatives: TP/(TP+FN). Visualization of these metrics is common practice. <a href="https://www.scikit-yb.org/en/latest/api/classifier/prcurve.html">The Yellowbrick library in Python </a>offers an easy visualizer for this. The code block below offers a step-by-step implementation of the visualizer.</p><pre>#1.Import libraries<br>from yellowbrick.datasets import load_occupancy<br>from sklearn.model_selection import train_test_split<br>from sklearn.linear_model import LogisticRegression<br>from yellowbrick.classifier import PrecisionRecallCurve<br><br>#2.Load data <br>X, y = load_occupancy()<br><br>#3.Split data into train and test<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size =0.2, random_state=1)<br><br>#4.Instantiate classification model: logistic regression<br>model = LogisticRegression()<br><br>#5.Instantiate PrecisionRecallCurve<br>visualizer = PrecisionRecallCurve(model)<br><br>#6.Fit model to training dataset<br>visualizer.fit(X_train, y_train)<br><br>#7.Evaluate on test data<br>visualizer.score(X_test, y_test)<br><br>#8.Display<br>visualizer.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*vosO-W-GMcq_VzhKnuZlXQ.png" /></figure><p><em>End!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e111bc79c0a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>