Trending March 2024 # ‘Ted Lasso’ Cast Members Attend Q&A At The Grove Apple Store, Opening Today # Suggested April 2024 # Top 5 Popular

You are reading the article ‘Ted Lasso’ Cast Members Attend Q&A At The Grove Apple Store, Opening Today updated in March 2024 on the website Katfastfood.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested April 2024 ‘Ted Lasso’ Cast Members Attend Q&A At The Grove Apple Store, Opening Today

Jason Sudeikis and other Ted Lasso cast members have attended a Q&A event at The Grove, the LA Apple Store opening today.

Apple says that the store, which originally opened in 2002, is now twice the size and has been “entirely reimagined” …

CEO Tim Cook said that the evening was “unforgettable,” but the Q&A itself hasn’t yet been shared.

Apple’s announcement mostly reiterated the awards won by the show.

Cast members of Apple’s multi-winning comedy series “Ted Lasso” attended a special Q&A event today at Apple’s newest retail location at The Grove in Los Angeles, CA ahead of its opening to the public tomorrow. The event takes place on the heels of “Ted Lasso” making history as the most Emmy Award-nominated freshman comedy series and landing seven Emmy Awards, including Outstanding Comedy Series, Outstanding Actor in a Comedy Series, Outstanding Supporting Actor in a Comedy Series, and Outstanding Supporting Actress in a Comedy Series […]

In addition to the Emmy Award honors, the first season of “Ted Lasso” has also been recognized with an esteemed Peabody Award; a SAG Award for Outstanding Performance by a Male Actor in a Comedy Series Award for Sudeikis; three Critics Choice Awards for Best Comedy Series, Best Actor in a Comedy Series for Sudeikis, and Best Supporting Actress in a Comedy Series for Hannah Waddingham, sweeping all categories in which the series was nominated; a Best Actor in a Comedy Series at the Golden Globe Awards for Sudeikis; and the Writers Guild of America crowned “Ted Lasso” with wins for both Best Comedy and Best New Series. “Ted Lasso” is also the only comedy series honored as an AFI Program of the Year and has picked up nominations from the Producers Guild of America for Comedy Series, as well as honors from many other guilds and critics groups […]

Star, creator and executive producer Jason Sudeikis (Ted Lasso), executive producer Brendan Hunt (Coach Beard), Juno Temple (Keeley), Brett Goldstein (Roy Kent, writer) and Cristo Fernandez (Dani Rojas) sat down at Apple The Grove for a conversation moderated by Yvette Nicole Brown.

Cook tweeted a couple of photos from the event.

An unforgettable evening with @JasonSudeikis and the cast of @TedLasso! Thank you for spending time with us in our beautiful new store, Apple The Grove, ahead of our grand opening tomorrow! chúng tôi Tim Cook (@tim_cook) November 19, 2023

The company also threw in a plug for the photographic capabilities of the iPhone 13, though the photo walk is predictably already fully booked.

The brand-new store […] will open its doors to the public on Friday, November 19, serving as an entirely reimagined destination for the LA community to discover Apple’s products and services, shop, get support and participate in free Today at Apple sessions, including Photo Walks.

In time for the holiday season, participants at The Grove can register to take a festive walk familiarizing themselves with iPhone 13 Pro features, including how to take stunning macro photos using the Ultra Wide camera, record video with Cinematic mode, and shoot with all-new Photographic Styles.

You may find the walk available at other stores.

FTC: We use income earning auto affiliate links. More.

You're reading ‘Ted Lasso’ Cast Members Attend Q&A At The Grove Apple Store, Opening Today

Lasso & Ridge Regression

37 minutes

⭐⭐⭐⭐⭐

Rating: 5 out of 5.

Introduction

Regression models work like magic in predicting the future using machine learning. Using these, businesses can predict future purchases and make better-informed decisions and future plans. In this article, I will tell you everything you need to know about regression models and how they can be used to solve prediction problems. We will extensively cover the basics of linear, lasso, and ridge regression models and learn how they are implemented in Python and R.

Learning Objectives

Understand and implement linear regression techniques for predictive modeling.

Understand regularization in regression models.

Build Lasso, Ridge, and Elastic Net regression models.

Are you a beginner looking for a place to start your data science journey? Presenting a comprehensive course full of knowledge and data science learning curated just for you!

Learning Example

Take a moment to list down all those factors you can think, on which the sales of a store will be dependent on. For each factor create an hypothesis about why and how that factor would influence the sales of various products. For example – I expect the sales of products to depend on the location of the store, because the local residents in each area would have different lifestyle. The amount of bread a store will sell in Ahmedabad would be a fraction of similar store in Mumbai.

Similarly list down all possible factors you can think of.

How many factors were you able to think of? If it is less than 15, give it more time and think again! A seasoned data scientist working on this problem would possibly think of tens and hundreds of such factors.

With that thought in mind, I am providing you with one such data set – The Big Mart Sales. In the data set, we have product wise Sales for Multiple outlets of a chain.

Let’s us take a snapshot of the dataset:

In the dataset, we can see characteristics of the sold item (fat content, visibility, type, price) and some characteristics of the outlet (year of establishment, size, location, type) and the number of the items sold for that particular item. Let’s see if we can predict sales using these features.

Simple Models for Prediction

Let us start with making predictions using a few simple ways to start with. If I were to ask you, what could be the simplest way to predict the sales of an item, what would you say?

Model 1 – Mean sales:

Even without any knowledge of machine learning, you can say that if you have to predict sales for an item – it would be the average over last few days . / months / weeks.

It is a good thought to start, but it also raises a question – how good is that model?

Turns out that there are various ways in which we can evaluate how good is our model. The most common way is Mean Squared Error. Let us understand how to measure it.

Prediction error

To evaluate how good is a model, let us understand the impact of wrong predictions. If we predict sales to be higher than what they might be, the store will spend a lot of money making unnecessary arrangement which would lead to excess inventory. On the other side if I predict it too low, I will lose out on sales opportunity.

So, the simplest way of calculating error will be, to calculate the difference in the predicted and actual values. However, if we simply add them, they might cancel out, so we square these errors before adding. We also divide them by the number of data points to calculate a mean error since it should not be dependent on number of data points.

This is known as the mean squared error.

Here e1, e2 …. , en are the difference between the actual and the predicted values.

So, in our first model what would be the mean squared error? On predicting the mean for all the data points, we get a mean squared error = 29,11,799. Looks like huge error. May be its not so cool to simply predict the average value.

Let’s see if we can think of something to reduce the error. Here is a live coding window to predict target using mean.



Model 2 – Average Sales by Location:

We know that location plays a vital role in the sales of an item. For example, let us say, sales of car would be much higher in Delhi than its sales in Varanasi. Therefore let us use the data of the column ‘Outlet_Location_Type’.

So basically, let us calculate the average sales for each location type and predict accordingly.

On predicting the same, we get mse = 28,75,386, which is less than our previous case. So we can notice that by using a characteristic[location], we have reduced the error.

Now, what if there are multiple features on which the sales would depend on. How would we predict sales using this information? Linear regression comes to our rescue.

What Is Linear Regression?

Linear regression is the simplest and most widely used statistical technique for predictive modeling. It basically gives us an equation, where we have our features as independent variables, on which our target variable [sales in our case] is dependent upon.

So what does the equation look like? Linear regression equation looks like this:

Here, we have Y as our dependent variable (Sales), X’s are the independent variables and all thetas are the coefficients. Coefficients are basically the weights assigned to the features, based on their importance. For example, if we believe that sales of an item would have higher dependency upon the type of location as compared to size of store, it means that sales in a tier 1 city would be more even if it is a smaller outlet than a tier 3 city in a bigger outlet. Therefore, coefficient of location type would be more than that of store size.

So, firstly let us try to understand linear regression with only one feature, i.e., only one independent variable. Therefore our equation becomes,

This equation is called a simple linear regression equation, which represents a straight line, where ‘Θ0’ is the intercept, ‘Θ1’ is the slope of the line. Take a look at the plot below between sales and MRP.

Surprisingly, we can see that sales of a product increases with increase in its MRP. Therefore the dotted red line represents our regression line or the line of best fit. But one question that arises is how you would find out this line?

How to Find the Line of Best Fit

As you can see below there can be so many lines which can be used to estimate Sales according to their MRP. So how would you choose the best fit line or the regression line?

The main purpose of the best fit line is that our predicted values should be closer to our actual or the observed values, because there is no point in predicting values which are far away from the real values. In other words, we tend to minimize the difference between the values predicted by us and the observed values, and which is actually termed as error. Graphical representation of error is as shown below. These errors are also called as residuals. The residuals are indicated by the vertical lines showing the difference between the predicted and actual value.

Okay, now we know that our main objective is to find out the error and minimize it. But before that, let’s think of how to deal with the first part, that is, to calculate the error. We already know that error is the difference between the value predicted by us and the observed value. Let’s just consider three ways through which we can calculate error:

Sum of residuals (∑(Y – h(X))) – it might result in cancelling out of positive and negative errors.

Sum of square of residuals ( ∑ (Y-h(X))2) – it’s the method mostly used in practice since here we penalize higher error value much more as compared to a smaller one, so that there is a significant difference between making big errors and small errors, which makes it easy to differentiate and select the best fit line.

Therefore, sum of squares of these residuals is denoted by:

where, h(x) is the value predicted by us,  h(x) =Θ1*x +Θ0 , y is the actual values and m is the number of rows in the training set.

The cost Function

So let’s say, you increased the size of a particular shop, where you predicted that the sales would be higher. But despite increasing the size, the sales in that shop did not increase that much. So the cost applied in increasing the size of the shop, gave you negative results.

So, we need to minimize these costs. Therefore we introduce a cost function, which is basically used to define and measure the error of the model.

If you look at this equation carefully, it is just similar to sum of squared errors, with just a factor of 1/2m is multiplied in order to ease mathematics.

So in order to improve our prediction, we need to minimize the cost function. For this purpose we use the gradient descent algorithm. So let us understand how it works.

Gradient Descent

Let us consider an example, we need to find the minimum value of this equation,

Y= 5x + 4x^2. In mathematics, we simple take the derivative of this equation with respect to x, simply equate it to zero. This gives us the point where this equation is minimum. Therefore substituting that value can give us the minimum value of that equation.

Gradient descent works in a similar manner. It iteratively updates Θ, to find a point where the cost function would be minimum. If you wish to study gradient descent in depth, I would highly recommend going through this article.

Using Linear Regression for Prediction

Now let us consider using Linear Regression to predict Sales for our big mart sales problem.

Model 3 – Enter Linear Regression:

From the previous case, we know that by using the right features would improve our accuracy. So now let us use two features, MRP and the store establishment year to estimate sales.

Now, let us built a linear regression model in python considering only these two features.

In this case, we got mse = 19,10,586.53, which is much smaller than our model 2. Therefore predicting with the help of two features is much more accurate.

Let us take a look at the coefficients of this linear regression model.

Therefore, we can see that MRP has a high coefficient, meaning items having higher prices have better sales.

R Square and Adjusted R-Square

How accurate do you think the model is? Do we have any evaluation metric, so that we can check this? Actually we have a quantity, known as R-Square.

R-Square: It determines how much of the total variation in Y (dependent variable) is explained by the variation in X (independent variable). Mathematically, it can be written as:

The value of R-square is always between 0 and 1, where 0 means that the model does not model explain any variability in the target variable (Y) and 1 meaning it explains full variability in the target variable.

Now let us check the r-square for the above model.

In this case, R² is 32%, meaning, only 32% of variance in sales is explained by year of establishment and MRP. In other words, if you know year of establishment and the MRP, you’ll have 32% information to make an accurate prediction about its sales.

Now what would happen if I introduce one more feature in my model, will my model predict values more closely to its actual value? Will the value of R-Square increase?

Let us consider another case.

Model 4 – Linear regression with more variables

We learnt, by using two variables rather than one, we improved the ability to make accurate predictions about the item sales.

So, let us introduce another feature ‘weight’ in case 3. Now let’s build a regression model with these three features.

ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’).

It produces an error, because item weights column have some missing values. So let us impute it with the mean of other non-null entries.

train['Item_Weight'].fillna((train['Item_Weight'].mean()), inplace=True)

Let us try to run the model again.

Therefore we can see that the mse is further reduced. There is an increase in the value R-square, does it mean that the addition of item weight is useful for our model?

Adjusted R-square

The only drawback of R2 is that if new predictors (X) are added to our model, R2 only increases or remains constant but it never decreases. We can not judge that by increasing complexity of our model, are we making it more accurate?

That is why, we use “Adjusted R-Square”.

The Adjusted R-Square is the modified form of R-Square that has been adjusted for the number of predictors in the model. It incorporates model’s degree of freedom. The adjusted R-Square only increases if the new term improves the model accuracy.

where

R2 = Sample R square

p = Number of predictors

N = total sample size

Using All the Features for Prediction

Now let us built a model containing all the features. While building the regression models, I have only used continuous features. This is because we need to treat categorical variables differently before they can used in linear regression model. There are different techniques to treat them, here I have used one hot encoding(convert each class of a categorical variable as a feature). Other than that I have also imputed the missing values for outlet size.

Data pre-processing steps for regression model Building the model

Clearly, we can see that there is a great improvement in both mse and R-square, which means that our model now is able to predict much closer values to the actual values.

Selecting the right features for your model

When we have a high dimensional data set, it would be highly inefficient to use all the variables since some of them might be imparting redundant information. We would need to select the right set of variables which give us an accurate model as well as are able to explain the dependent variable well. There are multiple ways to select the right set of variables for the model. First among them would be the business understanding and domain knowledge. For instance while predicting sales we know that marketing efforts should impact positively towards sales and is an important feature in your model. We should also take care that the variables we’re selecting should not be correlated among themselves.

Instead of manually selecting the variables, we can automate this process by using forward or backward selection. Forward selection starts with most significant predictor in the model and adds variable for each step. Backward elimination starts with all predictors in the model and removes the least significant variable for each step. Selecting criteria can be set to any statistical measure like R-square, t-stat etc.

Interpretation of Regression Plots

Take a look at the residual vs fitted values plot.

We can see a funnel like shape in the plot. This shape indicates Heteroskedasticity. The presence of non-constant variance in the error terms results in heteroskedasticity. We can clearly see that the variance of error terms(residuals) is not constant. Generally, non-constant variance arises in presence of outliers or extreme leverage values. These values get too much weight, thereby disproportionately influencing the model’s performance. When this phenomenon occurs, the confidence interval for out of sample prediction tends to be unrealistically wide or narrow.

We can easily check this by looking at residual vs fitted values plot. If heteroskedasticity exists, the plot would exhibit a funnel shape pattern as shown above. This indicates signs of non linearity in the data which has not been captured by the model. I would highly recommend going through this article for a detailed understanding of assumptions and interpretation of regression plots.

In order to capture this non-linear effects, we have another type of regression known as polynomial regression. So let us now understand it.

What Is Polynomial Regression?

Polynomial regression is another form of regression in which the maximum power of the independent variable is more than 1. In this regression technique, the best fit line is not a straight line instead it is in the form of a curve.

Quadratic regression, or regression with second order polynomial, is given by the following equation:

Y =Θ1 +Θ2*x +Θ3*x2

Now take a look at the plot given below.

Clearly the quadratic equation fits the data better than simple linear equation. In this case, what do you think will the R-square value of quadratic regression greater than simple linear regression? Definitely yes, because quadratic regression fits the data better than linear regression. While quadratic and cubic polynomials are common, but you can also add higher degree polynomials.

Below figure shows the behavior of a polynomial equation of degree 6.

So do you think it’s always better to use higher order polynomials to fit the data set. Sadly, no. Basically, we have created a model that fits our training data well but fails to estimate the real relationship among variables beyond the training set. Therefore our model performs poorly on the test data. This problem is called as over-fitting. We also say that the model has high variance and low bias.

Similarly, we have another problem called underfitting, it occurs when our model neither fits the training data nor generalizes on the new data.

Our model is underfit when we have high bias and low variance.

Bias and Variance in Regression Models

What does that bias and variance actually mean? Let us understand this by an example of archery targets.

Let’s say we have model which is very accurate, therefore the error of our model will be low, meaning a low bias and low variance as shown in first figure. All the data points fit within the bulls-eye. Similarly we can say that if the variance increases, the spread of our data point increases which results in less accurate prediction. And as the bias increases the error between our predicted value and the observed values increases.

Now how this bias and variance is balanced to have a perfect model? Take a look at the image below and try to understand.

As we add more and more parameters to our model, its complexity increases, which results in increasing variance and decreasing bias, i.e., overfitting. So we need to find out one optimum point in our model where the decrease in bias is equal to increase in variance. In practice, there is no analytical way to find this point. So how to deal with high variance or high bias?

To overcome underfitting or high bias, we can basically add new parameters to our model so that the model complexity increases, and thus reducing high bias.

Now, how can we overcome Overfitting for a regression model?

Basically there are two methods to overcome overfitting,

Reduce the model complexity

Regularization

Here we would be discussing about Regularization in detail and how to use it to make your model more generalized.

Regularization of Models

You have your model ready, you have predicted your output. So why do you need to study regularization? Is it necessary?

Suppose you have taken part in a competition, and in that problem you need to predict a continuous variable. So you applied linear regression and predicted your output. Voila! You are on the leaderboard. But wait what you see is still there are many people above you on the leaderboard. But you did everything right then how is it possible?

“Everything should be made simple as possible, but not simpler – Albert Einstein”

What we did was simpler, everybody else did that, now let us look at making it simple. That is why, we will try to optimize our code with the help of regularization.

In regularization, what we do is normally we keep the same number of features, but reduce the magnitude of the coefficients j. How does reducing the coefficients will help us?

Let us take a look at the coefficients of feature in our above regression model.

We can see that coefficients of Outlet_Identifier_OUT027 and Outlet_Type_Supermarket_Type3(last 2) is much higher as compared to rest of the coefficients. Therefore the total sales of an item would be more driven by these two features.

How can we reduce the magnitude of coefficients in our model? For this purpose, we have different types of regression techniques which uses regularization to overcome this problem. So let us discuss them.

What Is Ridge Regression?

Let us first implement it on our above problem and check our results that whether it performs better than our linear regression model.

So, we can see that there is a slight improvement in our model because the value of the R-Square has been increased. Note that value of alpha, which is hyperparameter of Ridge, which means that they are not automatically learned by the model instead they have to be set manually.

Here we have consider alpha = 0.05. But let us consider different values of alpha and plot the coefficients for each case.

You can see that, as we increase the value of alpha, the magnitude of the coefficients decreases, where the values reaches to zero but not absolute zero.

But if you calculate R-square for each alpha, we will see that the value of R-square will be maximum at alpha=0.05. So we have to choose it wisely by iterating it through a range of values and using the one which gives us lowest error.

So, now you have an idea how to implement it but let us take a look at the mathematics side also. Till now our idea was to basically minimize the cost function, such that values predicted are much closer to the desired result.

Now take a look back again at the cost function for ridge regression.

Here if you notice, we come across an extra term, which is known as the penalty term. λ given here, is actually denoted by alpha parameter in the ridge function. So by changing the values of alpha, we are basically controlling the penalty term. Higher the values of alpha, bigger is the penalty and therefore the magnitude of coefficients are reduced.

Important Points:

It shrinks the parameters, therefore it is mostly used to prevent multicollinearity.

It reduces the model complexity by coefficient shrinkage.

It uses L2 regularization technique. (which I will discussed later in this article)

Now let us consider another type of regression technique which also makes use of regularization.

What Is Lasso Regression?

LASSO (Least Absolute Shrinkage Selector Operator), is quite similar to ridge, but lets understand the difference them by implementing it in our big mart problem.

As we can see that, both the mse and the value of R-square for our model has been increased. Therefore, lasso model is predicting better than both linear and ridge.

Again lets change the value of alpha and see how does it affect the coefficients.

So, we can see that even at small values of alpha, the magnitude of coefficients have reduced a lot. By looking at the plots, can you figure a difference between ridge and lasso?

We can see that as we increased the value of alpha, coefficients were approaching towards zero, but if you see in case of lasso, even at smaller alpha’s, our coefficients are reducing to absolute zeroes. Therefore, lasso selects the only some feature while reduces the coefficients of others to zero. This property is known as feature selection and which is absent in case of ridge.

Mathematics behind lasso regression is quiet similar to that of ridge only difference being instead of adding squares of theta, we will add absolute value of Θ.

Here too, λ is the hypermeter, whose value is equal to the alpha in the Lasso function.

Important Points:

It uses L1 regularization technique (will be discussed later in this article)

It is generally used when we have more number of features, because it automatically does feature selection.

Now that you have a basic understanding of ridge and lasso regression, let’s think of an example where we have a large dataset, lets say it has 10,000 features. And we know that some of the independent features are correlated with other independent features. Then think, which regression would you use, Rigde or Lasso?

Let’s discuss it one by one. If we apply ridge regression to it, it will retain all of the features but will shrink the coefficients. But the problem is that model will still remain complex as there are 10,000 features, thus may lead to poor model performance.

Instead of ridge what if we apply lasso regression to this problem. The main problem with lasso regression is when we have correlated variables, it retains only one variable and sets other correlated variables to zero. That will possibly lead to some loss of information resulting in lower accuracy in our model.

Then what is the solution for this problem? Actually we have another type of regression, known as elastic net regression, which is basically a hybrid of ridge and lasso regression. So let’s try to understand it.



What Is Elastic Net Regression?

Before going into the theory part, let us implement this too in big mart sales problem. Will it perform better than ridge and lasso? Let’s check!

So we get the value of R-Square, which is very less than both ridge and lasso. Can you think why? The reason behind this downfall is basically we didn’t have a large set of features. Elastic regression generally works well when we have a big dataset.

Note, here we had two parameters alpha and l1_ratio. First let’s discuss, what happens in elastic net, and how it is different from ridge and lasso.

Elastic net is basically a combination of both L1 and L2 regularization. So if you know elastic net, you can implement both Ridge and Lasso by tuning the parameters. So it uses both L1 and L2 penality term, therefore its equation look like as follows:

So how do we adjust the lambdas in order to control the L1 and L2 penalty term? Let us understand by an example. You are trying to catch a fish from a pond. And you only have a net, then what would you do? Will you randomly throw your net? No, you will actually wait until you see one fish swimming around, then you would throw the net in that direction to basically collect the entire group of fishes. Therefore even if they are correlated, we still want to look at their entire group.

Elastic regression works in a similar way. Let’ say, we have a bunch of correlated independent variables in a dataset, then elastic net will simply form a group consisting of these correlated variables. Now if any one of the variable of this group is a strong predictor (meaning having a strong relationship with dependent variable), then we will include the entire group in the model building, because omitting other variables (like what we did in lasso) might result in losing some information in terms of interpretation ability, leading to a poor model performance.

So, if you look at the code above, we need to define alpha and l1_ratio while defining the model. Alpha and l1_ratio are the parameters which you can set accordingly if you wish to control the L1 and L2 penalty separately. Actually, we have

Alpha = a + b           and     l1_ratio =  a / (a+b)

where, a and b weights assigned to L1 and L2 term respectively. So when we change the values of alpha and l1_ratio, a and b are set aaccordingly such that they control trade off between L1 and L2 as:

a * (L1 term) + b* (L2 term)

Let alpha (or a+b) = 1, and now consider the following cases:

If l1_ratio =1, therefore if we look at the formula of l1_ratio, we can see that l1_ratio can only be equal to 1 if a=1, which implies b=0. Therefore, it will be a lasso penalty.

Similarly if l1_ratio = 0, implies a=0. Then the penalty will be a ridge penalty.

For l1_ratio between 0 and 1, the penalty is the combination of ridge and lasso.

So let us adjust alpha and l1_ratio, and try to understand from the plots of coefficient given below.

Now, you have basic understanding about ridge, lasso and elasticnet regression. But during this, we came across two terms L1 and L2, which are basically two types of regularization. To sum up basically lasso and ridge are the direct application of L1 and L2 regularization respectively.

But if you still want to know, below I have explained the concept behind them, which is OPTIONAL but before that let us see the same implementation of above codes in R.

Implementation in R

Step 1: Linear regression with two variables “Item MRP” and “Item Establishment Year”.

View the code on Gist.

Output

Call: lm(formula = Y_train ~ Item_MRP + Outlet_Establishment_Year, data = train_2) Residuals: Min 1Q Median 3Q Max -4000.1 -769.4 -32.7 679.4 9286.7 Coefficients: (Intercept) 17491.6441 4328.9747 4.041 5.40e-05 *** Item_MRP 15.9085 0.2909 54.680 < 2e-16 *** Outlet_Establishment_Year -8.7808 2.1667 -4.053 5.13e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1393 on 5953 degrees of freedom Multiple R-squared: 0.3354, Adjusted R-squared: 0.3352 F-statistic: 1502 on 2 and 5953 DF, p-value: < 2.2e-16

Also, the value of r square is 0.3354391 and the MSE is 20,28,538.

Step 2: Linear regression with three variables “Item MRP”, “Item Establishment Year”, “Item Weight”.

View the code on Gist.

Output

Call: lm(formula = Y_train ~ Item_Weight + Item_MRP + Outlet_Establishment_Year, data = train_2) Residuals: Min 1Q Median 3Q Max -4000.7 -767.1 -33.2 680.8 9286.3 Coefficients: (Intercept) 17530.3653 4329.9774 4.049 5.22e-05 *** Item_Weight -2.0914 4.2819 -0.488 0.625 Item_MRP 15.9128 0.2911 54.666 < 2e-16 *** Outlet_Establishment_Year -8.7870 2.1669 -4.055 5.08e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1393 on 5952 degrees of freedom Multiple R-squared: 0.3355, Adjusted R-squared: 0.3351 F-statistic: 1002 on 3 and 5952 DF, p-value: < 2.2e-16

Also, the value of r square is 0.3354657 and the MSE is 20,28,692.

Step 3: Linear regression with all variables.

View the code on Gist.

Output

Also, the value of r square is 0.3354657 and the MSE is 14,38,692.

Step 4: Implementation of Ridge regression

View the code on Gist.

Output

(Intercept) (Intercept) Item_Weight -220.666749 0.000000 4.223814 Item_Fat_Contentlow fat Item_Fat_ContentLow Fat Item_Fat_Contentreg 450.322572 170.154291 -760.541684 -150.724872 589.452742 -80.478887 Item_TypeBreakfast Item_TypeCanned Item_TypeDairy 62.144579 638.515758 85.600397 Item_TypeFrozen Foods Item_TypeFruits and Vegetables Item_TypeHard Drinks 359.471616 -259.261220 -724.253049 Item_TypeHealth and Hygiene Item_TypeHousehold Item_TypeMeat -127.436543 -197.964693 -62.876064 Item_TypeOthers Item_TypeSeafood Item_TypeSnack Foods 120.296577 -114.541586 140.058051 Item_TypeSoft Drinks Item_TypeStarchy Foods Item_MRP -77.997959 1294.760824 9.841181 Outlet_IdentifierOUT013 Outlet_IdentifierOUT017 Outlet_IdentifierOUT018 20.653040 442.754542 252.958840 Outlet_IdentifierOUT019 Outlet_IdentifierOUT027 Outlet_IdentifierOUT035 -1044.171225 1031.745209 -213.353983 Outlet_IdentifierOUT045 Outlet_IdentifierOUT046 Outlet_IdentifierOUT049 -232.709629 249.947674 154.372830 Outlet_Establishment_Year Outlet_SizeHigh Outlet_SizeMedium 1.718906 18.560755 356.251406 Outlet_SizeSmall Outlet_Location_TypeTier 2 Outlet_Location_TypeTier 3 54.009414 50.276025 -369.417420 Outlet_TypeSupermarket Type1 649.021251

Step 5: Implementation of lasso regression

View the code on Gist.

Output

(Intercept) (Intercept) Item_Weight 550.39251 0.00000 0.00000 Item_Fat_Contentlow fat Item_Fat_ContentLow Fat Item_Fat_Contentreg 0.00000 22.67186 0.00000 0.00000 0.00000 0.00000 Item_TypeBreakfast Item_TypeCanned Item_TypeDairy 0.00000 0.00000 0.00000 Item_TypeFrozen Foods Item_TypeFruits and Vegetables Item_TypeHard Drinks 0.00000 -83.94379 0.00000 Item_TypeHealth and Hygiene Item_TypeHousehold Item_TypeMeat 0.00000 0.00000 0.00000 Item_TypeOthers Item_TypeSeafood Item_TypeSnack Foods 0.00000 0.00000 0.00000 Item_TypeSoft Drinks Item_TypeStarchy Foods Item_MRP 0.00000 0.00000 11.18735 Outlet_IdentifierOUT013 Outlet_IdentifierOUT017 Outlet_IdentifierOUT018 0.00000 0.00000 0.00000 Outlet_IdentifierOUT019 Outlet_IdentifierOUT027 Outlet_IdentifierOUT035 -580.02106 645.76539 0.00000 Outlet_IdentifierOUT045 Outlet_IdentifierOUT046 Outlet_IdentifierOUT049 0.00000 0.00000 0.00000 Outlet_Establishment_Year Outlet_SizeHigh Outlet_SizeMedium 0.00000 0.00000 260.63703 Outlet_SizeSmall Outlet_Location_TypeTier 2 Outlet_Location_TypeTier 3 0.00000 0.00000 -313.21402 Outlet_TypeSupermarket Type1 48.77124

For better understanding and more clarity on all the three types of regression, you can refer to this Free Course: Big Mart Sales In R.

Types of Regularization Techniques

Let’s recall, both in ridge and lasso we added a penalty term, but the term was different in both cases. In ridge, we used the squares of theta while in lasso we used absolute value of theta. So why these two only, can’t there be other possibilities?

Actually, there are different possible choices of regularization with different choices of order of the parameter in the regularization term, which is denoted by . This is more generally known as Lp regularizer.

Let us try to visualize some by plotting them. For making visualization easy, let us plot them in 2D space. For that we suppose that we just have two parameters. Now, let’s say if p=1, we have term as  . Can’t we plot this equation of line? Similarly plot for different values of p are given below.

In the above plots, axis denote the parameters(Θ1 and Θ2). Let us examine them one by one.

For p=0.5, we can only get large values of one parameter only if other parameter is too small. For p=1, we get sum of absolute values where the increase in one parameter Θ is exactly offset by the decrease in other. For p =2, we get a circle and for larger p values, it approaches a round square shape.

The two most commonly used regularization are in which we have p=1 and p=2, more commonly known as L1 and L2 regularization.

Look at the figure given below carefully. The blue shape refers the regularization term and other shape present refers to our least square error (or data term).

The first figure is for L1 and the second one is for L2 regularization. The black point denotes that the least square error is minimized at that point and as we can see that it increases quadratically as we move from it and the regularization term is minimized at the origin where all the parameters are zero .

Now the question is that at what point will our cost function be minimum? The answer will be, since they are quadratically increasing, the sum of both the terms will be minimized at the point where they first intersect.

Take a look at the L2 regularization curve. Since the shape formed by L2 regularizer is a circle, it increases quadratically as we move away from it. The L2 optimum(which is basically the intersection point) can fall on the axis lines only when the minimum MSE (mean square error or the black point in the figure) is also exactly on the axis. But in case of L1, the L1 optimum can be on the axis line because its contour is sharp and therefore there are high chances of interaction point to fall on axis. Therefore it is possible to intersect on the axis line, even when minimum MSE is not on the axis. If the intersection point falls on the axes it is known as sparse.

Therefore L1 offers some level of sparsity which makes our model more efficient to store and compute and it can also help in checking importance of feature, since the features that are not important can be exactly set to zero.

Conclusion

I hope now you understand the science behind the linear regression and how to implement it and optimize it further to improve your model.

“Knowledge is the treasure and practice is the key to it”

Therefore, get your hands dirty by solving some problems. You can also start with the Big mart sales problem and try to improve your model with some feature engineering.  If you face any difficulties while implementing it, feel free to write on our discussion portal.

Key Takeaways

We now understand how to evaluate a linear regression model using R-squared and Adjusted R-squared values.

We looked into the difference between Bias and Variance in regression models.

We also learned to implement various regression models in R.

Frequently Asked Questions

Q1. Where are ridge and lasso regression used?

A. Ridge regression is used in cases where there are many parameters or predictors that affect the outcome. Whereas lasso regression works better when there are fewer significant parameters or predictors involved.

Q2. What is the full form of lasso?

A. The LASSO in lasso regression stands for Least Absolute Shrinkage and Selection Operator.

Q3. What is the difference between lasso and ridge regression in R?

A. The main difference between the two is that lasso regression can lower the coefficients to zero resulting in feature selection, while ridge regression cannot result in feature selection, as it only gets the coefficients close to zero.

Related

Se Quality Q & A #6

SE Quality Q & A #6

Question:Define the meaning of quality assurance. Explain the role of testing in Quality assurance.

Answer:

Quality Assurance

With the help of proper planning and systematic performance and both control may be the surety of better quality. The main objective of quality assurance is that to check the actions which are used in development process so that the margin of the error becomes zero and if in case error occurred during the process then solves the problem. To get the better output many actions are taken by the developer. In the process of analysis and design both the planes compared with each other. In this process Acceptance plan and Verification plan both checkout some points and compared which are:

Sr.No.Verification PlanAcceptance plan 1It ensures that needs of the client are fulfilled/satisfied by chúng tôi ensures that outcome of the product is as per the need or not. 2Sources used in the process should meet specified quality chúng tôi test can check the product performance.

A functional audit and physical audit are completed before the delivery of product to our customer. With the performance of function we check that it is fulfill the need of the customer. While physical audit performed to check that all the information are mentioned in document and documentation are done in systematic way and we can deliver the software at the next level.

Goal of quality assurance of software

To get the proper detail about the software and proper parameters are used in software development process.

To be helpful in quality maintenance.

Use of new technology in software technology.

To get the surety about the software development process to be of proper standard.

List of actions which used in quality assurance process

Application of technical method – To get the high level of performance from a software it is necessary that developer use various type of techniques and methods.

Conduction of formal technical reviews – After the process completed, a general meeting should be held for discussing the every point of the software development process. With the help of this discussion we can find the faults or errors if we miss any kind of errors in the process.

Software testing process – For the testing of software many kind of planning and techniques should be used. The department of Quality audits the software process for deciding that the software is according to expectations or not.

Enforcement of standard – We have a large choice of standard parameters and we find out the best one and apply this on software. ISO 9000, SEI and CMM are the best examples of standard of parameters.

Assessment – Software matrix can be used to get the quality and process changes.

Record keeping – A record keeping is must require at every level of a software life cycle. With the help of this we can get the proper information about the audit, thoughts and test report of a software at every level.

Importance of testing in Quality Assurance

We can easily get the errors without taking any time and efforts.

With the help of this we can get the information about that this software have the ability of trust and fulfill the client’s needs.

We can get the software of a high level performer.

We can get the detail about the design of a software.

Relationship of testing and Quality surety

Every project needs the capacity of well performance and correctness and fulfillment of clients’ needs for the success of projects. Testing of software provide the information about the requirement fulfilled on the opposite side quality of surety gives the information that testing method of software is used on a standard level.

Advertisements

How To Cast To Tv On Windows 11

Your Windows 11 display isn’t limited to a single screen. The operating system includes a feature that allows you to cast your screen on multiple monitors and televisions.

While in this article, we are focusing more on windows 11, you can apply this method to Windows 10 or any of its predecessors.

How to Cast to TV on Windows 11

You can cast media to multiple displays via both wired or wireless connections.

For a wired connection, the user will need an HDMI cable. As for a wireless connection, you will require a Smart TV that supports casting. 

Download Wireless Display Feature

To cast your media wirelessly, you must first download the wireless display feature to your PC.

Enable Network Discovery

When you enable Network Discovery on your Windows, your computer can view other computer networks and can be visible to other computer networks. Here are instructions to turn on your Network Discovery:

Once you have completed the download and enabling process, you can start the casting.

Cast Using an HDMI Cable

Plug in your HDMI cable to your PC and TV. On your TV, open the display connected via HDMI cable. Use the shortcut, Windows Key + P, to select the type of display you prefer Duplicate or Expand. This option casts your entire screen to your TV.

Wirelessly Cast to TV Using Miracast

Windows 11 has the option to cast to your Smart TV wirelessly. Follow these instructions to cast to your TV:

Under the Available Devices list, select your TV to cast your PC‘s screen. 

You can also use the shortcut Windows key + K to open the list of available devices for casting. This option casts your entire screen to your TV.

Add a Wireless Device for Casting

You can add a device to mirror or expand your screen wirelessly to your TV using bluetooth. To configure your devices using Bluetooth, follow these instructions:

Cast a File to Your TV

You can cast a particular media or a file to your screen. To cast a file to your connected device, follow these instructions: 

Cast Media from Your Browser

You can also share the media contents from your browser to your connected device. However, only a limited number of browsers, such as Google Chrome and Microsoft Edge Browser support casting. Here is how you can cast media from these browsers to your TV: 

Google Chrome

Choose your TV from the list to cast the media content.

Microsoft Edge Frequently Asked Questions (FAQs) Does Windows 11 support Miracast?

Windows 11 supports Miracast and if the device you are trying to connect supports too, you can duplicate or expand your screen using the miracast technology. Miracast is a wireless technology that lets a user copy or expand the entirety of their screen. 

Why is my HDMI not working on Windows 11?

If your HDMI cable isn’t working properly, there is probably physical damage to your cable. Inspect the cable thoroughly and look for debris on the HDMI and the port.

How do I project my Screen on Windows 11?

You can project your screen on Windows 11 to your connected display devices. To use this feature, press the shortcut Windows key + P.

Elden Ring: How To Get And Cast Incantations

While Elden Ring introduced many new things, it also re-introduced and improved past Soulslike features such as Incantations. Acquired throughout various NPCs in the Lands Between, these magic-based skills open up the gameplay to fun options. However, getting one and using them requires additional steps. This article covers everything you should know about how to get and use Incantations in Elden Ring.

What are Incantations in Elden Ring

In Elden Ring, players can perform magic in two ways – using the sorceries obtained and sorcery items like a staff. The latter is through the Incantations, which you can gather throughout your journey and using sacred seals. Like Dark Souls, Incantations acts like supplementary magic, which players can use besides the best weapons in Elden Ring to assist them. Some help in healing the player and the allies in their vicinity, while others deal damage to the enemies.

Unlike magic-based builds, which require intelligence points, incantations exclusively require points in faith, eliminating the necessity of spending points in other stats.

How to Get Incantation in Elden Ring NPC Vendors

The first method of acquiring these magical wonders is through NPC vendors in the game. When players visit the Roundtable Hold for the first time, they meet Brother Corhyn at the roundtable hold room. He sells numerous Incantations, which players can buy and use as they please.

During progression, players will come across other vendors, such as the wise and lovable turtle Miriel at the Church of Vows on Liurnia of the Lakes, the mysterious D, Hunter of the Dead, who players meet on the Stormhill at Limgrave, and later at Roundtable Hold and Gowry, who sits on his chair at Gowry’s Shack, located just outside Sellia, the town of sorcery at Caelid.

Each of these NPCs gives various kinds of Incantation of different categories and status effects:

Brother Corhyn gives magic-based assist Incantations which help during boss encounters, such as healing and shields. Players can find prayerbooks as item pickups and give them to him, increasing the purchase options.

Miriel hands over Raya Lucaria-based magic incantations, usable to fight with enemies and bosses. Furthermore, Miriel also hands over assist-based incantations, healing players and their nearby allies. Just like Brother Corhyn, Miriel also accepts prayerbooks found throughout the game.

Miriel

D, Hunter of the Dead sells only two offensive-based incantations – the Litany of Proper Death and Order’s Blade. Both of these inflict holy damage on the opponents.

Quest Completion Rewards

Players can also acquire Incantations in Elden Ring by completing various questlines and side-quests in-game. For example — players can get the “Dragon Communion Incantation,” which is fire-based and inspired by the power of dragons, only after defeating the various dragons scattered throughout the map. Killing the dragons gives Dragonheart, which players exchange at a specific altar for an incantation reward.

Prerequisites to Cast Incantations in Elden Ring

Much like Sorcery, Incantations also require players to meet established criteria and acquire items to cast them. Naturally, the two most important things players need are the following:

Procuring a Sacred Seal

Sacred Seals

In Elden Ring, players perform Incantations through a sacred seal. Like the magic staff required to conduct Sorcery, the seals allow users to perform an equipped Incantation. Players who select the Confessor or Prophet class during character creation will immediately receive the Finger Seal, allowing them to perform Incantation from the start of the game since both are faith-based.

Other players can receive the Finger Seal by purchasing it from the Twin Maiden Husk at the Roundtable hold for 800 runes. Later, Sacred Seals are found either from NPC questline completion or at specific places on the map. Once acquired, players need to equip it in one of the two hands and use it just like they would use a weapon.

Ensuring Enough Points in the Faith Stat

Unlike Sorcery, which uses intelligence to scale and improve, Incantations use faith skill points for players to perform them. They still share the FP bar for players to cast them. Each acquired incantation skill requires players to put a certain amount of points in faith to equip and perform them.

How to Cast Incantations in Elden Ring

Casting an incantation requires the players to follow a few simple steps, which are as under:

First, decide on the Incantation you want to use and check its equipment requirements. To do that, open up the inventory screen and go to the Incantation tab.

Once we decide on the Incantation, we want to perform, spawn at one of the sites of graces on the map, and rest on it.

Once resting, select the “Memorize Spell” option from the list, and equip the desired one in the slot.

After that, equip a sacred seal in your inventory. To do that, head on to the inventory and select the “Sacred seal” on the hand as a weapon.

Once all these steps are completed and ensured that the Incantation meets the faith requirements, players will be able to cast them at any point.

Is Using Incantation in Elden Ring Beneficial?

The usage of Incantations depends on the player’s needs and how they want to build their character. However, putting some points in faith and using incantations alongside a strength or dexterity-focused build is always beneficial. Some Incantations focus on amplifying players’ defense and even put resistance to status effects. Furthermore, using them also increases options in the game, opening them to unique gameplay experiences.

Frequently Asked Questions

‘Ted Lasso’ Cast Members Attend Q&A At The Grove Apple Store, Opening Today

Jason Sudeikis and other Ted Lasso cast members have attended a Q&A event at The Grove, the LA Apple Store opening today.

Apple says that the store, which originally opened in 2002, is now twice the size and has been “entirely reimagined” …

CEO Tim Cook said that the evening was “unforgettable,” but the Q&A itself hasn’t yet been shared.

Apple’s announcement mostly reiterated the awards won by the show.

Cast members of Apple’s multi-winning comedy series “Ted Lasso” attended a special Q&A event today at Apple’s newest retail location at The Grove in Los Angeles, CA ahead of its opening to the public tomorrow. The event takes place on the heels of “Ted Lasso” making history as the most Emmy Award-nominated freshman comedy series and landing seven Emmy Awards, including Outstanding Comedy Series, Outstanding Actor in a Comedy Series, Outstanding Supporting Actor in a Comedy Series, and Outstanding Supporting Actress in a Comedy Series […]

In addition to the Emmy Award honors, the first season of “Ted Lasso” has also been recognized with an esteemed Peabody Award; a SAG Award for Outstanding Performance by a Male Actor in a Comedy Series Award for Sudeikis; three Critics Choice Awards for Best Comedy Series, Best Actor in a Comedy Series for Sudeikis, and Best Supporting Actress in a Comedy Series for Hannah Waddingham, sweeping all categories in which the series was nominated; a Best Actor in a Comedy Series at the Golden Globe Awards for Sudeikis; and the Writers Guild of America crowned “Ted Lasso” with wins for both Best Comedy and Best New Series. “Ted Lasso” is also the only comedy series honored as an AFI Program of the Year and has picked up nominations from the Producers Guild of America for Comedy Series, as well as honors from many other guilds and critics groups […]

Star, creator and executive producer Jason Sudeikis (Ted Lasso), executive producer Brendan Hunt (Coach Beard), Juno Temple (Keeley), Brett Goldstein (Roy Kent, writer) and Cristo Fernandez (Dani Rojas) sat down at Apple The Grove for a conversation moderated by Yvette Nicole Brown.

Cook tweeted a couple of photos from the event.

An unforgettable evening with @JasonSudeikis and the cast of @TedLasso! Thank you for spending time with us in our beautiful new store, Apple The Grove, ahead of our grand opening tomorrow! chúng tôi Tim Cook (@tim_cook) November 19, 2023

The company also threw in a plug for the photographic capabilities of the iPhone 13, though the photo walk is predictably already fully booked.

The brand-new store […] will open its doors to the public on Friday, November 19, serving as an entirely reimagined destination for the LA community to discover Apple’s products and services, shop, get support and participate in free Today at Apple sessions, including Photo Walks.

In time for the holiday season, participants at The Grove can register to take a festive walk familiarizing themselves with iPhone 13 Pro features, including how to take stunning macro photos using the Ultra Wide camera, record video with Cinematic mode, and shoot with all-new Photographic Styles.

You may find the walk available at other stores.

FTC: We use income earning auto affiliate links. More.

Update the detailed information about ‘Ted Lasso’ Cast Members Attend Q&A At The Grove Apple Store, Opening Today on the Katfastfood.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!