নিম্নলিখিত বিভাগগুলি এই দুটি বিবেচনাকে আরও গভীরভাবে আলোচনা করে।
লগ ক্ষতি
লিনিয়ার রিগ্রেশন মডিউলে , আপনি ক্ষতি ফাংশন হিসাবে বর্গক্ষেত্র ক্ষতি (যাকে L 2 ক্ষতিও বলা হয়) ব্যবহার করেছেন। বর্গক্ষেত্র ক্ষতি একটি রৈখিক মডেলের জন্য ভাল কাজ করে যেখানে আউটপুট মান পরিবর্তনের হার স্থির থাকে। উদাহরণস্বরূপ, লিনিয়ার মডেল $y' = b + 3x_1$ দেওয়া হয়েছে, প্রতিবার যখন আপনি ইনপুট মান $x_1$ 1 দ্বারা বৃদ্ধি করবেন, আউটপুট মান $y'$ 3 দ্বারা বৃদ্ধি পাবে।
যাইহোক, লজিস্টিক রিগ্রেশন মডেলের পরিবর্তনের হার ধ্রুবক নয় । আপনি একটি সম্ভাব্যতা গণনা করতে দেখেছেন, সিগময়েড বক্ররেখাটি রৈখিক না হয়ে s-আকৃতির। যখন লগ-অডস ($z$) মান 0-এর কাছাকাছি হয়, তখন $z$-এ ছোট বৃদ্ধির ফলে $z$ একটি বড় ধনাত্মক বা ঋণাত্মক সংখ্যার তুলনায় $y$-এ অনেক বড় পরিবর্তন হয়। নিম্নলিখিত সারণীটি 5 থেকে 10 পর্যন্ত ইনপুট মানের জন্য সিগমায়েড ফাংশনের আউটপুট দেখায়, সেইসাথে ফলাফলের পার্থক্যগুলি ক্যাপচার করার জন্য প্রয়োজনীয় সংশ্লিষ্ট নির্ভুলতা দেখায়।
ইনপুট
লজিস্টিক আউটপুট
নির্ভুলতার প্রয়োজনীয় সংখ্যা
5
0.993
3
6
0.997
3
7
0.999
3
8
0.9997
4
9
0.9999
4
10
0.99998
5
আপনি যদি সিগমায়েড ফাংশনের ত্রুটিগুলি গণনা করতে বর্গক্ষেত্র ক্ষতি ব্যবহার করেন, যেহেতু আউটপুট 0 এবং 1 এর কাছাকাছি এবং কাছাকাছি এসেছে, তাহলে এই মানগুলি ট্র্যাক করার জন্য প্রয়োজনীয় নির্ভুলতা সংরক্ষণ করতে আপনার আরও মেমরির প্রয়োজন হবে।
পরিবর্তে, লজিস্টিক রিগ্রেশনের লস ফাংশন হল লগ লস । লগ লস সমীকরণ শুধুমাত্র ডেটা থেকে ভবিষ্যদ্বাণী পর্যন্ত দূরত্বের পরিবর্তে পরিবর্তনের মাত্রার লগারিদম প্রদান করে। লগ ক্ষতি নিম্নরূপ গণনা করা হয়:
\((x,y)\in D\) অনেকগুলি লেবেলযুক্ত উদাহরণ ধারণকারী ডেটাসেট, যা \((x,y)\) জোড়া
\(y\) একটি লেবেলযুক্ত উদাহরণের লেবেল। যেহেতু এই লজিস্টিক রিগ্রেশন, প্রতিটি মান \(y\) হয় 0 বা 1 হতে হবে।
\(y'\) আপনার মডেলের ভবিষ্যদ্বাণী (কোনও জায়গায় 0 এবং 1 এর মধ্যে), বৈশিষ্ট্যগুলির সেট দেওয়া হয়েছে৷ \(x\).
লজিস্টিক রিগ্রেশনে নিয়মিতকরণ
নিয়মিতকরণ , প্রশিক্ষণের সময় মডেল জটিলতাকে শাস্তি দেওয়ার একটি প্রক্রিয়া, লজিস্টিক রিগ্রেশন মডেলিংয়ের ক্ষেত্রে অত্যন্ত গুরুত্বপূর্ণ। নিয়মিতকরণ ব্যতীত, লজিস্টিক রিগ্রেশনের অ্যাসিম্পোটিক প্রকৃতি 0 এর দিকে ড্রাইভিং ক্ষতি চালিয়ে যাবে যেখানে মডেলটিতে প্রচুর সংখ্যক বৈশিষ্ট্য রয়েছে। ফলস্বরূপ, বেশিরভাগ লজিস্টিক রিগ্রেশন মডেলগুলি মডেল জটিলতা কমাতে নিম্নলিখিত দুটি কৌশলগুলির মধ্যে একটি ব্যবহার করে:
[[["সহজে বোঝা যায়","easyToUnderstand","thumb-up"],["আমার সমস্যার সমাধান হয়েছে","solvedMyProblem","thumb-up"],["অন্যান্য","otherUp","thumb-up"]],[["এতে আমার প্রয়োজনীয় তথ্য নেই","missingTheInformationINeed","thumb-down"],["খুব জটিল / অনেক ধাপ","tooComplicatedTooManySteps","thumb-down"],["পুরনো","outOfDate","thumb-down"],["অনুবাদ সংক্রান্ত সমস্যা","translationIssue","thumb-down"],["নমুনা / কোড সংক্রান্ত সমস্যা","samplesCodeIssue","thumb-down"],["অন্যান্য","otherDown","thumb-down"]],["2024-10-31 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eLogistic regression models are trained similarly to linear regression models but use Log Loss instead of squared loss and require regularization.\u003c/p\u003e\n"],["\u003cp\u003eLog Loss is used in logistic regression because the rate of change isn't constant, requiring varying precision levels unlike squared loss used in linear regression.\u003c/p\u003e\n"],["\u003cp\u003eRegularization, such as L2 regularization or early stopping, is crucial in logistic regression to prevent overfitting due to the model's asymptotic nature.\u003c/p\u003e\n"]]],[],null,["[**Logistic regression**](/machine-learning/glossary#logistic_regression)\nmodels are trained using the same process as\n[**linear regression**](/machine-learning/crash-course/linear-regression)\nmodels, with two key distinctions:\n\n- Logistic regression models use [**Log Loss**](/machine-learning/glossary#Log_Loss) as the loss function instead of [**squared loss**](/machine-learning/glossary#l2-loss).\n- Applying [regularization](/machine-learning/crash-course/overfitting/regularization) is critical to prevent [**overfitting**](/machine-learning/glossary#overfitting).\n\nThe following sections discuss these two considerations in more depth.\n\nLog Loss\n\nIn the [Linear regression module](/machine-learning/crash-course/linear-regression),\nyou used [**squared loss**](/machine-learning/glossary#l2-loss) (also called\nL~2~ loss) as the\n[**loss function**](/machine-learning/glossary#loss-function).\nSquared loss works well for a linear\nmodel where the rate of change of the output values is constant. For example,\ngiven the linear model $y' = b + 3x_1$, each time you increment the input\nvalue $x_1$ by 1, the output value $y'$ increases by 3.\n\nHowever, the rate of change of a logistic regression model is *not* constant.\nAs you saw in [Calculating a probability](/machine-learning/crash-course/logistic-regression/sigmoid-function), the\n[**sigmoid**](/machine-learning/glossary#sigmoid-function) curve is s-shaped\nrather than linear. When the log-odds ($z$) value is closer to 0, small\nincreases in $z$ result in much larger changes to $y$ than when $z$ is a large\npositive or negative number. The following table shows the sigmoid function's\noutput for input values from 5 to 10, as well as the corresponding precision\nrequired to capture the differences in the results.\n\n| input | logistic output | required digits of precision |\n|-------|-----------------|------------------------------|\n| 5 | 0.993 | 3 |\n| 6 | 0.997 | 3 |\n| 7 | 0.999 | 3 |\n| 8 | 0.9997 | 4 |\n| 9 | 0.9999 | 4 |\n| 10 | 0.99998 | 5 |\n\nIf you used squared loss to calculate errors for the sigmoid function, as the\noutput got closer and closer to `0` and `1`, you would need more memory to\npreserve the precision needed to track these values.\n\nInstead, the loss function for logistic regression is\n[**Log Loss**](/machine-learning/glossary#Log_Loss). The\nLog Loss equation returns the logarithm of the magnitude of the change, rather\nthan just the distance from data to prediction. Log Loss is calculated as\nfollows:\n\n\\\\(\\\\text{Log Loss} = \\\\sum_{(x,y)\\\\in D} -y\\\\log(y') - (1 - y)\\\\log(1 - y')\\\\)\n\n\u003cbr /\u003e\n\nwhere:\n\n- \\\\((x,y)\\\\in D\\\\) is the dataset containing many labeled examples, which are \\\\((x,y)\\\\) pairs.\n- \\\\(y\\\\) is the label in a labeled example. Since this is logistic regression, every value of \\\\(y\\\\) must either be 0 or 1.\n- \\\\(y'\\\\) is your model's prediction (somewhere between 0 and 1), given the set of features in \\\\(x\\\\).\n\nRegularization in logistic regression\n\n[**Regularization**](/machine-learning/glossary#regularization), a mechanism for\npenalizing model complexity during training, is extremely important in logistic\nregression modeling. Without regularization, the asymptotic nature of logistic\nregression would keep driving loss towards 0 in cases where the model has a\nlarge number of features. Consequently, most logistic regression models use one\nof the following two strategies to decrease model complexity:\n\n- [L~2~ regularization](/machine-learning/crash-course/overfitting/regularization)\n- [Early stopping](/machine-learning/crash-course/overfitting/regularization#early_stopping_an_alternative_to_complexity-based_regularization): Limiting the number of training steps to halt training while loss is still decreasing.\n\n| **Note:** You'll learn more about regularization in the [Datasets, Generalization, and Overfitting](/machine-learning/crash-course/overfitting) module of the course.\n| **Key terms:**\n|\n| - [Gradient descent](/machine-learning/glossary#gradient-descent)\n| - [Linear regression](/machine-learning/glossary#linear_regression)\n| - [Log Loss](/machine-learning/glossary#Log_Loss)\n| - [Logistic regression](/machine-learning/glossary#logistic_regression)\n| - [Loss function](/machine-learning/glossary#loss-function)\n| - [Overfitting](/machine-learning/glossary#overfitting)\n| - [Regularization](/machine-learning/glossary#regularization)\n- [Squared loss](/machine-learning/glossary#l2-loss) \n[Help Center](https://support.google.com/machinelearningeducation)"]]