import pandas as pd
import numpy as np
wine = pd.read_csv("winequality-red.csv", sep=";")
wine.head
from sklearn import linear_model
clf = linear_model.LinearRegression()
X = wine.log[:, ['density']].as_matrix()
Y = wine['alcohol'].as_matrix()
clf.fit(X, Y)
print(clf.coef_)
print(clf.intercept_)
print(clf.score(X, Y))
[vagrant@localhost python]$ python myapp.py
Traceback (most recent call last):
File “myapp.py”, line 1, in
import pandas as pd
File “/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pandas/__init__.py”, line 55, in
from pandas.core.api import (
File “/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pandas/core/api.py”, line 5, in
from pandas.core.arrays.integer import (
File “/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pandas/core/arrays/__init__.py”, line 1, in
from .array_ import array # noqa: F401
File “/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pandas/core/arrays/array_.py”, line 7, in
from pandas.core.dtypes.common import (
File “/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pandas/core/dtypes/common.py”, line 11, in
from pandas.core.dtypes.dtypes import (
File “/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pandas/core/dtypes/dtypes.py”, line 53, in
class Registry:
File “/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pandas/core/dtypes/dtypes.py”, line 84, in Registry
self, dtype: Union[Type[ExtensionDtype], str]
File “/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/typing.py”, line 552, in __getitem__
dict(self.__dict__), parameters, _root=True)
File “/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/typing.py”, line 512, in __new__
for t2 in all_params – {t1} if not isinstance(t2, TypeVar)):
File “/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/typing.py”, line 512, in
for t2 in all_params – {t1} if not isinstance(t2, TypeVar)):
File “/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/typing.py”, line 1077, in __subclasscheck__
if super().__subclasscheck__(cls):
File “/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/abc.py”, line 225, in __subclasscheck__
for scls in cls.__subclasses__():
TypeError: descriptor ‘__subclasses__’ of ‘type’ object needs an argument
python3.5.2が行けなかったか。。