英文:
knn.fit(X_train, y_train) not showing parameters
问题
以下是翻译好的部分:
The output it shows, is below.
输出如下。
I expected the output to be:
我预期的输出应该是:
`KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',
metric_params=None, n_jobs=1, n_neighbors=1, p=2,
weights='uniform')`
As I am working through the book introduction to machine learning with Python by O'Reilly.
因为我正在阅读 O'Reilly 出版的《Python 机器学习入门》这本书。
英文:
The output it shows, is below.
I expected the output to be:
`KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',
metric_params=None, n_jobs=1, n_neighbors=1, p=2,
weights='uniform')`
As I am working through the book introduction to machine learning with Python by O'Reilly.
答案1
得分: 0
只需在已拟合的对象上使用 get_params
方法。
from sklearn.neighbors import KNeighborsClassifier
X = [[0], [1], [2], [3]]
y = [0, 0, 1, 1]
neigh = KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski', metric_params=None, n_jobs=1, n_neighbors=1, p=2, weights='uniform')
neigh.fit(X, y)
neigh.get_params()
{'algorithm': 'auto',
'leaf_size': 30,
'metric': 'minkowski',
'metric_params': None,
'n_jobs': 1,
'n_neighbors': 1,
'p': 2,
'weights': 'uniform'}
英文:
Just use the get_params
method on the fitted object.
from sklearn.neighbors import KNeighborsClassifier
X = [[0], [1], [2], [3]]
y = [0, 0, 1, 1]
neigh = KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski', metric_params=None, n_jobs=1, n_neighbors=1, p=2, weights='uniform')
neigh.fit(X, y)
neigh.get_params()
{'algorithm': 'auto',
'leaf_size': 30,
'metric': 'minkowski',
'metric_params': None,
'n_jobs': 1,
'n_neighbors': 1,
'p': 2,
'weights': 'uniform'}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论