Open Dataset
Data Structure ?
4126.4M
Data Structure ?
*The above analysis is the result extracted and analyzed by the system, and the specific actual data shall prevail.
README.md
# コード画像
[](https://doi.org/10.5281/zenodo.1286417)
## 背景
これは[Zenodo-ML恐竜データセット](https://vsoch.github.io/datasets/2018/zenodo)
[[Github](https://www.github.com/vsoch/zenodo-ml)]のサブセットで、小さなpngファイルに変換され、言語ごとにフォルダに整理されています。これにより、画像入力を前提とする機械学習手法をすぐに使い始めることができます。
## 内容
含まれているのは.tar.gzファイルで、それぞれ拡張子に基づいて命名されており、展開すると同じ名前のフォルダが生成されます。
```
tree -L 1
.
├── c
├── cc
├── cpp
├── cs
├── css
├── csv
├── cxx
├── data
├── f90
├── go
├── html
├── java
├── js
├── json
├── m
├── map
├── md
├── txt
└── xml
```
そして、(やや小さい)セットの中をのぞくと、サブフォルダはゼノド識別子であることがわかります。ゼノド識別子は単一のGitHubリポジトリに対応しているため、生成されたpngファイルは特定のリポジトリからの拡張子タイプのコードのチャンクを表しています。
```
$ tree map -L 1
map
├── 1001104
├── 1001659
├── 1001793
├── 1008839
├── 1009700
├── 1033697
├── 1034342
...
├── 836482
├── 838329
├── 838961
├── 840877
├── 840881
├── 844050
├── 845960
├── 848163
├── 888395
├── 891478
└── 893858
154 directories, 0 files
```
各フォルダ(ゼノドID)内では、ファイルはゼノドIDで始まり、その後に元の画像セット配列へのインデックスが続きます。この配列は完全な[恐竜データセットアーカイブ](https://vsoch.github.io/datasets/2018/zenodo)に含まれています。
```
$ tree m/891531/ -L 1
m/891531/
├── 891531_0.png
├── 891531_10.png
├── 891531_11.png
├── 891531_12.png
├── 891531_13.png
├── 891531_14.png
├── 891531_15.png
├── 891531_16.png
├── 891531_17.png
├── 891531_18.png
├── 891531_19.png
├── 891531_1.png
├── 891531_20.png
├── 891531_21.png
├── 891531_22.png
├── 891531_23.png
├── 891531_24.png
├── 891531_25.png
├── 891531_26.png
├── 891531_27.png
├── 891531_28.png
├── 891531_29.png
├── 891531_2.png
├── 891531_30.png
├── 891531_3.png
├── 891531_4.png
├── 891531_5.png
├── 891531_6.png
├── 891531_7.png
├── 891531_8.png
└── 891531_9.png
0 directories, 31 files
```
> では、何が違うのですか?
違いは、これらのファイルが拡張子タイプごとに整理され、実際のpng画像として提供されていることです。元のデータはnumpyデータフレームとして提供され、ゼノドIDごとに整理されています。どちらもそれぞれの用途に役立ちますが、この特定のバージョンは、実際にコード画像がどのように見えるかを確認できるので素敵です。
> 合計でいくつの画像がありますか?
合計画像数を数えることができます。
```
find "." -type f -name *.png | wc -l
3,026,993
```
# データセットの作成
データセットを作成するスクリプトは[ここに提供されています](https://github.com/vsoch/zenodo-ml/blob/master/preprocess/2.organize_by_language.py)。基本的には、[この研究](https://vsoch.github.io/2018/extension-counts/)で特定された上位の拡張子(実際の画像ファイルを除く)から始めて、各80x80の画像を実際のpng画像として書き出し、拡張子ごとに、そしてゼノドIDごとに整理します(上記のように)。
# 画像の保存
単一チャンネルの80x80のデータフレームをpng画像として書き出すいくつかの方法をテストした結果、cv2のimwrite関数が好きになりました。この関数は、保存した内容をそのまま読み込むことができるからです。
```python
import cv2
cv2.imwrite(image_path, image)
```
# 画像の読み込み
上記の内容を踏まえると、画像を読み込むのはかなり簡単です!ここにscipyを使った例と、新しいPython(非推奨のメッセージが表示される場合)でimageioを使った例を示します。
```python
image_path = '/tmp/data1/data/csv/1009185/1009185_0.png'
from imageio import imread
image = imread(image_path)
array([[116, 105, 109, ..., 32, 32, 32],
[ 48, 44, 48, ..., 32, 32, 32],
[ 48, 46, 49, ..., 32, 32, 32],
...,
[ 32, 32, 32, ..., 32, 32, 32],
[ 32, 32, 32, ..., 32, 32, 32],
[ 32, 32, 32, ..., 32, 32, 32]], dtype=uint8)
image.shape
(80,80)
```
```python
# 非推奨
from scipy import misc
misc.imread(image_path)
Image([[116, 105, 109, ..., 32, 32, 32],
[ 48, 44, 48, ..., 32, 32, 32],
[ 48, 46, 49, ..., 32, 32, 32],
...,
[ 32, 32, 32, ..., 32, 32, 32],
[ 32, 32, 32, ..., 32, 32, 32],
[ 32, 32, 32, ..., 32, 32, 32]], dtype=uint8)
```
データ内の値は文字が序数に変換されたものであることを覚えておいてください。32は何だと思いますか?
```python
ord(' ')
32
# そして、もし戻す必要があれば...
chr(32)
```
では、ファイルから一行を再構築するにはどうすればいいでしょう?試してみましょう!ここにファイルのヘッダーと、最初の行が続きます。フォルダ名がcsvであることから、これがcsvファイルであることがわかります。
```python
''.join([chr(x) for x in image[0]])
# 'time,S1,S2 '
''.join([chr(x) for x in image[1]])
# '0,0.00015,0
```
## インスピレーション
これらのデータセットは、[ここで議論されている](https://vsoch.github.io/datasets/2018/zenodo/#what-can-i-learn-from-this-dataset)いくつかの同じ質問に答えることができます。基本的には、画像のパターンに基づいて言語を分類できる場合、スクリプト(ソフトウェアパッケージ)のグループ化に対するシグネチャを生成することができます。その後、コンテナ内でこれらのシグネチャを検出し、シグネチャを研究分野や、コードの品質または使用指標と関連付けることができます。
×
The dataset is currently being organized and other channels have been prepared for you. Please use them
The dataset is currently being organized and other channels have been prepared for you. Please use them
Note: Some data is currently being processed and cannot be directly downloaded. We kindly ask for your understanding and support.
No content available at the moment
No content available at the moment
- Share your thoughts
Go share your ideas~~
ALL
Welcome to exchange and share
Your sharing can help others better utilize data.
Data usage instructions: h1>
I. Data Source and Display Explanation:
- 1. The data originates from internet data collection or provided by service providers, and this platform offers users the ability to view and browse datasets.
- 2. This platform serves only as a basic information display for datasets, including but not limited to image, text, video, and audio file types.
- 3. Basic dataset information comes from the original data source or the information provided by the data provider. If there are discrepancies in the dataset description, please refer to the original data source or service provider's address.
II. Ownership Explanation:
- 1. All datasets on this site are copyrighted by their original publishers or data providers.
III. Data Reposting Explanation:
- 1. If you need to repost data from this site, please retain the original data source URL and related copyright notices.
IV. Infringement and Handling Explanation:
- 1. If any data on this site involves infringement, please contact us promptly, and we will arrange for the data to be taken offline.
- 1. The data originates from internet data collection or provided by service providers, and this platform offers users the ability to view and browse datasets.
- 2. This platform serves only as a basic information display for datasets, including but not limited to image, text, video, and audio file types.
- 3. Basic dataset information comes from the original data source or the information provided by the data provider. If there are discrepancies in the dataset description, please refer to the original data source or service provider's address.
- 1. All datasets on this site are copyrighted by their original publishers or data providers.
- 1. If you need to repost data from this site, please retain the original data source URL and related copyright notices.
- 1. If any data on this site involves infringement, please contact us promptly, and we will arrange for the data to be taken offline.