I have an dataset.

I am unable to use the K-Fold Validation. I am getting the error raised:

ValueError("{0} is not supported".format(y_type))

ValueError: continuous is not supported .

I do not want to do encoding to int, since it may affect the data, and also I want to understand why K-fold is not working.

Below is my python code.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.ensemble import RandomForestRegressor
from sklearn import cross_validation, metrics
from sklearn.cross_validation import train_test_split
from sklearn import model_selection
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.naive_bayes import GaussianNB

from sklearn import svm
from sklearn import preprocessing

 - `List item`

url = "https://archive.ics.uci.edu/ml/machine-learning-databases/00242/ENB2012_data.xlsx"
names=['Relative Compactness','Surface Area','Wall Area','Roof Area','Overall Height','Orientation','Glazing Area','Glazing Area Distribution','Heating Load','Cooling Load']
df = pd.read_excel(url,names=names)

#Feature selection
#save the original values in a dataframe so we can compare later
test_loads=test[["Cooling Load"]]
#Create 2 lists of response values to train our model
Y1=np.array(train['Heating Load'])
Y2=np.array(train['Cooling Load'])

#Select the features
train_corr=train[['Overall Height','Relative Compactness','Roof Area','Surface Area']]
test_corr=test[['Overall Height','Relative Compactness','Roof Area','Surface Area']]
seed = 7
scoring = 'accuracy'
kfold = model_selection.KFold(n_splits=10, random_state=seed) 
cv_results = model_selection.cross_val_score(RandomForestRegressor(), X_train, y_train, cv=kfold, scoring=scoring)
print (cv_results.mean())

Based on the answer here, Since you are doing a classification task, you should be using the metric R-squared (co-effecient of determination) instead of accuracy score (accuracy score is used for classification purposes). You should use something like score for evaluation because your task is regression.

  • $\begingroup$ I guess ,Random forest algorithm is a supervised classification algorithm,so it wont come into regression, iam trying to do an classifictaion here $\endgroup$
    – Ashok DS
    Feb 8 '18 at 6:49
  • $\begingroup$ Would you put your data, are you predicting labels or real value amounts? $\endgroup$ Feb 8 '18 at 6:52
  • $\begingroup$ Iam trying to do an classification like which of the features like (Relative Compactness','Surface Area','Wall Area') contribute most to the HeatingLoad,Cooling Load as the per the Learning data available in "archive.ics.uci.edu/ml/machine-learning-databases/00242/…", where Y1 denotes cooling load and y2 denotes heat load , as in archive.ics.uci.edu/ml/datasets/Energy+efficiency $\endgroup$
    – Ashok DS
    Feb 8 '18 at 7:07
  • $\begingroup$ @AshokDS I quote from the link you've provided , aiming to predict two real valued responses, regression. It can also be used as a multi-class classification problem if the response is rounded to the nearest integer. $\endgroup$ Feb 8 '18 at 7:20
  • $\begingroup$ So u mean to say that i should do R square for regression and after which could you pls give me a hint on how i can classify it $\endgroup$
    – Ashok DS
    Feb 8 '18 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.