Python Forum
machine learning error (using jupyter)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
machine learning error (using jupyter)
#1
i was trying to play around with machine learning and make prediction on this data set using jupyter:

https://github.com/dpkravi/DecisionTreeC...r/data.csv

but i get errors. i don't know if my coding is flawed, or the data set isn't eligible or valid for machine learning.
i am sorry for the inconvenience Blush . i am a beginner in programing Big Grin .

import pandas
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score

isotope_data = pandas.read_csv('data.csv')
x = isotope_data.drop(columns=['pH'])
y = isotope_data['pH']
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)

model = DecisionTreeClassifier()
model.fit(x_train, y_train)
predictions = model.predict(x_test)
score = accuracy_score(y_test, predictions)
score
Error:
ValueError Traceback (most recent call last) <ipython-input-196-75a9ac0cfa74> in <module> 10 11 model = DecisionTreeClassifier() ---> 12 model.fit(x_train, y_train) 13 predictions = model.predict(x_test) 14 score = accuracy_score(y_test, predictions) ~\Anaconda3\lib\site-packages\sklearn\tree\tree.py in fit(self, X, y, sample_weight, check_input, X_idx_sorted) 799 sample_weight=sample_weight, 800 check_input=check_input, --> 801 X_idx_sorted=X_idx_sorted) 802 return self 803 ~\Anaconda3\lib\site-packages\sklearn\tree\tree.py in fit(self, X, y, sample_weight, check_input, X_idx_sorted) 138 139 if is_classification: --> 140 check_classification_targets(y) 141 y = np.copy(y) 142 ~\Anaconda3\lib\site-packages\sklearn\utils\multiclass.py in check_classification_targets(y) 169 if y_type not in ['binary', 'multiclass', 'multiclass-multioutput', 170 'multilabel-indicator', 'multilabel-sequences']: --> 171 raise ValueError("Unknown label type: %r" % y_type) 172 173 ValueError: Unknown label type: 'continuous'
Reply
#2
The column 'pH' is 'continuous' which means it consists of real numbers
The target is supposed to be of a categorical class ['binary', 'multiclass', 'multiclass-multioutput', 'multilabel-indicator', 'multilabel-sequences']
for example like column 'quality' which is the label for this dataset.
column 'pH' is a feature.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  A class of machine learning programs Led_Zeppelin 0 489 Jul-13-2023, 01:17 PM
Last Post: Led_Zeppelin
  Joining two jupyter notebooks and getting an error! Led_Zeppelin 1 1,142 Oct-20-2022, 04:28 PM
Last Post: deanhystad
  Question on None function in a machine learning algorithm Livingstone1337 1 2,363 Mar-17-2021, 10:12 PM
Last Post: supuflounder
  Gui slot machine-out of memory error steve_shambles 12 5,129 May-18-2020, 11:31 PM
Last Post: deanhystad
  Jupyter throw error aritra19 0 2,427 Jul-31-2019, 02:50 PM
Last Post: aritra19
  Error executing Jupyter command 'notebook': [Errno 'jupyter-notebook' not found] 2 Newtopython123 10 31,321 Apr-25-2019, 07:30 AM
Last Post: banu0395
  Error message in Jupyter Notebook with json diet 4 5,541 Jun-17-2018, 08:32 PM
Last Post: snippsat
  Jupyter error - 'The kernel appears to have died, it will restart automatically' meganhollie 5 18,020 Jun-12-2018, 10:11 PM
Last Post: Larz60+
  Input Data machine Learning rafaelmoraes 2 3,308 Mar-15-2018, 01:24 PM
Last Post: rafaelmoraes
  Python for machine learning, complete beginners pythonario 3 3,390 Dec-18-2017, 07:09 AM
Last Post: Terafy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020