<?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 Dave Patel on Medium]]></title>
        <description><![CDATA[Stories by Dave Patel on Medium]]></description>
        <link>https://medium.com/@davepatel3?source=rss-9d67923443f4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dqeoFJS-ll9gJ0VndMhAsg.jpeg</url>
            <title>Stories by Dave Patel on Medium</title>
            <link>https://medium.com/@davepatel3?source=rss-9d67923443f4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:40:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@davepatel3/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[Why is Feature Engineering so Important?]]></title>
            <link>https://medium.com/@davepatel3/why-is-feature-engineering-so-important-6ac5f9586254?source=rss-9d67923443f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ac5f9586254</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[feature-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Dave Patel]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 13:02:09 GMT</pubDate>
            <atom:updated>2025-02-03T13:02:09.942Z</atom:updated>
            <content:encoded><![CDATA[<p>Many of you familiar with ML have probably heard something along the lines of: “Feature Engineering is one of the most important steps in Machine Learning” I know when I heard this for the first time, I struggled to understand what Feature Engineering actually entailed.</p><p>This article will hopefully make this term clearer by giving a clear definition and providing a practical example.</p><h3>What is Feature Engineering?</h3><p>A good way to think about the broad term of feature engineering is a combination of three smaller umbrella operations.</p><p>1) Feature Selection: This is the process of selecting a subset of all of your existing features for use in an ML model based on how important they are for the prediction of your target label. Some techniques used for Feature Selection are Pearson’s R correlation (only for data that is obviously linear), chi-square (for categorical data), and the build-in feature importance functions you can find for most tree-based models like Random Forest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/0*1ehkvUguGhcvmE81" /></figure><p>A visual depiction of feature selection</p><p>2) Feature Creation: This is the process of creating entirely new features based on existing individual features or by combining multiple existing features. For example, suppose you are working with stock data for NVIDIA — which would hypothetically include average daily stock price. One feature that you could add is average weekly stock price — which could help your model recognize patterns on a bigger time scale. In my opinion, Feature Creation is the hardest concept in the entire ML pipeline because you need to be quite creative to come up with new features that are helpful for your model as well as needing strong domain knowledge to come up with ideas for new features. The Feature Creation process can also be quite iterative and tedious, as there can be a lot of trial and error involved in knowing which new features improve model performance and which ones make performance worse. My example will give a good idea of the thought process needed to come up with good features.</p><p>3) Feature Transformation: This is the subsection of Feature Engineering that you would most likely already be familiar with and use on a regular basis with ML tasks. You are transforming existing features to make the data more compatible and cleaner for your ML model. This involves things like filling null values with the most frequent value/mean, performing One Hot Encoding, and scaling your numerical features between 0 and 1.</p><h3>Example of Feature Creation:</h3><p>I recently revisited the Kaggle Advanced Regression Techniques — House Prices competition in an attempt to specifically improve my feature engineering skills. This is a popular Kaggle competition for individuals with intermediate ML knowledge. The goal of this competition is to predict housing prices for unseen test data based on many factors about the house and nearby amenities, such as the presence/absence of railroads and the neighborhood the house is in. My example relates specifically to the neighborhood feature.</p><p>In the Kaggle dataset — there are about 25 different neighborhoods within the city of Ames, Iowa. (which is where all the houses are) When I initially saw this feature, my initial thought was something along the lines of — “This feature has way too many values and that kinda sucks”. Usually, a feature with too many values significantly increases dimensionality and makes it harder for the model to find patterns within that feature. The best transformation I thought of involving this feature was a new feature that still captured the general location of the house within Ames, Iowa without having so many dimensions. After a bit of thinking, I realized the general location could be captured through the cardinal directions: North, South, East, West, and Central. Below is a map of the Ames, Iowa neighborhoods that I used to help me with this. (<a href="https://www.cityofames.org/home/showpublisheddocument/52755/637050278030900000">637050278030900000)</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Wm8h3KoxFad-Bvkg" /></figure><p>Ames Map</p><p>For all of the neighborhoods present in my Kaggle data, I would find the associated neighborhood on the above map and visually judge which region of Ames it was in: North, West, South, East, or Central. I also added an additional category named ISU for Iowa State University, as the University housing prices would likely differ from the other regions. In order to create this new feature, I created a dictionary mapping my Kaggle neighborhoods to the general regions and then applied this mapping to my existing feature. My resultant column improved my score from 0.15690 to 0.15542 — which is not a huge numerical difference, but is a large improvement caused by just one additional feature. The major takeaway from this example should be: Try to be as creative as possible when coming up with ideas for new features and do not shy away from doing manual research of your own! (Like finding the above map)</p><p>In conclusion, Feature Engineering is a very broad term — but you can distill it into the critical elements of Feature Creation, Feature Transformation, and Feature Selection. Creativity and Domain Knowledge are the most important parts of the broad Feature Engineering process. I hope this article helps you out with your ML endeavors!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ac5f9586254" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scaling in Python: A Powerful Way to Transform your Data]]></title>
            <link>https://pub.aimind.so/scaling-in-python-a-powerful-way-to-transform-your-data-38a0802c7dc8?source=rss-9d67923443f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/38a0802c7dc8</guid>
            <dc:creator><![CDATA[Dave Patel]]></dc:creator>
            <pubDate>Mon, 24 Jul 2023 14:01:50 GMT</pubDate>
            <atom:updated>2023-07-24T15:00:14.056Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine you have a dataset with hundreds of numerical features. Each feature has a different range of numerical values, with some clustered between one and ten while others are anywhere between one and ten thousand. Training any Machine Learning model on a dataset such as this is bound to end badly. Due to the differences in range of the features, training a model is likely going to take a lot longer than if the features had the same range because the math computations to either minimize the cost function using Gradient Descent or find the optimal model parameters using a closed form equation will take significantly longer. This is where scaling comes into play. Scaling is just a way of transforming features so that they all share the same range. Doing so can significantly improve the time to train your model and model performance. In this article, I will first explain some basic statistics, such as z-scores, distributions, and outliers. Then, I will go over two different scaling techniques found within scikit-learn: StandardScaler() and MinMaxScaler(), both of which have their own benefits and drawbacks. Finally, I will explain when you should use each of these techniques and go over some code examples.</p><h3>The Statistics of Scaling</h3><p>The most important idea in all of statistics is the concept of a distribution. Below is an example of a distribution you have most definitely seen many times before:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/0*MHYAN_nv2kB1TZjP.png" /></figure><p>A distribution describes how data points are spread in a field. For example, the distribution above, called a Normal Distribution, is symmetrical and has most data contained within two standard deviations on either side of the mean. Below is Python code that generates a random distribution that is approximately normally distributed to show the heights of students within a class in inches.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br># Sample data - normally distributed heights of students in inches<br>mean_height = 65.5<br>std_deviation = 3.0<br>num_students = 1000<br>heights = np.random.normal(mean_height, std_deviation, num_students)<br><br># Calculate mean and standard deviation<br>mean_value = np.mean(heights)<br>std_value = np.std(heights)<br><br># Create the plot<br>plt.figure(figsize=(8, 6))<br>plt.hist(heights, bins=30, edgecolor=&#39;black&#39;, alpha=0.7)<br>plt.title(&#39;Height Distribution of Students in a Class&#39;)<br>plt.xlabel(&#39;Height (inches)&#39;)<br>plt.ylabel(&#39;Frequency&#39;)<br>plt.grid(True)<br><br># Print mean and standard deviation<br>print(&quot;Mean height: {:.2f} inches&quot;.format(mean_value))<br>print(&quot;Standard deviation: {:.2f} inches&quot;.format(std_value))<br><br>plt.show()</pre><p>Another important statistics concept is the idea of a z-score. In simple terms, a z-score is a measure of how many standard deviations away the data point is from the mean of the data. The formula below illustrates how this measurement is actually calculated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/0*B7PWpoNvIVHx-KSz.GIF" /><figcaption>Formula for z-score</figcaption></figure><p>All the formula does is find the difference between the data point and the mean of the data, and then divides that by the standard deviation of the data. This mathematical principle is the underpinning of how many data scalers work. Now, we will delve deeper into the use cases and inner workings of the StandardScaler() functionality from scikit-learn.</p><h3>Utilizing StandardScaler()</h3><p>Imagine you teach three sections of high school calculus. You have just finished grading each section’s final exams and want to use this data to predict how future calculus sections will perform on the exact same exam. You make a graph that shows all three section’s exam performances and notice that each section follows an approximately normal distribution, as the following code demonstrates.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from sklearn.preprocessing import StandardScaler<br><br># Set random seed for reproducibility<br>np.random.seed(41)<br><br># Generate synthetic data for three sections<br>num_students = 100<br>mean_scores = [85, 78, 92]<br>std_deviation = 5<br><br>scores_sec1 = np.random.normal(mean_scores[0], std_deviation, num_students)<br>scores_sec2 = np.random.normal(mean_scores[1], std_deviation, num_students)<br>scores_sec3 = np.random.normal(mean_scores[2], std_deviation, num_students)<br><br># Create the plot with different colors for each section<br>plt.figure(figsize=(10, 6))<br>plt.hist(scores_sec1, bins=20, edgecolor=&#39;black&#39;, alpha=0.7, color=&#39;blue&#39;, label=&#39;Section 1&#39;)<br>plt.hist(scores_sec2, bins=20, edgecolor=&#39;black&#39;, alpha=0.7, color=&#39;green&#39;, label=&#39;Section 2&#39;)<br>plt.hist(scores_sec3, bins=20, edgecolor=&#39;black&#39;, alpha=0.7, color=&#39;orange&#39;, label=&#39;Section 3&#39;)<br><br>plt.title(&#39;Final Exam Scores - High School Calculus Sections&#39;)<br>plt.xlabel(&#39;Score&#39;)<br>plt.ylabel(&#39;Frequency&#39;)<br>plt.legend()<br>plt.grid(True)<br><br>plt.show()</pre><p>After seeing this visualization, you remember that machine learning models work best on data that is scaled. But which scaling algorithm would be the best choice in this scenario? After a bit of thinking, you decide that StandardScaler() is the best fit, since all three of your features (which are your sections) are approximately normally distributed. If your data has outliers or some features are not normally distributed, then it is likely a better idea to use one of the other scalers. The way that this scaler works is pretty intuitive. The mean and standard deviation is calculated for every feature. Then, the z-score is calculated for every data point in each column, which scales each column around zero with a standard deviation of one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/0*187MEbxkahvPBgm4.png" /></figure><p>The below code demonstrates using StandardScaler() on the section data from above. Just to note, StandardScaler() is quite sensitive to outliers, so it will not work optimally on non-normal features/data.</p><pre><br># Combine the scores from all sections into a single array<br>all_scores = np.concatenate([scores_sec1, scores_sec2, scores_sec3])<br><br># Reshape the data to a 2D array (necessary for StandardScaler)<br>all_scores_reshaped = all_scores.reshape(-1, 1)<br><br># Create the StandardScaler object<br>scaler = StandardScaler()<br><br># Fit and transform the data using StandardScaler<br>scaled_scores = scaler.fit_transform(all_scores_reshaped)<br><br># Create a DataFrame from the scaled data<br>df_scaled_scores = pd.DataFrame(scaled_scores, columns=[&#39;Scaled Scores&#39;])<br><br># Display the DataFrame<br>print(df_scaled_scores.head())</pre><h3>Utilizing MinMaxScaler()</h3><p>Imagine now that you are grading the scores of the calculus final exams for your three sections the following year. You again decide to make a graph that shows how the scores are distributed. You notice this time that the scores are not normally distributed. You also want the scores to be scaled between the range of zero and five. These two conditions are usually very well suited for using MinMaxScaler(). The below code illustrates such distributions of section scores:</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from sklearn.preprocessing import MinMaxScaler<br><br># Set random seed for reproducibility<br>np.random.seed(42)<br><br># Generate synthetic data for three sections with skewed distributions<br>num_students = 100<br>mean_scores = [85, 78, 92]<br><br># Define skewness values for each section (positive skewness)<br>skewness_values = [3, 2, 1.5]<br><br># Generate skewed scores for each section using the beta distribution<br>scores_sec1 = 100 * np.random.beta(skewness_values[0], 1, num_students)<br>scores_sec2 = 100 * np.random.beta(skewness_values[1], 1, num_students)<br>scores_sec3 = 100 * np.random.beta(skewness_values[2], 1, num_students)<br><br># Create the plot with distinct colors and reduced opacity<br>plt.figure(figsize=(10, 6))<br>plt.hist(scores_sec1, bins=20, range=(0, 100), edgecolor=&#39;black&#39;, alpha=0.6, color=&#39;blue&#39;, label=&#39;Section 1&#39;, density=True)<br>plt.hist(scores_sec2, bins=20, range=(0, 100), edgecolor=&#39;black&#39;, alpha=0.6, color=&#39;green&#39;, label=&#39;Section 2&#39;, density=True)<br>plt.hist(scores_sec3, bins=20, range=(0, 100), edgecolor=&#39;black&#39;, alpha=0.6, color=&#39;orange&#39;, label=&#39;Section 3&#39;, density=True)<br><br>plt.title(&#39;Final Exam Scores - High School Calculus Sections (Skewed Distributions)&#39;)<br>plt.xlabel(&#39;Score&#39;)<br>plt.ylabel(&#39;Frequency&#39;)<br>plt.legend()<br>plt.grid(True)<br><br>plt.show()</pre><p>The way that MinMaxScaler() works internally is a bit different than the StandardScaler() above. Instead of using z-scores to scale, a linear transformation is applied directly to scale the data to a custom range. First, for each feature, the minimum and maximum value is calculated. Then, the data is scaled to a custom range using the formula below, which applies a linear transformation to each feature. In the formula below, a and b indicate the lower and upper bounds that you want your features scaled between (0 and 5 in this example), x is the value of the data point itself, and data_min and data_max are the minimum and maximum values of the feature itself.</p><pre>x_scaled_custom = (x - data_min) * (b - a) / (data_max - data_min) + a</pre><p>The below code applies a MinMaxScaler() to the skewed section data described above and scales between the custom range of 0 and 5.</p><pre><br># Combine the scores from all sections into a single array<br>all_scores = np.concatenate([scores_sec1, scores_sec2, scores_sec3])<br><br># Reshape the data to a 2D array (necessary for MinMaxScaler)<br>all_scores_reshaped = all_scores.reshape(-1, 1)<br><br># Create the MinMaxScaler object with the desired feature range [0, 5]<br>scaler = MinMaxScaler(feature_range=(0, 5))<br><br># Fit and transform the data using MinMaxScaler<br>scaled_scores = scaler.fit_transform(all_scores_reshaped)<br><br># Create a DataFrame from the scaled data<br>df_scaled_scores = pd.DataFrame(scaled_scores, columns=[&#39;Scaled Scores&#39;])<br><br># Display the DataFrame<br>print(df_scaled_scores.head())</pre><p>That is all for this article, where I described two of the most used scaling functionalities available in scikit-learn, StandardScaler() and MinMaxScaler(). I then gave some examples of when to use each scaler and how to use them through code. I hope you found this article helpful, and if you did, please consider following for more articles on machine learning and data science!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38a0802c7dc8" width="1" height="1" alt=""><hr><p><a href="https://pub.aimind.so/scaling-in-python-a-powerful-way-to-transform-your-data-38a0802c7dc8">Scaling in Python: A Powerful Way to Transform your Data</a> was originally published in <a href="https://pub.aimind.so/">AI Mind</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Three Critical but Overlooked Python Machine Learning Concepts]]></title>
            <link>https://pub.aimind.so/three-critical-but-overlooked-python-machine-learning-concepts-67c9ade83292?source=rss-9d67923443f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/67c9ade83292</guid>
            <category><![CDATA[data-preprocessing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[sklearn]]></category>
            <dc:creator><![CDATA[Dave Patel]]></dc:creator>
            <pubDate>Wed, 05 Jul 2023 13:32:15 GMT</pubDate>
            <atom:updated>2023-07-11T02:53:17.126Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*AsKxfwYHY7NrBkCVsqwaTQ.jpeg" /></figure><p>When thinking of how to approach a Supervised Machine Learning(ML) project, the process starting from obtaining your data all the way to deploying your model can often feel scripted in just a few steps:</p><ol><li>Obtain your data and convert the data file to your desired format</li><li>Split your data into a train and test set and select a performance measure</li><li>Explore and Visualize your data</li><li>Clean your data and perform Feature Engineering/Selection</li><li>Train numerous models and select the best performing ones</li><li>Perform Hyperparameter tuning and pick the best performing model</li><li>Deploy this model</li></ol><p>Those just getting started with ML tend to think that there is only one correct way of performing some of the above steps. For example, thinking that SKLearn’s train_test_split() functionality is the only way to create a train and a test set. (Despite there being numerous other ways to do so). This article will delve into some critical ML functionalities that often get overlooked but can immensely improve various aspects of a end to end project.</p><h4>1) Utilizing StratifiedShuffleSplit() to split data to follow a distribution</h4><p>Usually when splitting a dataset, we either use the train_test_split functionality or manually separate the data as shown below:</p><pre>#X and y can be any dataframe for this example. <br>X_train, X_test, y_train, y_test = X[:5], X[5:], y[:5], y[5:]</pre><pre>X = [[1, 2], [3, 4], [5, 6], [7, 8]]<br>y = [0, 1, 0, 1]<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)</pre><p>Both of these approaches are great when we have large and balanced datasets, since the size and balance of the dataset make it likely that we will get representative training and testing sets. However, this approach becomes problematic when we have smaller and/or unbalanced datasets. For example, suppose we have data for 100 computer science graduates such as their undergraduate GPA, the most notable company they interned with, their starting salary (which is the label in this example), etc… Based on this data, we have to train a ML model that can predict the average starting salary for future computer science graduates. Using train_test_split can easily introduce bias into our model by creating random instances of training and/or testing sets that heavily favor certain attributes. Going back to our computer science graduates example, lets say that train_test_split() gave us a training set with 80% of the rows being graduates that interned at a FAANG company. Our model will generalize poorly and make inaccurate predictions on new graduate data because our model is not well trained on graduates that have not interned at FAANG companies and graduates that have not interned for any companies. We need a way of splitting our training and test sets such that certain criteria are met (EX: Only 20% of graduates could have FAANG internships) to prevent underrepresentation of certain data groups and poor generalization on new data. This can be achieved by using the StratifiedShuffleSplit() functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*B4M3fa0JnVsBLXTv5OsoJg.png" /></figure><p>Instead of stratifying by most prominent intern company, let us stratify by the integer feature undergraduate GPA, which is far easier to work with than the categorical feature of intern company.</p><pre>#cs_grads is the name of the dataframe<br>#cs_grades is the name of the column containing grades from 0.0-4.0<br>from sklearn.model_selection import StratifiedShuffleSplit<br>cs_grads[&quot;grade_dist&quot;] = pd.cut(cs_grads[&quot;grades&quot;],<br>                         bins = [0., 1.0, 2.0, 3.0, 4.0],<br>                         labels = [&quot;F&quot;, &quot;D&quot;, &quot;C-B&quot;, &quot;B-A&quot;])<br>split = StratifiedShuffleSplit(n_splits=1, test_size=0.2, random_state=42)<br>for train, test in split.split(cs_grads, cs_grads[&quot;grade_dist&quot;]):<br>    stratified_train_set = cs_grads.loc[train]<br>    stratified_test_set = cs_grads.loc[test]</pre><p>In the code above, we first turn the numerical attribute of undergraduate GPA into a categorical attribute that roughly translates to their average letter grade. We then use StratifiedShuffleSplit() with 0.2% of the data going to the test set and 0.8% percent to the training set, with a random state of 42 to ensure reproducibility, as well as a loop, in order to create the training and testing sets.</p><h4>2) Using the n_jobs parameter to significantly speed up processes</h4><p>When executing code to train any model or tune hyperparameters, by default, only 1 CPU is used, which is fine for smaller datasets. However, if we have a dataset with 250,000 rows, training a model with only 1 CPU is going to take many hours, if not longer. This is where the n_jobs parameter comes into play. This parameter allows you to define the number of concurrently running CPUS/workers, which will significantly speed up the training of models and hyperparameter tuning. The below code and image illustrate how using increased CPUs to fit a model can speed up fitting and tuning processes.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from sklearn.datasets import load_breast_cancer<br>from sklearn.ensemble import RandomForestClassifier<br>import time<br><br>breast_cancer = load_breast_cancer()<br><br>execution_times = []<br>n_jobs_values = range(1, 7)  # Test values from 1 to 6 for n_jobs<br><br>for n_jobs in n_jobs_values:<br>    start_time = time.time()<br>    model = RandomForestClassifier(n_jobs=n_jobs)<br>    model.fit(breast_cancer.data, breast_cancer.target)<br>    end_time = time.time()<br>    execution_time = end_time - start_time<br>    execution_times.append(execution_time)<br><br>plt.plot(n_jobs_values, execution_times, marker=&#39;o&#39;)<br>plt.xlabel(&#39;n_jobs&#39;)<br>plt.ylabel(&#39;Execution Time (seconds)&#39;)<br>plt.title(&#39;Random Forest Classifier Fitting Time vs. n_jobs&#39;)<br>plt.grid(True)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*Y6R-p8ihNSsaK_Kax0acsw.png" /></figure><p>The code above is loading in the breast cancer dataset, a popular dataset for classification. I then train a random forest classifier with the n_jobs parameter varying from one to six, with six being all CPUs on my computer. Surprisingly, 3 CPUs gives the lowest fitting time instead of 6 CPUs. When adding more parallel processes, it becomes quite difficult to predict how long it takes for each process and the entire execution of the code to run. Because of this, the amount of CPUs does not necessarily linearly correlate to decreased fitting time. In the graph above, 3 CPUs seems to only decrease the running time by 0.01 seconds, which is due to the small size of the breast cancer dataset. However, when we look at the 8% decrease in running time between 1 and 3 CPUs, we can see why the n_jobs parameter could be so useful for larger datasets, where increasing the number of CPUs could decrease running time by many minutes or even hours.</p><h4>3) Use cross-validation instead of creating a validation set</h4><p>Usually we create a training, test, and a validation set to train, optimize, and test our model respectively. While the training and testing sets are absolutely necessary, the validation set can often feel cumbersome and inefficient. It feels like we are not using the data to its full potential during training when we are just leaving the validation set in holdout until the very last phases of improving our model before trying the model on the test data. What if there was a way to only have just the training and testing sets while still being able to evaluate the model on unseen set combinations? Turns out, cross-validation is our solution!. In short, cross-validation splits your data into k folds, where each fold contains a random training and testing subset. Then, cross-validation trains the model on each folds training data, and returns a score for that folds test data. The code snippet below is part of the wonderful book “Hands-On Machine Learning with Scikit-Learn, Keras, and Tensorflow” and I encourage you to read through it as I have been doing to learn all of the details of Python Machine Learning. To view the code from this book, check out this GitHub: <a href="https://github.com/ageron/handson-ml2/blob/master/02_end_to_end_machine_learning_project.ipynb">https://github.com/ageron/handson ml2/blob/master/02_end_to_end_machine_learning_project.ipynb</a></p><pre>lin_scores = cross_val_score(lin_reg, housing_prepared, housing_labels,<br>                             scoring=&quot;neg_mean_squared_error&quot;, cv=10)<br>lin_rmse_scores = np.sqrt(-lin_scores)<br>display_scores(lin_rmse_scores)<br><br>def display_scores(scores):<br>    print(&quot;Scores:&quot;, scores)<br>    print(&quot;Mean:&quot;, scores.mean())<br>    print(&quot;Standard deviation:&quot;, scores.std())<br><br>display_scores(tree_rmse_scores)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SqcvIYyrOAS18S3xWGKypA.jpeg" /></figure><p>The code segment is using cross_val_score to split the data into 10 folds, each with training and testing subsets from the overlying training set of housing_prepared and overlying test set of housing_labels. The function display_scores is then used to print the score for each fold and mean + Standard Deviation for all 10 folds.</p><p>I hope these three critical concepts help you in improving your end-to-end ML projects. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67c9ade83292" width="1" height="1" alt=""><hr><p><a href="https://pub.aimind.so/three-critical-but-overlooked-python-machine-learning-concepts-67c9ade83292">Three Critical but Overlooked Python Machine Learning Concepts</a> was originally published in <a href="https://pub.aimind.so/">AI Mind</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>