機械学習で分類を行うプログラムをアヤメの分類のプログラムを元に作りました。
以下プログラムとエラーです。何かわかりましたらよろしくお願いします。
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.svm import SVC from sklearn.metrics import accuracy_score # アヤメデータの読み込み --- (*1) analysisresults_data = pd.read_csv("analysis_results.csv", encoding="utf-8") # アヤメデータをラベルと入力データに分離する --- (*2) y = analysisresults_data.loc[:,"結果"] x = analysisresults_data.loc[:,["番号1","番号2","番号3","URL","日付"]] # 学習用とテスト用に分離する --- (*3) x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.3, train_size = 0.7, shuffle = True) # 学習する --- (*4) clf = SVC() clf.fit(x_train, y_train) # 評価する --- (*5) y_pred = clf.predict(x_test) print("正解率 = " , accuracy_score(y_test, y_pred))
Traceback (most recent call last):
File "4iris.py", line 7, in <module>
analysisresults_data = pd.read_csv("analysis_results.csv", encoding="utf-8")
File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/pandas/io/parsers.py", line 702, in parser_f
return _read(filepath_or_buffer, kwds)
File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/pandas/io/parsers.py", line 429, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/pandas/io/parsers.py", line 895, in init
self._make_engine(self.engine)
File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/pandas/io/parsers.py", line 1122, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/pandas/io/parsers.py", line 1853, in init
self._reader = parsers.TextReader(src, **kwds)
File "pandas/_libs/parsers.pyx", line 542, in pandas._libs.parsers.TextReader.cinit
File "pandas/_libs/parsers.pyx", line 782, in pandas._libs.parsers.TextReader._get_header
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x94 in position 0: invalid start byte
回答2件
あなたの回答
tips
プレビュー