def home(): if request.method == 'POST': file = request.files['file'].read() result = predictor.predict(file) return result[0] else: return render_template('index.html')
def serialized_prediction(df): response = pd.DataFrame(np.vstack( [predictor.predict(df), predictor.predict_proba(df).max(axis=1)]).T, columns=["Survived", "Probability"], index=df['passengerid']) return response.to_json(orient='index')
def index(): if request.method=='POST': lyrics = request.form['song_text'] lyrics = str(lyrics) result_string, results_probability = pred.predict(lyrics) return render_template('show_results.html', result_string=result_string, result_probability=results_probability) else: return render_template('index.html')
def start(): if request.method == 'POST': f = request.files['file'] df = pd.read_csv(f) y = predict(df) df = pd.concat([df, y], axis=1) now = datetime.datetime.now() filepath = 'files/{}.csv'.format(now.strftime("%Y-%m-%d %H:%M:%S")) df.to_csv(filepath) return render_template('finished.html', url='/{}'.format(filepath)) return render_template('start.html')
import pandas import os import settings from clusterGenerator.clusterController import generateCluster print(os.getcwd()) from predictor.predictor import predict Main_Path = os.path.join(settings.default_path, 'data') os.chdir(Main_Path) resulting_input_cluster = [] print("Loading test data") input_data = pandas.read_csv('yelp_labelled.csv', delimiter="\t") trunc_input_data = input_data.iloc[0:20, 0:2] trunc_input_labels = trunc_input_data.iloc[:, 1].values.tolist() trunc_input_reviews = input_data.iloc[0:20, 0:2].values.tolist() print("Loaded") trunc_input_data_length = trunc_input_data.shape[0] for sentence in trunc_input_data.itertuples(): # for i, sentence in enumerate(trunc_input_reviews): # print(sentence) resulting_input_cluster.append(generateCluster(sentence._1, sentence.Index)) # resulting_input_cluster.append(generateCluster(sentence, i)) # print(resulting_input_cluster) predict(resulting_input_cluster , trunc_input_labels)
def testing(predictor, data, labels): predictions = predictor.predict(data) print "Test accuracy: %.1f%%" % accuracy(predictions, labels)