template
This commit is contained in:
parent
1305796eba
commit
07d97c5267
5
.gitignore
vendored
5
.gitignore
vendored
@ -0,0 +1,5 @@
|
||||
venv*
|
||||
.venv*
|
||||
.vscode*
|
||||
__pycache__*
|
||||
music_genre.csv
|
23
datapreparator.py
Normal file
23
datapreparator.py
Normal file
@ -0,0 +1,23 @@
|
||||
from copy import deepcopy
|
||||
import pandas as pd
|
||||
|
||||
class DataPreparator:
|
||||
genre_dict = {
|
||||
"blues" : 1,
|
||||
"classical" : 2,
|
||||
"country" : 3,
|
||||
"disco" : 4,
|
||||
"hiphop" : 5,
|
||||
"jazz" : 6,
|
||||
"metal" : 7,
|
||||
"pop" : 8,
|
||||
"reggae" : 9,
|
||||
"rock" : 10
|
||||
}
|
||||
|
||||
def prepare_data(df: pd.DataFrame) -> pd.DataFrame:
|
||||
data = deepcopy(df)
|
||||
column = df["label"].apply(lambda x: DataPreparator.genre_dict[x])
|
||||
data.insert(0, 'genre', column, 'float')
|
||||
data = data.drop(columns=['filename', 'label', 'length'])
|
||||
return data
|
12
main.py
Normal file
12
main.py
Normal file
@ -0,0 +1,12 @@
|
||||
from bayes import Bayes
|
||||
from datapreparator import DataPreparator
|
||||
import pandas as pd
|
||||
import os
|
||||
|
||||
filename = 'music_genre.csv'
|
||||
if os.path.isfile(filename):
|
||||
data = pd.read_csv(filename)
|
||||
else:
|
||||
data_raw = pd.read_csv('music_genre_raw.csv')
|
||||
data = DataPreparator.prepare_data(data_raw)
|
||||
data.to_csv(filename, index=False)
|
1001
music_genre_raw.csv
Normal file
1001
music_genre_raw.csv
Normal file
File diff suppressed because it is too large
Load Diff
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
pandas==1.2.4
|
Loading…
Reference in New Issue
Block a user