目前看来knn与gbrt效果挺好
花絮:python各种知识点
1.自定义函数,结尾请用return返回结果方便调用
2.np.arange:产生等差数列
3.f - string:Python 字符串的格式化,从 %格式到 format再到 f-string,格式化的方式是越来越直观,同时 f-string 的效率似乎也比前两个高。
参考文档 :https://www.cnblogs.com/traditional/p/9445930.html
#回归
import numpy as np
import matplotlib.pyplot as plt
from sklearn import tree
from sklearn.linear_model import LinearRegression
from sklearn import svm
from sklearn import neighbors
from sklearn import ensemble
from sklearn.tree import ExtraTreeRegressor
def gen_data(x1,x2):
y=np.sin(x1)*0.5 +np.cos(x2)*0.5 + 0.1*x1 +np.random.random(1)
return y #知识点1
x1_train = np.linspace(0,50,100)
x2_train = np.linspace(-10,10