コード例 #1
0
def predict_artist(lyrics):
    # TODO transform (stem) the lyrics
    lyrics = transformLyrics(lyrics)
    # TODO predict the artist for the lyrics. Note that predict will
    # interpret the argument as a list.
    prediction = pipeline.predict([lyrics])
    # TODO return a string naming the predicted artist.
    return 'Predicted Artist: %s' % prediction
コード例 #2
0
def predict_artist(lyrics):
    lyrics = transformLyrics(lyrics)
    print 'predicting artist for %s' % lyrics
    prediction = pipeline.predict([lyrics])
    # TODO instead of returning a string, render the prediction.html template.
    # TODO
    d = {'lyrics': lyrics, 'artist': prediction[0]}
    return render_template('prediction.html', d=d)
コード例 #3
0
def predict_artist():
    # TODO get the lyrics from the body of the POST request

    lyrics = transformLyrics(lyrics)
    print 'predicting artist for %s' % lyrics
    prediction = pipeline.predict([lyrics])
    d = {'lyrics': lyrics, 'artist': prediction[0]}
    return render_template('prediction.html', d=d)
コード例 #4
0
def predict_artist(lyrics):
    # TODO transform (stem) the lyrics
    lyrics = transformLyrics(lyrics)
    # TODO predict the artist for the lyrics. Note that predict will
    # interpret the argument as a list.
    prediction = pipeline.predict([lyrics])
    # TODO return a string naming the predicted artist.
    return 'Predicted Artist: %s' % prediction
コード例 #5
0
def predict_artist(lyrics):
    lyrics = transformLyrics(lyrics)
    print "predicting artist for %s" % lyrics
    prediction = pipeline.predict([lyrics])
    # TODO instead of returning a string, render the prediction.html template.
    # TODO
    d = {"lyrics": lyrics, "artist": prediction[0]}
    return render_template("prediction.html", d=d)
コード例 #6
0
ファイル: lyrics_classifier.py プロジェクト: vtan707/DAT18NYC
 def predictArtist(self, lyrics):
     """Returns an artist name given sample song lyrics.
     Applies the Million Song Dataset stemming routine to
     the lyrics (pre-processing), vectorizes the lyrics,
     and runs them through the MultinomialNB classifier.
     Returns the artist name associated with the predicted
     label.
     """
     transformed_lyrics = transformLyrics(lyrics)
     return ""
コード例 #7
0
 def predictArtist(self,lyrics):
     """Returns an artist name given sample song lyrics.
     Applies the Million Song Dataset stemming routine to
     the lyrics (pre-processing), vectorizes the lyrics,
     and runs them through the MultinomialNB classifier.
     Returns the artist name associated with the predicted
     label.
     """
     transformed_lyrics = transformLyrics(lyrics)
     return ""
コード例 #8
0
def predict_artist():
    # TODO get the lyrics from the body of the POST request
    lyrics = request.form['lyrics']
    lyrics = transformLyrics(lyrics)
    print 'predicting artist for %s' % lyrics
    prediction = pipeline.predict([lyrics])
    d = {
        'lyrics': lyrics,
        'artist': prediction[0]
    }
    return render_template('prediction.html', d=d)
コード例 #9
0
def predict_artist(lyrics):
    lyrics = transformLyrics(lyrics)
    print 'predicting artist for %s' % lyrics
    prediction = pipeline.predict([lyrics])
    # TODO instead of returning a string, render the prediction.html template.
    # TODO create a dictionary containing the keys 'lyrics' and 'artists' that
    # TODO will be used to complete the template.
    d = {
        'lyrics': lyrics,
        'artist': prediction[0]
    }
    return render_template('prediction.html', d=d)
コード例 #10
0
 def predictArtist(self,lyrics):
     """Returns an artist name given sample song lyrics.
     Applies the Million Song Dataset stemming routine to
     the lyrics (pre-processing), vectorizes the lyrics,
     and runs them through the MultinomialNB classifier.
     Returns the artist name associated with the predicted
     label.
     """
     transformed_lyrics = transformLyrics(lyrics)
     df = pd.DataFrame({'Lyrics':[transformed_lyrics]})
     X = self.vectorizer.transform(df['Lyrics'])
     y = self.clf.predict(X)
     for artist, label in self.artistLabels.items():
         if label == y:
             return artist
     return "Artist Not Found (predicted label %d)"%(y)
コード例 #11
0
 def predictArtist(self, lyrics):
     """Returns an artist name given sample song lyrics.
     Applies the Million Song Dataset stemming routine to
     the lyrics (pre-processing), vectorizes the lyrics,
     and runs them through the MultinomialNB classifier.
     Returns the artist name associated with the predicted
     label.
     """
     transformed_lyrics = transformLyrics(lyrics)
     df = pd.DataFrame({'Lyrics': [transformed_lyrics]})
     X = self.vectorizer.transform(df['Lyrics'])
     y = self.clf.predict(X)
     for artist, label in self.artistLabels.items():
         if label == y:
             return artist
     return "Artist not found (prdeict label %d" % y
コード例 #12
0
def predict_artist(lyrics):
    lyrics = transformLyrics(lyrics)
    print 'predicting artist for %s' % lyrics
    prediction = pipeline.predict([lyrics])
    return 'Predicted Artist: %s' % prediction
コード例 #13
0
def predict_artist(lyrics):
    lyrics = transformLyrics(lyrics)
    print 'predicting artist for %s' % lyrics
    prediction = pipeline.predict([lyrics])
    return 'Predicted Artist: %s' % prediction