Using Machine Learning to Predict Temperature I am a beginner in ML and I want to create a smart thermostat, that after collecting enough data from the interaction with the user, it will start to set the home temperature by itself.

What I got so far is the hardware prototype that lets the user set the temperature, and in the same time it posts the Environment and the UserSetTemperature to ThingSpeak (to easily store the data for later access)

The other part is a python algorithm that gets the data from ThingSpeak and it converts it into a Pandas DataFrame.

The data frame looks like bellow:

timeStamp                      environment_temp    user_set_temp  

2018-05-27T00:12:43Z               20            21              
2018-05-27T00:17:27Z               20            22                 
2018-05-27T00:17:59Z               20            24                
2018-05-27T00:20:01Z               20            21                  
2018-05-27T00:23:14Z               20            24                 
2018-05-28T09:39:07Z               20            22             
2018-05-28T10:40:17Z               20            23               
2018-05-28T20:12:47Z               20            25              
2018-05-28T20:14:16Z               23            25               
2018-05-30T20:29:30Z               18            24  


And here is where I got stuck. I don't know how to use this data with the ML libraries in order to make predictions on how the temperature should be set when the environment temperature is x.

I tried to use the sklearn train_test_split() and LinearRegression(), but with no significant result. I really don't know how to use this data

Every suggestion will be highly appreciated!!
I would not recommend going ahead with the data that you know might be wrong.

Looking at your current data, the reason you got a bad result with linear regression is because the relation between them is not linear for the current data. For eg. There is high variation in response (i.e. user_set_temp)  for same value of your predictor (i.e. environment_temp).

First, get hold of correct temperature for your recorded timestamps from local weather data to replace environment temp with this data, till you get the issue rectified with your original recorded environment_temp. When you rectify the issue, then I would recommend you to use both weather and environment temp to predict, as a person might set the temperature depending upon a combination of both. 

After you get a good representative data, this should be a reasonable procedure to help you predict the temperature:


Exploratory data analysis for uni-variate timeseries:
This will help you observe patterns in data, which will help you decide on which new features to engineer/ create from timestamps (step 2) you have of recordings. Also, look at the acf/ pacf plots to help figure out the lags in data that might help you predict better. Fit a basic uni-variate model like STL or ARIMA model to get a good base model for prediction (this model you will compare new models with to see how they perform)
Feature Engineering: Time of day, day of week, week of month etc identified in step 1. Also, look for any other features that might help your algorithm find patterns.
Regression Models: Test with advanced algorithms like RandomForest, Gradient Boosting and RNN-LSTM to check how they perform against each other and the base model.