Bottom Page

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

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(), y_train)
predictions = model.predict(x_test)
score = accuracy_score(y_test, predictions)
ValueError Traceback (most recent call last) <ipython-input-196-75a9ac0cfa74> in <module> 10 11 model = DecisionTreeClassifier() ---> 12, y_train) 13 predictions = model.predict(x_test) 14 score = accuracy_score(y_test, predictions) ~\Anaconda3\lib\site-packages\sklearn\tree\ 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\ 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\ 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'
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.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Jupyter throw error aritra19 0 95 Jul-31-2019, 02:50 PM
Last Post: aritra19
  Can you help about my learning project Qusha 1 119 Jul-21-2019, 07:46 PM
Last Post: Yoriz
  Learning Python in a month MuhammadNauman 1 141 Jul-17-2019, 11:53 AM
Last Post: metulburr
  How to schedule Jupyter Notebooks with Papermill wendysling 0 204 Jun-11-2019, 05:53 PM
Last Post: wendysling
  learning to while loop iofhua 7 257 May-24-2019, 09:46 AM
Last Post: DarkCraftPlayz
  Just completed Learning Python the Hard Way rxndy 5 379 Apr-27-2019, 01:48 AM
Last Post: rxndy
  Error executing Jupyter command 'notebook': [Errno 'jupyter-notebook' not found] 2 Newtopython123 10 12,178 Apr-25-2019, 07:30 AM
Last Post: banu0395
  Learning python, stuck on some code. stanceworksv8 2 326 Apr-02-2019, 01:51 AM
Last Post: stanceworksv8
  Issue In Loading Textblob in jupyter Shivi_Bhatia 1 552 Apr-01-2019, 06:50 PM
Last Post: perfringo
  Jupyter and python terminal dervast 3 268 Mar-29-2019, 02:08 PM
Last Post: dervast

Forum Jump:

Users browsing this thread: 1 Guest(s)