質問編集履歴
1
コードとエラーを追記いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,23 +14,80 @@
|
|
14
14
|
### 発生している問題・エラーメッセージ
|
15
15
|
|
16
16
|
```
|
17
|
+
ValueError Traceback (most recent call last)
|
18
|
+
~\AppData\Local\Temp/ipykernel_19348/2698015120.py in <module>
|
19
|
+
----> 1 housing_pcp.fit(X_train,y_train)
|
20
|
+
|
21
|
+
~\anaconda3\lib\site-packages\sklearn\linear_model\_stochastic_gradient.py in fit(self, X, y, coef_init, intercept_init, sample_weight)
|
22
|
+
727 Returns an instance of self.
|
17
|
-
|
23
|
+
728 """
|
18
24
|
--> 729 return self._fit(X, y, alpha=self.alpha, C=1.0,
|
19
25
|
730 loss=self.loss, learning_rate=self.learning_rate,
|
20
26
|
731 coef_init=coef_init, intercept_init=intercept_init,
|
21
27
|
|
28
|
+
~\anaconda3\lib\site-packages\sklearn\linear_model\_stochastic_gradient.py in _fit(self, X, y, alpha, C, loss, learning_rate, coef_init, intercept_init, sample_weight)
|
29
|
+
567 self.t_ = 1.0
|
30
|
+
568
|
31
|
+
--> 569 self._partial_fit(X, y, alpha, C, loss, learning_rate, self.max_iter,
|
32
|
+
570 classes, sample_weight, coef_init, intercept_init)
|
33
|
+
571
|
34
|
+
|
35
|
+
~\anaconda3\lib\site-packages\sklearn\linear_model\_stochastic_gradient.py in _partial_fit(self, X, y, alpha, C, loss, learning_rate, max_iter, classes, sample_weight, coef_init, intercept_init)
|
36
|
+
497 n_samples, n_features = X.shape
|
37
|
+
498
|
38
|
+
--> 499 _check_partial_fit_first_call(self, classes)
|
39
|
+
500
|
40
|
+
501 n_classes = self.classes_.shape[0]
|
41
|
+
|
22
|
-
\anaconda3\lib\site-packages\sklearn\utils\multiclass.py in _check_partial_fit_first_call(clf, classes)
|
42
|
+
~\anaconda3\lib\site-packages\sklearn\utils\multiclass.py in _check_partial_fit_first_call(clf, classes)
|
23
43
|
337 else:
|
24
44
|
338 # This is the first call to partial_fit
|
25
45
|
--> 339 clf.classes_ = unique_labels(classes)
|
26
46
|
340 return True
|
47
|
+
341
|
27
48
|
|
49
|
+
~\anaconda3\lib\site-packages\sklearn\utils\multiclass.py in unique_labels(*ys)
|
50
|
+
96 _unique_labels = _FN_UNIQUE_LABELS.get(label_type, None)
|
28
|
-
|
51
|
+
97 if not _unique_labels:
|
52
|
+
---> 98 raise ValueError("Unknown label type: %s" % repr(ys))
|
53
|
+
99
|
54
|
+
100 ys_labels = set(chain.from_iterable(_unique_labels(y) for y in ys))
|
55
|
+
|
56
|
+
ValueError: Unknown label type: (array([ 5. , 6.3, 7. , 7.2, 8.1, 8.3, 8.5, 8.7, 8.8, 9.5, 9.6,
|
57
|
+
10.2, 10.4, 10.5, 10.8, 10.9, 11.3, 11.5, 11.7, 11.8, 11.9, 12. ,
|
58
|
+
12.1, 12.5, 12.6, 12.7, 12.8, 13. , 13.1, 13.2, 13.3, 13.4, 13.5,
|
59
|
+
13.6, 13.8, 13.9, 14. , 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.8,
|
60
|
+
14.9, 15. , 15.1, 15.2, 15.3, 15.4, 15.6, 15.7, 16. , 16.1, 16.2,
|
61
|
+
16.3, 16.4, 16.6, 16.7, 16.8, 17.1, 17.3, 17.4, 17.5, 17.6, 17.7,
|
62
|
+
17.8, 17.9, 18. , 18.1, 18.2, 18.3, 18.4, 18.5, 18.8, 18.9, 19. ,
|
63
|
+
19.1, 19.2, 19.3, 19.4, 19.5, 19.6, 19.7, 19.8, 19.9, 20. , 20.1,
|
64
|
+
20.2, 20.3, 20.4, 20.5, 20.6, 20.7, 20.8, 20.9, 21. , 21.1, 21.2,
|
65
|
+
21.4, 21.5, 21.6, 21.7, 21.8, 21.9, 22. , 22.1, 22.2, 22.3, 22.4,
|
66
|
+
22.5, 22.6, 22.7, 22.8, 22.9, 23.1, 23.2, 23.3, 23.4, 23.6, 23.7,
|
67
|
+
23.8, 23.9, 24. , 24.1, 24.2, 24.3, 24.4, 24.5, 24.6, 24.7, 24.8,
|
68
|
+
25. , 25.1, 25.2, 25.3, 26.4, 26.5, 26.6, 27. , 27.1, 27.5, 27.9,
|
69
|
+
28. , 28.2, 28.4, 28.5, 28.6, 28.7, 29. , 29.1, 29.6, 29.8, 29.9,
|
70
|
+
30.1, 30.3, 30.7, 30.8, 31. , 31.1, 31.5, 31.6, 31.7, 32. , 32.2,
|
71
|
+
32.4, 32.5, 32.7, 33. , 33.1, 33.2, 33.4, 33.8, 34.6, 34.7, 34.9,
|
72
|
+
35.1, 35.2, 35.4, 36. , 36.1, 36.2, 36.4, 36.5, 37. , 37.3, 37.6,
|
73
|
+
37.9, 39.8, 41.7, 42.3, 43.1, 43.5, 43.8, 44. , 45.4, 46. , 46.7,
|
74
|
+
48.5, 48.8, 50. ]),)
|
29
75
|
```
|
30
76
|
|
31
77
|
### 該当のソースコード
|
32
78
|
|
33
79
|
```ここに言語名を入力
|
80
|
+
from sklearn.preprocessing import StandardScaler
|
81
|
+
sc = StandardScaler()
|
82
|
+
sc.fit(housing_X)
|
83
|
+
housing_X = sc.transform(housing_X)
|
84
|
+
|
85
|
+
from sklearn.model_selection import train_test_split
|
86
|
+
X_train, X_test, y_train, y_test = train_test_split(housing_X,housing_y, test_size = 0.3, random_state=0)
|
87
|
+
|
88
|
+
from sklearn.linear_model import Perceptron
|
89
|
+
# 学習
|
90
|
+
housing_pcp = Perceptron(max_iter=40, tol=1e-3, eta0=1.0, shuffle=True)
|
34
91
|
housing_pcp.fit(X_train,y_train)
|
35
92
|
```
|
36
93
|
|