目录
| 方法 | 说明 |
|---|---|
fit(X, y) | 根据数据矩阵X和标签y拟合模型 |
get_params([deep]) | 获取这个估计器的参数。 |
predict(X) | 使用多层感知器模型进行预测。 |
score(X, y[, sample_weight]) | 返回预测的可决系数。 |
set_params(**params) | 设置这个估计器的参数。 |
假设训练好的模型名称为clf
根据数据矩阵X和标签y拟合模型。
| 参数 | 说明 |
|---|---|
| X | ndarray or sparse matrix of shape (n_samples, n_features) 输入数据。 |
| y | ndarray of shape (n_samples,) or (n_samples, n_outputs) 目标值(分类中的类别标签,回归中的实数)。 |
| 返回值 | 说明 |
|---|---|
| self | returns a trained MLP model. |
clf.fit(X,y)
获取模型的参数
| 参数 | 说明 |
|---|---|
| deep | bool, default=True 如果为True,则将返回这个估计器的参数和所包含的估计器子对象。 |
| 返回值 | 说明 |
|---|---|
| params | mapping of string to any 参数名映射到其值 |
clf.get_params(deep=True)
使用模型进行预测
| 参数 | 说明 |
|---|---|
| X | {array-like, sparse matrix} of shape (n_samples, n_features) 输入数据。 |
| 返回值 | 说明 |
|---|---|
| y | ndarray of shape (n_samples, n_outputs) 预测值。 |
clf.predict(x)
返回预测的可决定系数R2
| 参数 | 说明 |
|---|---|
| X | array-like of shape (n_samples, n_features) 测试样本。对于某些估计量,这可以是预先计算的面板矩阵或通用对象列表,而不是shape =(n_samples,n_samples_fitted),其中n_samples_fitted是用于估计器拟合的样本数。 |
| y | array-like of shape (n_samples,) or (n_samples, n_outputs) X的真实值。 |
| sample_weight | array-like of shape (n_samples,), default=None 样本权重。 |
| 返回值 | 说明 |
|---|---|
| score | float self.predict(X)关于y的R2 |
为模型设置参数
该方法适用于简单的估计器以及嵌套对象(例如pipelines)。后者具有形式的参数, 以便可以更新嵌套对象的每个组件。
| 参数 | 说明 |
|---|---|
| **params | dict 估计器参数 |
| 返回值 | 说明 |
|---|---|
| self | object 估计器实例 |