相关疑难解决方法(0)

预期的二维数组,得到一维数组而不是错误

我收到错误为

“ValueError:预期的二维数组,而是得到一维数组:数组=[ 45000. 50000. 60000. 80000. 110000. 150000. 200000. 300000. 500000. 1000000. 1000000. 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000. ) 如果您的数据具有单个特征或 array.reshape(1, -1) 如果它包含单个样本。”

在执行以下代码时:

# SVR

# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Importing the dataset
dataset = pd.read_csv('Position_S.csv')
X = dataset.iloc[:, 1:2].values
y = dataset.iloc[:, 2].values

 # Feature Scaling
from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
sc_y = StandardScaler()
X = sc_X.fit_transform(X)
y = sc_y.fit_transform(y)

# Fitting SVR to the dataset
from sklearn.svm …
Run Code Online (Sandbox Code Playgroud)

python machine-learning data-science

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

data-science ×1

machine-learning ×1

python ×1