We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I found many notebooks with same error, but no one gave me back a solution to this issue:
X_train = data_train.date[:, np.newaxis]
"Support for multi-dimensional indexing (e.g. obj[:, None]) is deprecated and will be removed in a future version."
obj[:, None]
So, after looking for some answers i found this:
instead using ndarray, use just an array and them reshape it from an 1D array to 2D array with array.reshape(-1, 1) and it will be done
from sklearn.tree import DecisionTreeRegressor
data_train = ram_prices[ram_prices.date < 2000] data_test = ram_prices[ram_prices.date >= 2000]
X_train = np.array(data_train.date) X_train = X_train.reshape(-1, 1) y_train = np.log(data_train.price)
tree = DecisionTreeRegressor().fit(X_train, y_train) linear_reg = LinearRegression().fit(X_train, y_train)
X_all = np.array(ram_prices.date) X_all = X_all.reshape(-1, 1)
pred_tree = tree.predict(X_all) pred_lr = linear_reg.predict(X_all)
price_tree = np.exp(pred_tree) price_lr = np.exp(pred_lr)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I found many notebooks with same error, but no one gave me back a solution to this issue:
X_train = data_train.date[:, np.newaxis]
"Support for multi-dimensional indexing (e.g.
obj[:, None]
) is deprecated and will be removed in a future version."So, after looking for some answers i found this:
instead using ndarray, use just an array and them reshape it from an 1D array to 2D array with array.reshape(-1, 1) and it will be done
from sklearn.tree import DecisionTreeRegressor
data_train = ram_prices[ram_prices.date < 2000]
data_test = ram_prices[ram_prices.date >= 2000]
X_train = np.array(data_train.date)
X_train = X_train.reshape(-1, 1)
y_train = np.log(data_train.price)
tree = DecisionTreeRegressor().fit(X_train, y_train)
linear_reg = LinearRegression().fit(X_train, y_train)
X_all = np.array(ram_prices.date)
X_all = X_all.reshape(-1, 1)
pred_tree = tree.predict(X_all)
pred_lr = linear_reg.predict(X_all)
price_tree = np.exp(pred_tree)
price_lr = np.exp(pred_lr)
The text was updated successfully, but these errors were encountered: