sklearn常用模块
sklearn常用模块
官方地址
官方地址:https://scikit-learn.org/stable/
0.24的API文档:https://scikit-learn.org/stable/auto_examples/release_highlights/plot_release_highlights_0_24_0.html
处理
数据集
官方数据集分类位置:https://scikit-learn.org/stable/auto_examples/#dataset-examples
sklearn.datasets
#如:
from sklearn.datasets import load_iris
模型评估
sklearn.metrics
#如:
from sklearn.metrics import accuracy_score
模型选型
sklearn.model_selection主要做超参优化,模型验证,和数据集分割的,虽然名字叫model_selection模块(但是感觉名字不是很好)
官方API文档:https://scikit-learn.org/0.18/modules/classes.html#module-sklearn.model_selection
sklearn.model_selection
#如:
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score #交叉检验
预处理
sklearn.preprocessing
#如:
from sklearn.preprocessing import LabelEncoder, LabelBinarizer
特征选择
sklearn.feature_selection
#如:
from sklearn.feature_selection import chi2
算法
聚类
sklearn.cluster
#如:k-means聚类
from sklearn.cluster import Kmeans
朴素贝叶斯
sklearn.naive_bayes
#如:高斯朴素贝叶斯
from sklearn.naive_bayes import GaussianNB
邻近算法
sklearn.neighbors
#如:knn
from sklearn.neighbors import KNeighborsClassifier
决策树
sklearn.tree
#如:
from sklearn.tree import DecisionTreeClassifier
支持向量机
sklearn.svm
#如:
from sklearn.svm import SVC
降维
sklearn.decomposition
#如:
from sklearn.decomposition import PCA