()
| 33 | |
| 34 | @app.route('/api-getDataSet', methods = ['POST', 'GET']) |
| 35 | def getDataSet(): |
| 36 | |
| 37 | if request.method == 'POST': |
| 38 | |
| 39 | data = json.loads(str(request.data, 'utf-8')) |
| 40 | |
| 41 | path = ["MachineLearningAlgorithm/Bayes/spam_ham_dataset.csv", |
| 42 | "MachineLearningAlgorithm/KNN/tree.csv", |
| 43 | "MachineLearningAlgorithm/SupportVectorMachine/cancer.csv", |
| 44 | "MachineLearningAlgorithm/LinearRegression/housing.csv", |
| 45 | "MachineLearningAlgorithm/LogisticRegression/iris.csv", |
| 46 | "MachineLearningAlgorithm/ClassificationAndRegressionTree/forestfire1.csv" |
| 47 | ] |
| 48 | |
| 49 | with open(path[data], 'r') as f: |
| 50 | |
| 51 | text = StringIO(f.read()) |
| 52 | |
| 53 | df = read_csv(text, sep=',') |
| 54 | |
| 55 | if ("Unnamed: 0" in df.columns): df = dropColumns(df, columns=["Unnamed: 0"]) |
| 56 | |
| 57 | res = DataFrame2Array(df) |
| 58 | |
| 59 | return str(res) |
| 60 | |
| 61 | return '<h1>请使用POST方法访问</h1>' |
| 62 | |
| 63 | @app.route('/api-DataFrame', methods = ['POST', 'GET']) |
| 64 | def dataFrame() : |
nothing calls this directly
no test coverage detected