コード例 #1
0
def build_playback_archive():
  filename = _G.PlotPlaybackFilename
  if os.path.exists(filename):
    print(f"Archive {filename} already exists")
    return _G.load_data(filename)
  print(f"Building archive playback for '{filename}'")
  files  = sorted(glob_plots(filename))
  cur_timestamp = 0
  data   = []
  _len   = len(files)
  for i, file in enumerate(files):
    print(f"Processing {i}/{_len}")
    dat = PlotPlaybackRecord(cur_timestamp)
    dat.sx, dat.ex = find_plot_window_length(file)
    data.append(dat)
    cur_timestamp += _G.TimeWindowSize
  _G.dump_data(data, filename)
  print("Archived dumped")
  return data
コード例 #2
0
def start_analyze():
    global data
    print(f"Analyzing stream file index of {_G.StreamFileIndex}")
    data = []

    if _G.FLAG_POSITIVE_PROC:
        print(f"Analyzing Positive Samples")
        _G.ensure_dir_exist(f"{_G.PositiveSamplePath}/.")
        _G.wait(1)
        files = _G.positive_audios()
        for i, file in enumerate(files):
            analyze_and_plot_audio(file, _G.positive_plot_filename(i), True)
            _G.dump_data(data, _G.make_positive_dataname(i))
    elif _G.FLAG_NEGATIVE_PROC:
        print(f"Analyzing Negative Samples")
        _G.ensure_dir_exist(f"{_G.NegativeSamplePath}/.")
        _G.wait(1)
        files = _G.negative_audios()
        for i, file in enumerate(files):
            analyze_and_plot_audio(file, _G.negative_plot_filename(i), True)
            _G.dump_data(data, _G.make_negative_dataname(i))
    else:
        _G.ensure_dir_exist(_G.plot_filename(0))
        files = get_audio_files(_G.StreamFilePrefix, _G.StreamFileSuffix)
        flen = len(files)
        for i, file in enumerate(files):
            print(f"Analyzing {i+1}/{flen}")
            analyze_and_plot_audio(file, _G.plot_filename(i), True)
            # if i >= 2:
            #   break
        _G.dump_data(data, _G.get_stream_adump_filename())
コード例 #3
0
                          verbose=VERBOSE,
                          n_jobs=N_JOBS)

x_train = np.array(x_train, dtype=object)
x_train = x_train.reshape(x_train.shape[0],
                          x_train.shape[1] * x_train.shape[2])
print(f"Reshaped size: {x_train.shape}")

if TRAIN_SVM:
    print("Training SVM")
    clsier_svm.fit(x_train, y_train)
    print("Best params: ", clsier_svm.best_params_)
    print("Result:")
    pprint(clsier_svm.cv_results_)
    print("Dumping SVM data")
    _G.dump_data(clsier_svm, f"svm_zcr.mod")

if TRAIN_KNN:
    print("Training KNN")
    clsier_knn.fit(x_train, y_train)
    print("Best params: ", clsier_knn.best_params_)
    print("Result:")
    pprint(clsier_knn.cv_results_)
    print("Dumping KNN data")
    _G.dump_data(clsier_knn, f"knn_zcr.mod")

if TRAIN_RFR:
    print("Training Random Forest")
    clsier_rfr.fit(x_train, y_train)
    print("Best params: ", clsier_rfr.best_params_)
    print("Result:")
コード例 #4
0
clsier_svm = GridSearchCV(estimator=svm.SVC(), param_grid=parm_svm, scoring='accuracy',cv=GRID_CV,verbose=VERBOSE,n_jobs=N_JOBS)
clsier_knn = GridSearchCV(estimator=KNeighborsClassifier(), param_grid=parm_knn, scoring='accuracy',cv=GRID_CV,verbose=VERBOSE,n_jobs=N_JOBS)
clsier_rfr = GridSearchCV(estimator=RandomForestRegressor(), param_grid=parm_rfr, scoring='explained_variance',cv=GRID_CV,verbose=VERBOSE,n_jobs=N_JOBS)

x_train = np.array(x_train, dtype=object)
x_train = x_train.reshape(x_train.shape[0], x_train.shape[1]*x_train.shape[2])
print(f"x_traine reshped: {x_train.shape}")

if TRAIN_SVM:
  print("Training SVM")
  clsier_svm.fit(x_train, y_train)
  print("Best params: ", clsier_svm.best_params_)
  print("Result:")
  pprint(clsier_svm.cv_results_)
  print("Dumping SVM")
  _G.dump_data(clsier_svm, "svm_mfcc.mod")

if TRAIN_KNN:
  print("Training KNN")
  clsier_knn.fit(x_train, y_train)
  print("Best params: ", clsier_knn.best_params_)
  print("Result:")
  pprint(clsier_knn.cv_results_)
  _G.dump_data(clsier_knn, f"knn_mfcc.mod")

if TRAIN_RFR:
  print("Training Random Forest")
  clsier_rfr.fit(x_train, y_train)
  print("Best params: ", clsier_rfr.best_params_)
  print("Result:")
  pprint(clsier_rfr.cv_results_)
コード例 #5
0
                          verbose=VERBOSE,
                          n_jobs=N_JOBS)

x_train = np.array(x_train, dtype=object)
x_train = x_train.reshape(x_train.shape[0],
                          x_train.shape[1] * x_train.shape[2])
print(f"Reshaped size: {x_train.shape}")

if TRAIN_SVM:
    print("Training SVM")
    clsier_svm.fit(x_train, y_train)
    print("Best params: ", clsier_svm.best_params_)
    print("Result:")
    pprint(clsier_svm.cv_results_)
    print("Dumping SVM data")
    _G.dump_data(clsier_svm, f"svm_rolloff.mod")

if TRAIN_KNN:
    print("Training KNN")
    clsier_knn.fit(x_train, y_train)
    print("Best params: ", clsier_knn.best_params_)
    print("Result:")
    pprint(clsier_knn.cv_results_)
    print("Dumping KNN data")
    _G.dump_data(clsier_knn, f"knn_rolloff.mod")

if TRAIN_RFR:
    print("Training Random Forest")
    clsier_rfr.fit(x_train, y_train)
    print("Best params: ", clsier_rfr.best_params_)
    print("Result:")