-
-
Save amankharwal/85f63d3fb7534d34119b2ef53be5905a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prepare_data(df,forecast_col,forecast_out,test_size): | |
label = df[forecast_col].shift(-forecast_out) #creating new column called label with the last 5 rows are nan | |
X = np.array(df[[forecast_col]]) #creating the feature array | |
X = preprocessing.scale(X) #processing the feature array | |
X_lately = X[-forecast_out:] #creating the column i want to use later in the predicting method | |
X = X[:-forecast_out] # X that will contain the training and testing | |
label.dropna(inplace=True) #dropping na values | |
y = np.array(label) # assigning Y | |
X_train, X_test, Y_train, Y_test = train_test_split(X, y, test_size=test_size, random_state=0) #cross validation | |
response = [X_train,X_test , Y_train, Y_test , X_lately] | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment