0% found this document useful (0 votes)
246 views4 pages

Machine Learning Exam: Python Focus

fgf
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
246 views4 pages

Machine Learning Exam: Python Focus

fgf
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Exam Paper 1

Machine Learning using Python [Time: 4 hrs]


[Total Marks: 50]
Exam – Paper 1

Part I: Supervised Learning [Total Marks - 30]

Given is the ‘Portugal Bank Marketing’ dataset:

Bank client data:


1) age (numeric)

2) job: type of
job(categorical:"admin.","bluecollar","entrepreneur","housemaid","management","retired","self-
employed","services","student","technician","unemployed","unknown")

3) marital: marital status (categorical: "divorced","married","single","unknown"; note: "divorced"


means divorced or widowed)

4) education: education of individual (categorical:


"basic.4y","basic.6y","basic.9y","[Link]","illiterate","[Link]","[Link]","u
nknown")

5) default: has credit in default? (categorical: "no","yes","unknown")

6) housing: has housing loan? (categorical: "no","yes","unknown")

7) loan: has personal loan? (categorical: "no","yes","unknown")

Related with the last contact of the current campaign:


8) contact: contact communication type (categorical: "cellular","telephone")

9) month: last contact month of year (categorical: "jan", "feb", "mar", …, "nov", "dec")

10) dayofweek: last contact day of the week (categorical: "mon","tue","wed","thu","fri")

11) duration: last contact duration, in seconds (numeric). Important note: this attribute highly
affects the output target (e.g., if duration=0 then y="no"). Yet, the duration is not known before a call
is performed. Also, after the end of the call y is obviously known. Thus, this input should only be
included for benchmark purposes and should be discarded if the intention is to have a realistic
predictive model.
Exam Paper 1

Other attributes:
12) campaign: number of contacts performed during this campaign and for this client (numeric,
includes last contact)

13) pdays: number of days that passed by after the client was last contacted from a previous
campaign (numeric; 999 means client was not previously contacted)

14) previous: number of contacts performed before this campaign and for this client (numeric)

15) poutcome: outcome of the previous marketing campaign (categorical:


"failure","nonexistent","success")

Social and economic context attributes


16) [Link]: employment variation rate - quarterly indicator (numeric)

17) [Link]: consumer price index - monthly indicator (numeric)

18) [Link]: consumer confidence index - monthly indicator (numeric)

19) concavepoints_se: standard error for number of concave portions of the contour

20) euribor3m: euribor 3 month rate - daily indicator (numeric)

21) [Link]: number of employees - quarterly indicator (numeric)

Output variable (desired target):

22) y: has the client subscribed a term deposit? (binary: "yes","no")

Perform the following tasks: Marks


Q1. What does the primary analysis of several categorical [5]
features reveal?
Q2. Perform the following Exploratory Data Analysis tasks: [10]
a. Missing Value Analysis
b. Label Encoding wherever required
c. Selecting important features based on Random Forest
d. Handling unbalanced data using SMOTE
e. Standardize the data using the anyone of the scalers
provided by sklearn
Exam Paper 1

Q3. Build the following Supervised Learning models: [10]


a. Logistic Regression
b. AdaBoost
c. Naïve Bayes
d. KNN
e. SVM
Q4. Tabulate the performance metrics of all the above models [5]
and tell which model performs better in predicting if the
client will subscribe to term deposit or not

Part II: Time Series [Total Marks - 20]

For the given data ‘MonthWiseMarketArrivals_Clean.csv’, below is attribute


information:

This dataset is about Indian onion market.

1. Market Name - Market Place Name


2. Month - Month (January-December)
3. Year - 1996-2016
4. Quantity - Quantity of Onion (in Kgs)
5. priceMin - Minimum Selling Price
6. priceMax - Maximum Selling Price
7. Pricemod - Modal Price
8. State - State of market
9. City - City of market
10. Date - Date of arrival
Exam Paper 1

Perform the following tasks: Marks


Q1. Get the modal price of onion for each month for the Mumbai [2]
market (Hint: set monthly date as index and drop
redundant columns)
Q2. Build time series model and check the performance of the [8]
model using RMSE
Q3. Plot ACF and PACF plots [5]
Q4. Exponential smoothing using Holt-Winter’s technique and [5]
Forecast onion price for Mumbai market

Common questions

Powered by AI

Label encoding assigns numerical values to categorical variables, but it can erroneously introduce ordinal relationships where none exist. This misrepresentation is particularly challenging in algorithms sensitive to input ordering, like decision trees. A mitigation strategy involves using one-hot encoding, which represents categories as binary vectors, preventing unintended ordinal effects and preserving data's categorical nature, enhancing model fidelity .

Analyzing categorical features like 'job', 'marital status', 'education', and 'contact' type can reveal patterns or correlations with the response variable (subscription to a term deposit). Such insights can inform feature selection, for instance, identifying that certain jobs or marital statuses might correlate with higher subscription rates, guiding the focus on these features during model training. This strategic selection enhances model efficiency by prioritizing impactful data attributes .

Building a time series model involves selecting a suitable model (e.g., ARIMA), transforming data for stationarity, and fitting the model to historical price data. RMSE (Root Mean Square Error) is then computed as a metric to quantify prediction accuracy by measuring the average deviation of predicted values from actual prices. Lower RMSE values indicate higher model accuracy, providing insights into model reliability and precision for price forecasting .

ACF plots show correlations between current and lagged values for various lags, suggesting if observations are autocorrelated, while PACF plots help identify the order of autoregressive terms by showing direct correlations, eliminating intermediate correlation effects. Analyzing these plots guides in setting ARIMA model parameters (p, d, q), enhancing model accuracy by identifying essential past observations influencing current values, ensuring well-specified models fit to the data's memory structure .

Analyzing monthly modal price trends of onions can uncover patterns in price fluctuations, seasonal influences, and supply-demand dynamics. Variable trends indicate responses to economic, climatic, and policy shifts. This data allows stakeholders to predict future pricing and strategize inventory or financial decisions. Long-term analyses enhance understanding of price volatilities, informing policy makers and businesses about potential economic impacts or opportunities for market interventions and sustainability .

Holt-Winter's technique enhances forecasting by integrating level, trend, and seasonality components, providing a more flexible model, particularly for seasonal data like onion prices. Unlike simple moving averages, which only consider recent values to smooth time series, Holt-Winter's accounts for fluctuating seasonal patterns and trends, offering comprehensive and adaptive predictions, beneficial for complex time-related variations in markets .

Comparing the performance of models involves evaluating metrics like accuracy, precision, recall, and F1-score. Logistic regression provides a clear probability distribution, effective with large feature space, but it assumes linearity. AdaBoost enhances weak predictors iteratively, good for complex patterns. Naïve Bayes is efficient with categorical data but assumes independence. KNN is intuitive but suffers with high dimensionality. SVM is robust with small datasets and non-linear decision boundaries. Each model's effectiveness is influenced by data distribution, feature linearity, dimensionality, and class imbalance .

To address data imbalance, the SMOTE technique can be used, which involves synthesizing new data points for the minority class to create a balanced dataset. This process is crucial as imbalance can lead to biased models which favor the majority class, reducing the generalization and accuracy of predictions on new data. Creating a balanced dataset ensures that the model adequately learns traits of both class outcomes, enhancing predictive reliability .

Feature standardization scales numeric features to a common range, often crucial when models like SVMs and KNNs are sensitive to the magnitude of inputs. Using a scaler, such as StandardScaler from sklearn, ensures numeric features are normalized, reducing biases in distance-based algorithms. This process enhances convergence speed and provides a stable learning environment, improving overall model performance and accuracy .

The 'duration' attribute significantly affects the model's output because longer call durations are associated with positive client responses ('yes'). However, this data is not available until the call occurs, and thus cannot be used to predict the outcome prior to the call without skewing the model's results. As such, including 'duration' in model training would lead to an overestimation of predictive performance because it uses information not available at decision-making time, making the model unrealistic for practical use .

You might also like