을 그릴 수 없습니다Pyplot가 나는 아주 간단한 예를 모방하려고 회귀
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radiuses
print(type(x),type(y))
print('training samples ',len(x),len(y))
plt.scatter(x, y, c=colors, alpha=0.5)
plt.show()
이 예상대로
<class 'numpy.ndarray'> <class 'numpy.ndarray'>
training samples 50 50
를 표시하고 플롯은 잘 보여줍니다. 지금은 X_train
, y_train
및 X_test
모든 NumPy와 배열이라는 것을
base_regressor = GradientBoostingRegressor()
base_regressor.fit(X_train, y_train)
y_pred_base = base_regressor.predict(X_test)
print(type(X_train),type(y_train))
print('training samples ',len(X_train),len(y_train))
print(type(X_test),type(y_pred_base))
print('base samples ',len(X_test),len(y_pred_base))
plt.figure()
plt.scatter(X_train, y_train, c="k", label="training samples")
plt.plot(X_test, y_pred_base, c="g", label="n_estimators=1", linewidth=2)
plt.xlabel("data")
plt.ylabel("target")
plt.title("Base Regression")
plt.legend()
plt.show()
참고로 GradientBoostingRegressor
의 결과를 플롯하는 것을 시도하고있다. 위의 코드를 위해 나는
<class 'numpy.ndarray'> <class 'numpy.ndarray'>
training samples 74067 74067
<class 'numpy.ndarray'> <class 'numpy.ndarray'>
base samples 166693 166693
를 얻을 수 있지만 줄거리는 표시되지 않습니다 나는
plt.scatter(X_train, y_train, c="k", label="training samples")
에서 오류
ValueError: x and y must be the same size
를 얻을 수 있지만으로는, 출력에 x
및 y
을 볼 수 같은 크기와 유형입니다. 내가 도대체 뭘 잘못하고있는 겁니까?
대신'len (X_test)'를 출력 할 수 있습니다.'X_test.shape'를 출력 할 수 있습니까? – MMF
내 훈련 차원에서 의미가있는 훈련 샘플 (74067, 163) (74067,)과 기본 샘플 (166693, 163) (166693,)이 – AbtPst
인데, – AbtPst