0
0
Intro to Computingfundamentals~10 mins

Machine learning concept in Intro to Computing - Interactive Code Practice

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

Complete the code to import the machine learning library.

Intro to Computing
import [1]
Drag options to blanks, or click blank then click option'
Anumpy
Btensorflow
Cpandas
Dmatplotlib
Attempts:
3 left
💡 Hint
Common Mistakes
Importing numpy instead of tensorflow
Importing pandas which is for data manipulation
Importing matplotlib which is for plotting
2fill in blank
medium

Complete the code to create a simple linear regression model using scikit-learn.

Intro to Computing
from sklearn.linear_model import [1]
model = [1]()
Drag options to blanks, or click blank then click option'
ALinearRegression
BLogisticRegression
CDecisionTreeClassifier
DKMeans
Attempts:
3 left
💡 Hint
Common Mistakes
Using LogisticRegression which is for classification
Using DecisionTreeClassifier which is for classification
Using KMeans which is for clustering
3fill in blank
hard

Fix the error in the code to split data into training and testing sets with test_size=0.2.

Intro to Computing
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=[1], random_state=42)
Drag options to blanks, or click blank then click option'
A0.5
B50
C0.2
D'0.2'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an integer like 50 instead of a float
Passing the number as a string
Using a value greater than 1
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if the length is greater than 3.

Intro to Computing
{word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Clen(word) > 3
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value
Checking if the word is greater than 3 (which is invalid)
Not using len(word) in the condition
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their frequencies only if frequency is greater than 1.

Intro to Computing
{ [1]: [2] for [3], [2] in word_counts.items() if [2] > 1 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Bcount
Cword
Dfreq
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original word as key without uppercasing
Using inconsistent variable names for count
Not filtering counts greater than 1