logo

Crowdly

Browser

Add to Chrome

Questions Bank (1631747 total)

Принц Гаррі, головний персонаж історичної хроніки Шекспіра «Генріх ІV», виховується:
0%
0%
0%
0%
View this question

 Визначте розмір грошових  агрегатів М0 та М1, якщо відомі такі показники:

-         грошова маса – 43750 млн грн;

-         кошти на строкових рахунках у банках – 2560 млн грн.

-         кошти на поточних рахунках у банках – 1580 млн. грн.

-         довгострокові депозитні сертифікати – 200 млн. грн.

View this question
Яка форма рельєфу зображена на рисунку?

0%
0%
0%
View this question

За якими ознаками класифікують мікропроцесори ?

✅
❌
✅
✅
❌
✅
✅
View this question
Франческо Петрарка присвятив свої вірші:
0%
0%
0%
0%
View this question
Що принесли дві ластівка Трістана і що згодом було зашито в його жупані:
100%
0%
0%
0%
View this question

Що означає на карті масштабу 1:500 умовний знак?

❌
✅
❌
View this question
Герой історичної хроніки Шекспіра «Річард ІІІ» стає королем завдяки:
0%
0%
0%
0%
View this question

Question 4 (25 marks)

4.1 Write a pseudo code/ algorithm for the K-means clustering algorithm.(10)

4.2   Explain why accuracy is not always the ideal metric for model evaluation (5)

 

 4.3 Use Table 4.3 to answer the following questions:  

     

     Table 4.3

·         age: Patient age (years).

·         blood_pressure: Systolic blood pressure (mmHg)

·         cholesterol: Serum cholesterol level (mg/dL)

·         has_disease: Binary target indicating if the patient has the disease (1 = yes, 0 = no)

Complete the following code to show a Python code snippet to train the decision tree and logistic regression models for making predictions.

import pandas as pd

from sklearn.linear_model import LogisticRegression

from sklearn.model_selection import train_test_split

from sklearn.metrics import classification_report, confusion_matrix

 

# Load the data in the dataframe

data = {

    "age": [40, 55, 60, 45, 50, 35, 70, 65, 54, 75],

    "blood_pressure": [120, 140, 130, 135, 142, 110, 160, 150, 138, 170],

    "cholesterol": [200, 210, 250, 240, 190, 180, 260, 210, 225, 280],

    "has_disease": [0, 1, 0, 1, 0, 0, 1, 1, 0, 1]

}

df = pd.DataFrame(data)

 

# Split into features (X) and target (y)

X = df[["age", "blood_pressure", "cholesterol"]]

y = df["has_disease"]

 

 

# Dataset split

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)

 # Code for training the Decision tree and make predictions (5)

………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………

# Code for training the Logistic regression  and make predictions                                                 (5)

………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………

View this question

Question 3 (25 marks)

3.1 Use Table 3.1  to answer the following questions:

Table 3.1

square_footage

num_bedrooms

age

location

price

800

2

10

Urban

350000

1200

3

5

Suburban

245000

1500

4

10

Urban

400000

1800

3

20

Urban

300000

2500

4

7

Rural

200000

900

2

25

Urban

250000

1100

5

15

Suburban

320000

2200

4

17

Rural

280000

square_footage is the area of the house in square feet.

num_bedrooms is the number of bedrooms.

age is the age of the house in years.

location is the location of the which is Urban, Suburban or Rural.

price is the cost of the house in ZAR (rand).

Using the following imported libraries:

import pandas as pd

import numpy as np

import matplotlib.pyplot as plt

from sklearn.model_selection import train_test_split

from sklearn.linear_model import LinearRegression

from sklearn.metrics import mean_squared_error, r2_score

from sklearn.preprocessing import LabelEncoder

Each question has a weighting of 5 marks.

(a )Write Python code snippet to load the houses data in a dataframe

(b) Write a Python code snippet to separate independent features/attributes and a target feature (price).                                                                                                                   

 

(c) Write a Python code snippet to apply label-encoding (one-hot encoding) to the location column. 

                                                                                                                           

(d) Write a Python code snippet to split the dataset into 80% train and 20% test.

(e) Write a Python code snippet to train a linear regression model (using the test dataset) and predict the house price of a house with 2000 square_footage, num_bedrooms: 5, age: 5 and location:  Urban.                                                                                                                             

(a                                                                                                                               

View this question