import pandas as pd
uri = "https://gist.githubusercontent.com/guilhermesilveira/2d2efa37d66b6c84a722ea627a897ced/raw/10968b997d885cbded1c92938c7a9912ba41c615/tracking.csv"
dados = pd.read_csv(uri)
mapa = {
"home" : "principal",
"how_it_works" : "como_funciona",
"contact" : "contato",
"bought" : "comprou"
}
dados = dados.rename(columns = mapa)
x = dados[["principal", "como_funciona", "contato"]]
y = [["comprou"]]
treino_x = x[:75]
treino_y = y[:75]
teste_x = x[75:]
teste_y = y[75:]
print("Treinaremos com %d elementos e testaremos com %d elementos" % (len(treino_x), len(teste_x)))
teste_y.shape
AttributeError Traceback (most recent call last)
<ipython-input-15-d90e376a4499> in <module>()
----> 1 teste_y.shape
AttributeError: 'list' object has no attribute 'shape'
from sklearn.svm import LinearSVC
modelo = LinearSVC()
modelo.fit(treino_x, treino_y)
/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py:760: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
y = column_or_1d(y, warn=True)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-12-359cb4b569f7> in <module>()
2
3 modelo = LinearSVC()
----> 4 modelo.fit(treino_x, treino_y)
2 frames
/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py in check_consistent_length(*arrays)
210 if len(uniques) > 1:
211 raise ValueError("Found input variables with inconsistent numbers of"
--> 212 " samples: %r" % [int(l) for l in lengths])
213
214
ValueError: Found input variables with inconsistent numbers of samples: [75, 1]
O código apresentou estes dois erros e não se como resolver...