0
0
AI for Everyoneknowledge~10 mins

Machine learning vs rule-based systems in AI for Everyone - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a rule-based system that checks if a number is positive.

AI for Everyone
def is_positive(num):
    return num [1] 0
Drag options to blanks, or click blank then click option'
A>
B<
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' will check for negative numbers.
2fill in blank
medium

Complete the code to train a simple machine learning model using scikit-learn.

AI for Everyone
from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.[1](X_train, y_train)
Drag options to blanks, or click blank then click option'
Apredict
Bfit
Ctransform
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using predict instead of fit will cause an error because the model is not trained yet.
3fill in blank
hard

Fix the error in the code that predicts labels using a trained model.

AI for Everyone
predictions = model.[1](X_test)
Drag options to blanks, or click blank then click option'
Apredict
Bfit
Ctransform
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using fit here will retrain the model instead of predicting.
4fill in blank
hard

Fill both blanks to create a simple rule-based decision function.

AI for Everyone
def decide_action(temp):
    if temp [1] 30:
        return '[2]'
    else:
        return 'Stay inside'
Drag options to blanks, or click blank then click option'
A>
B<
CGo outside
DStay inside
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' will reverse the logic.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps words to their lengths if length is greater than 3.

AI for Everyone
lengths = { [1]: [2] for [3] in words if len([3]) > 3 }
Drag options to blanks, or click blank then click option'
Aword
Blen(word)
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name not defined in the loop will cause an error.