質問するログイン新規登録

質問編集履歴

3

ご指摘頂きまして、最初の投稿内容に戻しました

2020/03/31 11:34

投稿

iziz
iziz

スコア8

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  参考書に記載されている方法でがんの遺伝子発現量のPCAを試しにやっています。
2
- 下記のコード実行結果で
2
+ 下記のコード実行すると
3
3
 
4
4
  ```python
5
5
  import math
@@ -33,24 +33,9 @@
33
33
  plt.ylabel('pc2')
34
34
  plt.show()
35
35
 
36
- 主成分 [[ 0.0031 0.0077 -0.0001 ... 0.0009 0.0007 0.0079]
37
- [ 0.0018 -0.0054 0.0014 ... 0.0023 0.0005 0.0075]
38
- [-0.0029 -0.0009 0.0076 ... -0.0004 0.0079 -0.0005]
39
- ...
40
- [ 0.0034 0.0007 -0.0008 ... 0.003 -0.0045 0.0001]
41
- [-0.0035 0.0005 -0.0015 ... 0.0007 -0.001 0.0019]
42
- [-0.0384 0.0004 -0.0158 ... 0.0079 -0.0002 0.0066]]
43
- 平均 [-8.43311000e-18 3.04584692e-16 9.11922127e-16 ... -5.46995667e-16
44
- 7.02818867e-17 -4.11093644e-16]
36
+ 下記の様なエラーが出ます
45
- Traceback (most recent call last):
46
- File "PCA_gdc.py", line 16, in <module>
47
- print('共分散',pca.get_covariance())
48
- File "/home/usr/.local/lib/python3.6/site-packages/sklearn/decomposition/_base.py", line 43, in get_covariance
49
- cov = np.dot(components_.T * exp_var_diff, components_)
50
- File "<__array_function__ internals>", line 6, in dot
51
- MemoryError: Unable to allocate 25.3 GiB for an array with shape (58312, 58312) and data type float64
52
37
 
38
+ ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
53
39
 
54
40
  ```
55
-
56
- メモリ不足を意味するエラーかも思いましたが、対処法について教えて頂けますでしょうか
41
+ エラーの内容と対処法について教えて下さい

2

エラーをコード内に表示しました。

2020/03/31 11:34

投稿

iziz
iziz

スコア8

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  参考書に記載されている方法でがんの遺伝子発現量のPCAを試しにやっています。
2
- 下記のコード実行すると、
2
+ 下記のコード実行結果で
3
3
 
4
4
  ```python
5
5
  import math
@@ -32,10 +32,7 @@
32
32
  plt.xlabel('pc1')
33
33
  plt.ylabel('pc2')
34
34
  plt.show()
35
- ```
36
35
 
37
- 下記のエラーが出ます。
38
-
39
36
  主成分 [[ 0.0031 0.0077 -0.0001 ... 0.0009 0.0007 0.0079]
40
37
  [ 0.0018 -0.0054 0.0014 ... 0.0023 0.0005 0.0075]
41
38
  [-0.0029 -0.0009 0.0076 ... -0.0004 0.0079 -0.0005]
@@ -53,4 +50,7 @@
53
50
  File "<__array_function__ internals>", line 6, in dot
54
51
  MemoryError: Unable to allocate 25.3 GiB for an array with shape (58312, 58312) and data type float64
55
52
 
53
+
54
+ ```
55
+
56
56
  メモリ不足を意味するエラーかもと思いましたが、対処法について教えて頂けますでしょうか。

1

ご指摘頂いた通り、nullを含むサンプルが見つかったので、そのサンプルを除外して再度実行した結果を示しました。

2020/03/30 15:55

投稿

iziz
iziz

スコア8

title CHANGED
File without changes
body CHANGED
@@ -36,6 +36,21 @@
36
36
 
37
37
  下記のエラーが出ます。
38
38
 
39
+ 主成分 [[ 0.0031 0.0077 -0.0001 ... 0.0009 0.0007 0.0079]
40
+ [ 0.0018 -0.0054 0.0014 ... 0.0023 0.0005 0.0075]
41
+ [-0.0029 -0.0009 0.0076 ... -0.0004 0.0079 -0.0005]
42
+ ...
43
+ [ 0.0034 0.0007 -0.0008 ... 0.003 -0.0045 0.0001]
44
+ [-0.0035 0.0005 -0.0015 ... 0.0007 -0.001 0.0019]
45
+ [-0.0384 0.0004 -0.0158 ... 0.0079 -0.0002 0.0066]]
46
+ 平均 [-8.43311000e-18 3.04584692e-16 9.11922127e-16 ... -5.46995667e-16
47
+ 7.02818867e-17 -4.11093644e-16]
48
+ Traceback (most recent call last):
49
+ File "PCA_gdc.py", line 16, in <module>
50
+ print('共分散',pca.get_covariance())
51
+ File "/home/usr/.local/lib/python3.6/site-packages/sklearn/decomposition/_base.py", line 43, in get_covariance
52
+ cov = np.dot(components_.T * exp_var_diff, components_)
53
+ File "<__array_function__ internals>", line 6, in dot
39
- ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
54
+ MemoryError: Unable to allocate 25.3 GiB for an array with shape (58312, 58312) and data type float64
40
55
 
41
- エラーの内容と対処法教えて頂けないでしょうか。
56
+ メモリ不足を意味するエラーかも思いましたが、対処法について教えて頂けますでしょうか。