Distance Formula (KNN)
Step-by-step Euclidean distance calculations
1. Target Data (নতà§à¦¨ Sample)
2. K Value (Neighbors)
3. Sample Points
Step 1: Distance formula বà§à¦¯à¦¬à¦¹à¦¾à¦° করবো
KNN ঠসাধারণত Euclidean distance বà§à¦¯à¦¬à¦¹à¦¾à¦° করা হয়।
d = √(x₂ - x₁)² + (y₂ - y₁)²
💡 সহজ বà§à¦¯à¦¾à¦–à§à¦¯à¦¾:
(x₁, y₁)হলো আমাদের Target Data বা নতà§à¦¨ Point।(x₂, y₂)হলো আগে থেকে দেয়া Sample Data।- আমরা পà§à¦°à¦¤à¦¿à¦Ÿà¦¿ Sample à¦à¦° সাথে নতà§à¦¨ Point টির
xandyà¦à¦° পারà§à¦¥à¦•à§à¦¯ (বিয়োগফল) বের করে বরà§à¦— (square) করি, তারপর যোগ করে রà§à¦Ÿ (square root) করে Distance বের করি।
Step 2: সব sample à¦à¦° distance বের করি
Sample 1 → (7, 7) → Bad
7 − 3 = 4) à¦à¦¬à¦‚ Y à¦à¦° পারà§à¦¥à¦•à§à¦¯ (7 − 7 = 0) বের করে বরà§à¦— (square) করা হলো।Distance
= √[(7 − 3)² + (7 − 7)²]
= √[16 + 0]
= √16
= 4
Sample 2 → (7, 4) → Bad
7 − 3 = 4) à¦à¦¬à¦‚ Y à¦à¦° পারà§à¦¥à¦•à§à¦¯ (4 − 7 = -3) বের করে বরà§à¦— (square) করা হলো।Distance
= √[(7 − 3)² + (4 − 7)²]
= √[16 + 9]
= √25
= 5
Step 3: Exam Answer Format (Summary Table)
পরীকà§à¦·à¦¾à¦° খাতায় ঠিক à¦à¦‡ ফরমà§à¦¯à¦¾à¦Ÿà§‡ টেবিল করে উতà§à¦¤à¦° লিখলে à¦à¦¾à¦²à§‹ নমà§à¦¬à¦° পাওয়া যাবে:
| Name | X Value | Y Value | Class | Distance |
|---|---|---|---|---|
| Sample 1 | 7 | 7 | Bad | √[(7−3)² + (7−7)²] = 4 |
| Sample 2 | 7 | 4 | Bad | √[(7−3)² + (4−7)²] = 5 |
Conclusion (for K = 3)
যেহেতৠK = 3, তাই আমরা সবচেয়ে কাছের (কম distance) 3 টি neighbor বা sample নিবো:
- 1Sample 1 — Distance: 4 (Bad)
- 2Sample 2 — Distance: 5 (Bad)
✅ চূড়ানà§à¦¤ সিদà§à¦§à¦¾à¦¨à§à¦¤ (Final Prediction):
উপরের à¦à¦‡ 3 টি Nearest Neighbors à¦à¦° মধà§à¦¯à§‡ যে Label টি সবচেয়ে বেশিবার আছে (Majority Vote), আমাদের নতà§à¦¨ Point টির Label ও সেটিই হবে!
How does this calculator work?
This tool follows the exact Euclidean distance workflow used in K-Nearest Neighbors (KNN). The core idea is simple: a new data point is compared with previously labeled sample points, and the algorithm checks which samples are closest. In this page, you enter a target point (X, Y), define the value of K, and then add as many labeled sample points as you want. For each sample, the calculator performs the formula step by step: subtract X values, subtract Y values, square both differences, add the squared values, and take the square root. The final number is the distance between your target point and that sample.
After all distances are computed, the samples are sorted from smallest to largest distance. The top K items become the nearest neighbors. A majority vote is then used: whichever class label appears most frequently among those K neighbors is selected as the predicted class for the new point. For example, if K = 3 and the nearest labels are Good, Good, and Bad, then the predicted label is Good. This is why choosing K matters. A very small K can be noisy, while a very large K can over-smooth patterns. In practice, students test multiple K values and compare outcomes.
The calculator also presents exam-style output so you can copy a clean structure into assignments or written answers. Instead of only giving a final number, it shows the working process, intermediate values, and a summary table. That helps in three ways: first, it improves conceptual understanding; second, it makes it easier to verify mistakes in arithmetic; third, it matches what teachers usually expect in problem-solving questions. If your distance seems wrong, check whether you entered negative values correctly and whether you squared each difference before summing.
Although this page demonstrates a 2D version (X and Y), the same mechanism works for higher dimensions in analytics, AI, and business forecasting tasks. In a multi-feature dataset, the formula simply extends to more variables: you compute squared differences for each feature, sum all of them, and take the square root once. So this tool is a foundation for broader machine-learning interpretation, especially for students who are transitioning from statistics to practical classification models.
What is the grading scale at Daffodil International University?
At DIU, most undergraduate programs including BBA use a 4.00 GPA system with letter grades. The exact cutoffs may be revised by the university, so students should always verify the current official scale from DIU academic regulations. A commonly used pattern in many DIU courses is: A+ (4.00), A (3.75), A- (3.50), B+ (3.25), B (3.00), B- (2.75), C+ (2.50), C (2.25), D (2.00), and F (0.00). Some courses may also include status outcomes like Incomplete or Withdrawn depending on policy and deadlines.
Why mention grading scale on a distance-formula page? Because BBA students often solve quantitative tools as part of assessed coursework, quizzes, and exams. Knowing how grading works helps you plan effort strategically: show full steps, avoid shortcut-only answers, and present a clear conclusion. In many grading rubrics, method marks are awarded even when the final label is incorrect due to a minor arithmetic error. This means the structured derivation shown by this calculator can directly improve exam performance and report quality.
Frequently asked questions about calculating BBA credits
1) How do I calculate total earned credits in BBA?
Add the credit hours of all courses you have passed. Failed courses do not add to earned credits until retaken and passed. Always compare your own calculation with the official student portal transcript.
2) How is CGPA connected to credits?
CGPA is a weighted average. For each course, multiply grade point by course credits to get quality points. Sum all quality points and divide by total attempted credits (or policy-specific denominator defined by the university).
3) If I improve a grade in a retake, what happens?
Retake and grade replacement rules depend on DIU policy at the time of your semester. In many cases, the latest valid grade is considered, but you must confirm the exact rule from your department office.
4) Do non-credit or lab components affect CGPA?
Credit-bearing components affect CGPA. Non-credit activities usually do not, but they may still be graduation requirements. Labs that carry credit are included in GPA/CGPA.
5) What is the safest way to track BBA progress?
Maintain a simple sheet with course code, title, credit hours, letter grade, grade point, semester, and status. Update it after each published result and reconcile it with official records.