Updated on 2023-11-16 GMT+08:00
sklearn
Adding sklearn on Function Details Page
Figure 1 Adding sklearn
![](https://support.huaweicloud.com/eu/usermanual-functiongraph/en-us_image_0000001757078489.png)
Importing sklearn to Code
# Import 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
Parent topic: Public Dependency Demos
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.