机器学习的分类:有监督学习,无监督学习
有监督学习:有因变量,有特征向量,预测结果和未来,即有x和y
无监督学习:有x但是没有y,自行探索数据结构
1.1回归
下面展示一些 内联代码片
。
// A code block
var foo = 'bar';
// An highlighted block
from sklearn import datasets
boston=datasets.load_boston()
x=boston.data
y=boston.target
features=boston.feature_names
boston_data=pd.DataFrame(x,columns=features)
boston_data['price']=y
boston_data.head()
plt.scatter(boston_data['NOX'],boston_data['price'])
plt.xlabel('NOX')
plt.ylabel('price')
plt.title('price~NOX')
1.2分类
下面展示一些 内联代码片
。
// A code block
var foo = 'bar';
// An highlighted block
iris = datasets.load_iris()
x=iris.data
y=iris.target
features=iris.feature_names
iris_data=pd.DataFrame(x,columns=features)
iris_data['target']=y
iris_data.head()
marker=['s','x','o']
for index,c in enumerate(np.unique(y)):
plt.scatter(x=iris_data.loc[y==c,'sepal length (cm)'],y=iris_data.loc[y==c,'sepal width (cm)'],
label=index, marker=marker[index])
plt.xlabel('sepal length (cm)')
plt.ylabel('sepal width (cm)')
plt.legend()
1.3无监督学习
下面展示一些 内联代码片
。
// A code block
var foo = 'bar';
// An highlighted block
from sklearn import datasets
x, y = datasets.make_moons(n_samples=2000, shuffle=True,
noise=0.05, random_state=None)
for index,c in enumerate(np.unique(y)):
plt.scatter(x[y==c,0],x[y==c,1],s=7)
plt.show()