1. 程式人生 > >sk-learn常用函式

sk-learn常用函式

sklearn.model_selection.train_test_split(*arrays, test_size=0.25, train_size=None, random_state=None, shuffle=True, stratify=None)

https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html


 

sklearn.model_selection.GridSearchCV(estimator, param_grid, scoring=None, fit_params=None, n_jobs=None, iid=’warn’, refit=True, cv=’warn’, verbose=0, pre_dispatch=‘2*n_jobs’, error_score=’raise-deprecating’, return_train_score=’warn’)[source]

https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html


 

sklearn.linear_model.LinearRegression(fit_intercept=True, normalize=False, copy_X=True, n_jobs=None)

https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html

fit_intercept:是否計算截距

normalize :是否標準化


sklearn.linear_model.Lasso(alpha=1.0, fit_intercept=True, normalize=False, precompute=False, copy_X=True, max_iter=1000, tol=0.0001, warm_start=False, positive=False, random_state=None, selection=’cyclic’)

https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Lasso.html

precompute:是否使用預先計算的Gram矩陣來加速計算

max_iter:最大迭代次數

tol:判斷是否收斂的閾值


sklearn.datasets.make_blobs(n_samples=100, n_features=2, centers=None, cluster_std=1.0, center_box=(-10.0, 10.0), shuffle=True, random_state=None)

https://scikit-learn.org/dev/modules/generated/sklearn.datasets.make_blobs.html

cluster_std:簇的標準差

center_box:每個簇的邊界


sklearn.cluster.KMeans(n_clusters=8, init=’k-means++’, n_init=10, max_iter=300, tol=0.0001, precompute_distances=’auto’, verbose=0, random_state=None, copy_x=True, n_jobs=None, algorithm=’auto’)

https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html

tol:判斷是否收斂的閾值

verbose:詳細模式

fit_predict(X, y=None, sample_weight=None)

sklearn.metrics.pairwise.euclidean_distances(X, Y=None, Y_norm_squared=None, squared=False, X_norm_squared=None)

https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.euclidean_distances.html


sklearn.cluster.AffinityPropagation(damping=0.5, max_iter=200, convergence_iter=15, copy=True, preference=None, affinity=’euclidean’, verbose=False)

https://scikit-learn.org/stable/modules/generated/sklearn.cluster.AffinityPropagation.html

damping:阻尼係數,是相對於輸入值保持當前值的程度。這是為了在更新這些值時避免數值振盪

affinity:使用哪種相似值

verbose:是否輸出詳細資訊