SCENIC+ is a python package to build gene regulatory networks (GRNs) using combined or separate single-cell gene expression (scRNA-seq) and single-cell chromatin accessibility (scATAC-seq) data.
Other
163
stars
27
forks
source link
ValueError: X has 1 features, but KNeighborsClassifier is expecting 1441 features as input. #330
from flask import Flask, render_template, request
import pickle
from model import *
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from nltk.stem import WordNetLemmatizer
from sklearn import *
app = Flask(__name__)
model = pickle.load(open('dengue.pkl', 'rb'))
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict', methods=['POST', 'GET'])
def predict():
symptoms = str(request.form['text'])
stop_words = set(stopwords.words('english'))
words = word_tokenize(symptoms.lower())
words = [word for word in words if word.isalpha() and word not in stop_words]
preprocessed_symptoms = ' '.join(words)
tfidf_vectorizer = TfidfVectorizer(max_features=1500)
symptom_tfidf = tfidf_vectorizer.fit_transform([preprocessed_symptoms]).toarray
X_train, X_test, y_train, y_test = train_test_split(tfidf_features, labels, test_size=0.2, random_state=42)
knn_classifier = KNeighborsClassifier(n_neighbors=5)
knn_classifier.fit(X_train, y_train)
predictions = knn_classifier.predict(X_test)
symptom_tfidf = tfidf_vectorizer.fit_transform([preprocessed_symptoms])
result = model.predict(symptom_tfidf)
if result[0] == "Dengue":
result = "You are more likely to be suffering from dengue!"
else :
result = "You have less chances that you are suffering from dengue but there are chances that you are suffering from", result[0]
return render_template('index.html', result=result)
if __name__ == '__main__':
app.run(debug=True)
Flask code