コード例 #1
0
def main():
    allSong, targetList = dataset.main()
    allSong = np.array(allSong)
    targetList = np.array(targetList)

    allSong = listNormalizer(allSong)
    model(allSong, targetList)
コード例 #2
0
def predictionSong(songUri: str):

    # Girilin uri "spotify:track:URI" şeklinde ise URI kısmını ayırmak için kullanılır.
    if songUri.find("spotify") != -1:
        songUri = songUri[14:]

    # yeni şarkının veri setine eklenmesi ve normalize edilmesi
    artistName, songName, songInfo = SpotifyConnection.getSongInfo(songUri)
    allSong, targetList = dataset.main()
    allSong.append(songInfo)
    allSong = np.array(allSong)
    allSong = allSong / allSong.max(axis=0)

    # Modelin hazırlanması
    model = readModelFromJSON()

    #veri setinden şarkının alınması ve tahmini
    mysong = allSong[-1:]
    predict = model.predict(mysong)
    print("*************HIT SONG PREDICTION*************")
    print("Song Name: " +songName)
    print("Artist Name:" +artistName)
    print("Hit Rate: %" + "%.2f" % (predict[0][0] * 100))

    if predict >= 0.7:
        print("SONG IS HIT!")
    else:
        print("SONG IS NOT HIT!")
コード例 #3
0
ファイル: main.py プロジェクト: kohei-tofu/Ion_Switching
def main():

    parser = argparse.ArgumentParser(description='PyTorch Kaggle')
    parser.add_argument('--jobtype', '-M', type=str, default='evaluate', help='what are you going to do on this function')
    parser.add_argument('--setting', '-S', type=str, default='setting1', help='which setting file are you going to use for training.')
    #parser.add_argument('--model', '-M', type=str, default='', help='')
    args = parser.parse_args()

    #cfg = setting.Config()
    cfg = cfgs.get(args.setting)

    if args.jobtype == 'preprocess':
        dataset.main(cfg)

    if args.jobtype == 'train':
        train.main(cfg)

    if args.jobtype == 'evaluate':
        evaluate.main(cfg)
コード例 #4
0
def predictionSong(songUri: str, songNameLabel: Label, artistNameLabel: Label,
                   hitRateLabel: Label, resultLabel: Label,
                   decisionHitLabel: Label, decisionResult: Label,
                   knnHitLabel: Label, knnResult: Label, svmHitLabel: Label,
                   svmResult: Label, bayesHitLabel: Label, bayesResult: Label):
    if songUri.find("spotify") != -1:
        songUri = songUri[14:]

    # yeni şarkının veri setine eklenmesi ve normalize edilmesi
    artistName, songName, songInfo = SpotifyConnection.getSongInfo(songUri)
    allSong, targetList = dataset.main()
    allSong.append(songInfo)
    allSong = np.array(allSong)
    allSong = allSong / allSong.max(axis=0)

    # veri setinden şarkının alınması ve tahmini
    mysong = allSong[-1:]
    print("*************HIT SONG PREDICTION*************")
    print("Song Name: " + songName)
    print("Artist Name:" + artistName)

    songNameLabel['text'] = "ŞARKI İSMİ: " + songName
    artistNameLabel['text'] = "SANATÇI İSMİ: " + artistName

    predict, predictions, result = neuralPrediction(mysong)
    hitRateLabel['text'] = "POPÜLER OLMA İHTİMALİ: % " + "%.2f" % (
        predict[0][0] * 100) + " " + str(predictions[0])
    resultLabel['text'] = "SONUÇ: " + result
    print("Hit Rate: %" + "%.2f" % (predict[0][0] * 100))

    predict, result = decisionTreePrediction(mysong)
    decisionHitLabel['text'] = "POPÜLERLİK : " + str(predict)
    decisionResult['text'] = "SONUÇ: " + result

    predict, result = knnPrediction(mysong)
    knnHitLabel['text'] = "POPÜLERLİK : " + str(predict)
    knnResult['text'] = "SONUÇ: " + result

    predict, result = svmPrediction(mysong)
    svmHitLabel['text'] = "POPÜLERLİK : " + str(predict)
    svmResult['text'] = "SONUÇ: " + result

    predict, result = bayesPrediction(mysong)
    bayesHitLabel['text'] = "POPÜLERLİK : " + str(predict)
    bayesResult['text'] = "SONUÇ: " + result
コード例 #5
0
def predictionSong():
    songUri = "spotify:track:1aaI0imelqLqye35922oMD"
    if songUri.find("spotify") != -1:
        songUri = songUri[14:]

    artistName, songName, songInfo = SpotifyConnection.getSongInfo(songUri)
    allSong, targetList = dataset.main()
    allSong.append(songInfo)
    allSong = np.array(allSong)
    allSong = allSong / allSong.max(axis=0)

    mySong = allSong[-1:]
    model = joblib.load('BNB.pkl', mmap_mode='r')
    y_pred = model.predict(mySong)
    print(y_pred)
    print("Sanatçı:" + artistName)
    print("Şarkı Adı:" + songName)

    if (y_pred == [0]):
        print("THIS SONG IS NOT HIT")
    else:
        print("THIS SONG IS HIT")