Description
A linear model may predict negative values. However, such values can be meaningless because the salary can't be negative. In this stage, handle negative predictions.
Objectives
- Read the data. For downloading the dataset refer to Stage 1;
- Load data with
pandas.read_csv; - As predictors select those variables that gave the best metric in the previous stage. Make
Xa DataFrame with predictors andya series with a target. To makeX, drop target variable from the data. - Split predictors and the target into train and test parts. Use
test_size=0.3andrandom_state=100— they guarantee that the results will be the same as the test system expects. - Fit the model that predicts salary based on all other variables;
- Predict the salaries.
- Try two techniques to deal with negative predictions:
- replace the negative values with
0; - replace the negative values with the median of the training part of
y.
- replace the negative values with
- Calculate the MAPE for every two options and print the best as a floating number rounded to five decimal places.
Example
Example 1: program output
0.00001