更新时间:2024-07-12 GMT+08:00
sklearn
在FunctionGraph页面将sklearn添加为公共依赖
图1 sklearn添加为公共依赖
![点击放大](https://support.huaweicloud.com/usermanual-functiongraph/zh-cn_image_0000001887943349.png)
在代码中导入sklearn并使用
# 导入 sklearn 相关内容 from sklearn import datasets from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier def handler (event, context): iris=datasets.load_iris() iris_X=iris.data iris_y=iris.target X_train,X_test,y_train,y_test=train_test_split(iris_X,iris_y,test_size=0.3) knn=KNeighborsClassifier() knn.fit(X_train,y_train) print(knn.predict(X_test)) return y_test
父主题: 公共依赖Demo