Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Predicting Humidity with Nonlinear Methods

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Predicting Humidity with Nonlinear Methods. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Humidity prediction: fit a model to predict missing humidity readings; any non-linear regression or pandas interpolate passes the MSE-based tests

Asked in the HackerRank stage. Q3. Using the PostgreSQL tables provided, calculate linear interpolations for missing readings that have valid observed readings before and after them.

Output

  1. Return one row per interpolatable missing reading with sensor_id, sensor_name, reading_time, and predicted_humidity.
  2. Exclude missing readings without valid observations on both sides.
  3. Order by sensor_id, then reading_time.

Schema

humidity_readings
ColumnTypeDescription
reading_idPKINTUnique humidity reading identifier
sensor_idINTSensor that recorded the reading
reading_timeTIMESTAMPTimestamp of the reading
humidityNUMERIC(5,2)Observed relative humidity percentage
sensors
ColumnTypeDescription
sensor_idPKINTUnique sensor identifier
sensor_nameVARCHAR(100)Human-readable sensor name
locationVARCHAR(100)Sensor deployment location
Tableshumidity_readingssensors
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results