2014년 12월 30일 화요일

scikit-learn 설치

현재 설치 프로그램
- Python 2.7.8
- Numpy 1.9.1
- Scipy 0.12.0


설치 프로그램

위의 링크를 클릭하여 프로그램을 받는다.


1. 환경변수 설정


고급 시스템 설정 클릭




환경변수 클릭


Path의 편집을 눌려서 파이썬을 설치한 폴더를 추가해준다.

C:\Python27





* 환경변수를 설정하고 재프팅을 해주어야 적용된다.


2. ez_setup 설치

 윈도우키 + R



cmd창에서 위에서 압축을 푼 폴더로 이동하고
python ez_setup.py build 입력한다.



python ez_setup.py install 입력한다.



3. path 추가

아까 환경변수를 추가한 것처럼 아래 변수를 추가한다.
C:\Python27\Scripts


* 환경변수를 설정하고 재프팅을 해주어야 적용된다.


4. pip 설치

cmd창에 easy_install pip 입력한다.


5. scikit-learn 설치

cmd창에 pip install -U scikit-learn 을 입력한다.


6. 예제 파일
scikit-learn 실행 예제

print(__doc__)

from sklearn.svm import SVC
from sklearn.datasets import load_digits
from sklearn.feature_selection import RFE
import matplotlib.pyplot as plt

# Load the digits dataset
digits = load_digits()
X = digits.images.reshape((len(digits.images), -1))
y = digits.target

# Create the RFE object and rank each pixel
svc = SVC(kernel="linear", C=1)
rfe = RFE(estimator=svc, n_features_to_select=1, step=1)
rfe.fit(X, y)
ranking = rfe.ranking_.reshape(digits.images[0].shape)

# Plot pixel ranking
plt.matshow(ranking)
plt.colorbar()
plt.title("Ranking of pixels with RFE")
plt.show()

결과 화면



댓글 1개:

  1. 4번까지는 완료했는데 5번에서 오류나는데 어쩌죠 ㅜㅜ
    UnicodeDecodeError 가 나네요..

    답글삭제