Machine Learning & AI · Chapter 4.0 · Start Here level

Start Here: What is AI? (Data + Your First Prediction)

शुरुआत: AI क्या है? (Data + आपकी पहली Prediction)

Normal coding: YOU write the rule — if marks >= 33: print("Pass"). Machine Learning (ML): you give the computer many examples (data) and it finds the rule by itself. That is how YouTube guesses which video you will like and how Google Maps predicts traffic. In Python, data is usually a list: runs = [32, 45, 28, 51, 44]. The simplest 'model' of all is the average: if Rohan's last 5 scores average 40, a fair guess for the next match is 40. sum(runs) adds everything and len(runs) counts the items, so sum(runs) / len(runs) is the average — no ML library needed! Note: in this lab, model, nlp_model, NeuralNetwork and ai_assistant are built-in learning helpers (they do not exist in normal Python). From chapter 4.8 you will write real scikit-learn code that also runs in Google Colab.

नॉर्मल कोडिंग: नियम आप लिखते हो — if marks >= 33: print("Pass")। Machine Learning (ML): आप कंप्यूटर को बहुत सारे उदाहरण (data) देते हो और वह नियम ख़ुद ढूँढ लेता है। YouTube इसी तरह अंदाज़ा लगाता है कि आपको कौन-सा वीडियो पसंद आएगा, और Google Maps ट्रैफ़िक बताता है। Python में data अक्सर एक list होता है: runs = [32, 45, 28, 51, 44]। सबसे आसान 'model' है औसत (average): अगर रोहन के पिछले 5 स्कोर का औसत 40 है, तो अगले मैच के लिए 40 एक सही अंदाज़ा है। sum(runs) सब जोड़ता है और len(runs) गिनता है, इसलिए sum(runs) / len(runs) औसत है — कोई ML library नहीं चाहिए! ध्यान दो: इस लैब में model, nlp_model, NeuralNetwork और ai_assistant पहले से बने सीखने वाले helpers हैं (ये सामान्य Python में नहीं होते)। चैप्टर 4.8 से आप असली scikit-learn कोड लिखोगे जो Google Colab में भी चलता है।

In the classroom you can run and edit this code in your browser, get hints and mark the chapter as done. क्लास में यह code ब्राउज़र में चलाकर बदल सकते हो।

Words and symbols in this chapter

runs = [32, 45, 28, 51, 44]
Data: past examples stored in a list.
Data: पुराने उदाहरण, एक list में रखे हुए।
sum(runs)
Adds all the numbers in the list (here 200).
List के सारे नंबर जोड़ता है (यहाँ 200)।
len(runs)
Counts the items (here 5).
Items गिनता है (यहाँ 5)।
sum(runs) / len(runs)
The average (40.0) — our first "prediction".
औसत (40.0) — हमारी पहली "prediction"।
if average >= 40:
A rule written by a human — that is normal coding.
इंसान का लिखा नियम — यही नॉर्मल कोडिंग है।

Ready example

# Rohan ke pichhle 5 cricket matches ke runs = hamara DATA
runs = [32, 45, 28, 51, 44]

total = sum(runs)
matches = len(runs)
average = total / matches

print("Total runs:", total)
print("Matches:", matches)
print("Prediction for the next match:", average)

# Normal coding: yeh rule insaan ne likha hai
if average >= 40:
    print("Rule says: Rohan is in good form!")

What you will see: The memory boxes show the data list and the average; the terminal shows the prediction.

मेमोरी डिब्बों में data की list और औसत दिखेगा; terminal में prediction छपेगी।

Line by line

runs = [32, 45, 28, 51, 44]
Rohan’s last 5 scores = our dataset.
रोहन के पिछले 5 स्कोर = हमारा dataset।
average = total / matches
The average: 200 / 5 = 40.0
औसत: 200 / 5 = 40.0
print("Prediction for the next match:", average)
The model’s guess for the next match.
अगले मैच के लिए model का अंदाज़ा।
if average >= 40:
Here a human wrote the rule; in ML the computer learns rules from data.
यहाँ नियम इंसान ने लिखा; ML में कंप्यूटर data से नियम सीखता है।

Common mistake

✗ Wrong

total = sum(32, 45, 28)

✓ Right

total = sum([32, 45, 28])

sum() needs ONE list inside square brackets [ ], not separate numbers (that gives a TypeError).

sum() को square brackets [ ] में एक list चाहिए, अलग-अलग नंबर नहीं (उससे TypeError आती है)।

Your task

Find the average of temps with sum() and len() and print it as the prediction for tomorrow (it should be 32.0).

sum() और len() से temps का औसत निकालो और उसे कल की prediction के रूप में print करो (32.0 आना चाहिए)।

  1. Write total = sum(temps).
    total = sum(temps) लिखो।
  2. Write average = total / len(temps).
    average = total / len(temps) लिखो।
  3. Write print("Prediction for tomorrow:", average) and Run — you should see 32.0.
    print("Prediction for tomorrow:", average) लिखकर Run करो — 32.0 दिखना चाहिए।
Starter code for the task
# Jaipur ka pichhle 5 din ka temperature (degree C)
temps = [31, 33, 30, 34, 32]

# TODO 1: total = sum(temps)
# TODO 2: average = total / len(temps)
# TODO 3: print("Prediction for tomorrow:", average)

Do this task in the classroom: your code is checked automatically and you get hints if something is missing.

Recap

Quick quiz

What is the main difference between normal coding and Machine Learning?

नॉर्मल कोडिंग और Machine Learning में मुख्य फ़र्क़ क्या है?

  1. ML needs no data
  2. In normal coding we write the rules; in ML the computer learns the rules from examples (data)
  3. ML works only on phones
  4. There is no difference
Show the answer

Answer: B (In normal coding we write the rules; in ML the computer learns the rules from examples (data))

ML finds the pattern in past examples instead of a human writing every rule.

ML में हर नियम इंसान नहीं लिखता — कंप्यूटर पुराने उदाहरणों से पैटर्न ढूँढता है।

Practice problems for this chapter

Solve them in the Practice Zone, where each answer is checked automatically and two hints are available.