def home(): params = get_algo(request.args) if params is None: params = "linearRegression" data_params = get_params(request.args) if params == "linearRegression": return redirect( url_for('.linear', start=data_params[0], end=data_params[1], rows=data_params[2], cols=data_params[3], clust=data_params[4])) elif params == "logisticRegression": return redirect( url_for('.logistic', start=data_params[0], end=data_params[1], rows=data_params[2], cols=data_params[3], clust=data_params[4])) elif params == "ridge": return redirect( url_for('.ridge', start=data_params[0], end=data_params[1], rows=data_params[2], cols=data_params[3], clust=data_params[4], alpha=data_params[10])) else: return "select algo"
def linear(): params = get_params(request.args) X_train, X_test, y_train, y_test = regressionData(params[2], params[3]) start, end = params[0], params[1] model = linear_model.LinearRegression() model.fit(X_train, y_train) y_pred = model.predict(X_test) res = result(X_test, y_test, y_pred) res = res[start:end] return res.to_json(orient='index')
def ridge(): params = get_params(request.args) start, end = params[0], params[1] X_train, X_test, y_train, y_test = regressionData(params[2], params[3]) ridgereg = linear_model.Ridge(alpha=params[10], normalize=True) ridgereg.fit(X_train, y_train) y_pred = ridgereg.predict(X_test) res = result(X_test, y_test, y_pred) res = res[start:end] print("ridge") print(params) return res.to_json(orient='index')
def svm(): params = get_params(request.args) X_train, X_test, y_train, y_test = createData(params[2],params[3],params[4]) start, end = params[0], params[1] clf = SVC(kernel=params[6]) clf.fit(X_train, np.ravel(y_train)) y_pred = clf.predict(X_test) res = result(X_test, y_test, y_pred) res = res[start:end] print("svm") print(params) return res.to_json(orient='index')
def naive(): params = get_params(request.args) X_train, X_test, y_train, y_test = createData(params[2],params[3],params[4]) start, end = params[0], params[1] model = GaussianNB() model.fit(X_train,np.ravel(y_train)) y_pred = model.predict(X_test) res = result(X_test, y_test, y_pred) res = res[start:end] print("naive") print(params) return res.to_json(orient='index')
def logistic(): params = get_params(request.args) X_train, X_test, y_train, y_test = createData(params[2],params[3],params[4]) start, end = params[0], params[1] model = linear_model.LogisticRegression(random_state=0) model.fit(X_train, np.ravel(y_train)) y_pred = model.predict(X_test) res = result(X_test, y_test, y_pred) res = res[start:end] print("log") print(params) return res.to_json(orient='index')
def rtree(): params = get_params(request.args) X_train, X_test, y_train, y_test = createData(params[2],params[3],params[4]) start, end = params[0], params[1] clf=RandomForestClassifier(n_estimators=params[8]) clf.fit(X_train,np.ravel(y_train)) y_pred=clf.predict(X_test) res = result(X_test, y_test, y_pred) res = res[start:end] print("rtree") print(params) return res.to_json(orient='index')
def dtree(): params = get_params(request.args) X_train, X_test, y_train, y_test = createData(params[2],params[3],params[4]) start, end = params[0], params[1] clf = DecisionTreeClassifier(max_depth= params[7]) clf = clf.fit(X_train,np.ravel(y_train)) y_pred = clf.predict(X_test) res = result(X_test, y_test, y_pred) res = res[start:end] print("dtree") print(params) return res.to_json(orient='index')
def knear(): params = get_params(request.args) X_train, X_test, y_train, y_test = createData(params[2],params[3],params[4]) start, end = params[0], params[1] classifier = KNeighborsClassifier(n_neighbors=params[5]) classifier.fit(X_train, np.ravel(y_train)) y_pred = classifier.predict(X_test) res = result(X_test, y_test, y_pred) res = res[start:end] print("knear") print(params) return res.to_json(orient='index')
def home(): params = get_algo(request.args) if params is None or "": params = "logisticRegression" data_params = get_params(request.args) if params == "logisticRegression": return redirect(url_for('.logistic',start=data_params[0],end=data_params[1], rows=data_params[2], cols=data_params[3], clust=data_params[4])) elif params == "knear": return redirect(url_for('.knear',start=data_params[0],end=data_params[1], rows=data_params[2], cols=data_params[3], clust=data_params[4], knear=data_params[5])) elif params == "svm": return redirect(url_for('.svm',start=data_params[0],end=data_params[1], rows=data_params[2], cols=data_params[3], clust=data_params[4], kernel=data_params[6])) elif params == "naive": return redirect(url_for('.naive',start=data_params[0],end=data_params[1], rows=data_params[2], cols=data_params[3], clust=data_params[4])) elif params == "dtree": return redirect(url_for('.dtree',start=data_params[0],end=data_params[1], rows=data_params[2], cols=data_params[3], clust=data_params[4], max_depth=data_params[7])) elif params == "rtree": return redirect(url_for('.rtree',start=data_params[0],end=data_params[1], rows=data_params[2], cols=data_params[3], clust=data_params[4], n_estimators=data_params[8]))