Skip to content

Latest commit

 

History

History
243 lines (212 loc) · 6.29 KB

Train.md

File metadata and controls

243 lines (212 loc) · 6.29 KB
import fastai
from fastai import *
from fastai.vision import *
from fastai.tabular import *  # Quick access to tabular functionality
from sklearn.model_selection import train_test_split

Features: 20 MFCCs, 20 first-derivative of MFCCs, 5 Spectrals

usecols_21 = ['MFCC01', 'MFCC02', 'MFCC03', 'MFCC04', 'MFCC05', 'MFCC06', 'MFCC07', 'MFCC08', 'MFCC09', 'MFCC10', 'MFCC11', 'MFCC12', 'MFCC13', 'MFCC14', 'MFCC15', 'MFCC16', 'MFCC17', 'MFCC18', 'MFCC19', 'MFCC20', 'Class']
usecols_41 = ['MFCC01', 'MFCC02', 'MFCC03', 'MFCC04', 'MFCC05', 'MFCC06', 'MFCC07', 'MFCC08', 'MFCC09', 'MFCC10', 'MFCC11', 'MFCC12', 'MFCC13', 'MFCC14', 'MFCC15', 'MFCC16', 'MFCC17', 'MFCC18', 'MFCC19', 'MFCC20', 'MFCC_delta01', 'MFCC_delta02', 'MFCC_delta03', 'MFCC_delta04', 'MFCC_delta05', 'MFCC_delta06', 'MFCC_delta07', 'MFCC_delta08', 'MFCC_delta09', 'MFCC_delta10', 'MFCC_delta11', 'MFCC_delta12', 'MFCC_delta13', 'MFCC_delta14', 'MFCC_delta15', 'MFCC_delta16', 'MFCC_delta17', 'MFCC_delta18', 'MFCC_delta19', 'MFCC_delta20', 'Class']
usecols_41 = ['MFCC01', 'MFCC02', 'MFCC03', 'MFCC04', 'MFCC05', 'MFCC06', 'MFCC07', 'MFCC08', 'MFCC09', 'MFCC10', 'MFCC11', 'MFCC12', 'MFCC13', 'MFCC14', 'MFCC15', 'MFCC16', 'MFCC17', 'MFCC18', 'MFCC19', 'MFCC20', 'MFCC_delta01', 'MFCC_delta02', 'MFCC_delta03', 'MFCC_delta04', 'MFCC_delta05', 'MFCC_delta06', 'MFCC_delta07', 'MFCC_delta08', 'MFCC_delta09', 'MFCC_delta10', 'MFCC_delta11', 'MFCC_delta12', 'MFCC_delta13', 'MFCC_delta14', 'MFCC_delta15', 'MFCC_delta16', 'MFCC_delta17', 'MFCC_delta18', 'MFCC_delta19', 'MFCC_delta20', 'Class']
path = '/root'
df = pd.read_csv('/root/msec_mfcc_nonsilent.csv', usecols = usecols_41)
train_df, valid_df = train_test_split(df)
train_df.tail()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
MFCC01 MFCC02 MFCC03 MFCC04 MFCC05 MFCC06 MFCC07 MFCC08 MFCC09 MFCC10 ... MFCC_delta12 MFCC_delta13 MFCC_delta14 MFCC_delta15 MFCC_delta16 MFCC_delta17 MFCC_delta18 MFCC_delta19 MFCC_delta20 Class
7566 -623.986962 171.999459 71.872040 21.720318 9.263828 -1.223066 -3.965144 -0.210722 -5.282595 -13.754732 ... 0.001008 -0.007516 -0.006467 -0.003224 -0.003534 -0.002909 0.001973 0.004103 -0.000633 2
2501 -309.825480 143.641373 -21.801265 21.942721 20.128781 13.287995 17.403127 14.121780 13.158946 12.971298 ... 0.526601 0.185795 0.222595 0.005254 -0.193304 -0.212205 -0.089623 -0.065902 -0.211232 2
5672 -599.813874 162.164221 93.778812 55.092892 42.331028 26.904240 13.506857 12.611757 10.626413 0.757259 ... 0.075538 0.444945 0.240737 -0.248581 -0.396535 -0.179960 -0.017341 -0.028708 -0.030098 2
4666 -761.547931 116.665295 52.558674 22.422087 16.306704 4.734597 -8.219314 -13.676851 -16.229516 -17.614693 ... 0.499126 0.416849 0.208211 0.114092 0.058175 -0.214615 -0.510880 -0.496397 -0.326911 2
3449 -320.932113 156.872793 -32.379042 49.476503 4.194986 18.936419 5.512803 0.282368 1.504447 3.965386 ... 0.115879 -0.116351 0.091803 -0.056881 0.005115 -0.098158 -0.018486 0.009138 -0.009866 2

5 rows × 41 columns

path = '/root'
dep_var = 'Class'
#cat_names = ['Class']
data = TabularDataBunch.from_df(path, train_df, valid_df, dep_var, 
                                tfms=[FillMissing, Categorify], cat_names=None)
learn = get_tabular_learner(data, layers=[20], metrics=accuracy)
learn.lr_find()
learn.recorder.plot()
LR Finder complete, type {learner_name}.recorder.plot() to see the graph.

png

learn.fit(8, 0.05)
Total time: 00:09
epoch  train_loss  valid_loss  accuracy
1      0.085720    0.090742    0.970018  (00:01)
2      0.076532    0.067959    0.978836  (00:01)
3      0.082301    0.064496    0.978836  (00:01)
4      0.070542    0.057943    0.981305  (00:01)
5      0.075540    0.064264    0.978836  (00:01)
6      0.069713    0.070506    0.976367  (00:01)
7      0.073813    0.072434    0.975309  (00:01)
8      0.086864    0.071680    0.977425  (00:01)