Source From Here
Question Before you can build machine learning models, you need to load your data into memory. In this post you will discover how to load data for machine learning in Python using scikit-learn.
Packaged Datasets
The scikit-learn library is packaged with datasets. These datasets are useful for getting a handle on a given machine learning algorithm or library feature before using it in your own work. Below recipe demonstrates how to load the famous Iris flowers dataset:
Load from CSV
It is very common for you to have a dataset as a CSV file on your local workstation or on a remote server. This recipe show you how to load a CSV file from a URL, in this case the Pima Indians diabetes classification dataset from the UCI Machine Learning Repository.
From the prepared X and y variables, you can train a machine learning model:
Summary
In this post you discovered that the scikit-learn method comes with packaged data sets including the iris flowers dataset. These datasets can be loaded easily and used for explore and experiment with different machine learning models. You also saw how you can load CSV data with scikit-learn. You learned a way of opening CSV files from the web using the urllib library and how you can read that data as a NumPy matrix for use in scikit-learn.
Supplement
* Machine Learning: Python 機器學習:使用Python
* [ Scikit- learn ] Training a machine learning model with scikit-learn
沒有留言:
張貼留言