I have dataframe with columns Year, month, day,hour, minute, second, Daily_KWH. I need to predict Daily KWH using neural netowrk. Please let me know how to go about it
      Daily_KWH_System  year  month  day  hour  minute  second
0          4136.900384  2016      9    7     0       0       0
1          3061.657187  2016      9    8     0       0       0
2          4099.614033  2016      9    9     0       0       0
3          3922.490275  2016      9   10     0       0       0
4          3957.128982  2016      9   11     0       0       0
I'm getting the Value Error, when I'm fitting the model.
code so far:
X = df[['year','month','day','hour','minute','second']]
y = df['Daily_KWH_System']
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y)
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
# Fit only to the training data
scaler.fit(X_train)
#y_train.shape
#X_train.shape
X_train = scaler.transform(X_train)
X_test = scaler.transform(X_test)
from sklearn.neural_network import MLPClassifier
mlp = MLPClassifier(hidden_layer_sizes=(30,30,30))
#y_train = np.asarray(df['Daily_KWH_System'], dtype="|S6") 
mlp.fit(X_train,y_train)
Error:
ValueError: Unknown label type: (array([  2.27016856e+02,   3.02173014e+03,   4.29404190e+03,
     2.41273427e+02,   1.76714247e+02,   4.23374425e+03,
                The fit() function expects y to be 1D list. By slicing a Pandas dataframe you always get a 2D object. This means that for your case, you need to convert the 2D object you got from slicing the DataFrame into an actual 1D list, as expected by fit function:
y = list(df['Daily_KWH_System'])
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With