Skip to main content
typo
Source Link

The answer provided by Faraz is a nice solution to the problem of performing leave-one-out cross validation with sklearn, and nicely sidesteps the problem of the original poster.
But to come back to the original question, how to resolve the error? Apparently there are two versions of LeaveOneOut in sklearn:

from sklearn.cross_validation import LeaveOneOut  #(of the original poster)

and

from sklearn.model_selection import LeaveOneOut   #(which you can find easily online)

wichwhich have a slightly different interface (cross_validation and model_selection). The latter can be run without parameters (as the original poster did), the former (which the original poster used) requires at least one parameter (n: Total number of elements):

  import glob
  import numpy as np
  import pandas as pd
  from sklearn.cross_validation import LeaveOneOut
  path=r'...................\Data\New 
  design process data'
  filelist=glob.glob(path + "/*.csv")
  loo=LeaveOneOut(n=52)
  for train,test in loo.split(filelist):
     print("%s %s" % (train, test))

The answer provided by Faraz is a nice solution to the problem of performing leave-one-out cross validation with sklearn, and nicely sidesteps the problem of the original poster.
But to come back to the original question, how to resolve the error? Apparently there are two versions of LeaveOneOut in sklearn:

from sklearn.cross_validation import LeaveOneOut  #(of the original poster)

and

from sklearn.model_selection import LeaveOneOut   #(which you can find easily online)

wich have a slightly different interface (cross_validation and model_selection). The latter can be run without parameters (as the original poster did), the former (which the original poster used) requires at least one parameter (n: Total number of elements):

  import glob
  import numpy as np
  import pandas as pd
  from sklearn.cross_validation import LeaveOneOut
  path=r'...................\Data\New 
  design process data'
  filelist=glob.glob(path + "/*.csv")
  loo=LeaveOneOut(n=52)
  for train,test in loo.split(filelist):
     print("%s %s" % (train, test))

The answer provided by Faraz is a nice solution to the problem of performing leave-one-out cross validation with sklearn, and nicely sidesteps the problem of the original poster.
But to come back to the original question, how to resolve the error? Apparently there are two versions of LeaveOneOut in sklearn:

from sklearn.cross_validation import LeaveOneOut  #(of the original poster)

and

from sklearn.model_selection import LeaveOneOut   #(which you can find easily online)

which have a slightly different interface (cross_validation and model_selection). The latter can be run without parameters (as the original poster did), the former (which the original poster used) requires at least one parameter (n: Total number of elements):

  import glob
  import numpy as np
  import pandas as pd
  from sklearn.cross_validation import LeaveOneOut
  path=r'...................\Data\New 
  design process data'
  filelist=glob.glob(path + "/*.csv")
  loo=LeaveOneOut(n=52)
  for train,test in loo.split(filelist):
     print("%s %s" % (train, test))
Source Link

The answer provided by Faraz is a nice solution to the problem of performing leave-one-out cross validation with sklearn, and nicely sidesteps the problem of the original poster.
But to come back to the original question, how to resolve the error? Apparently there are two versions of LeaveOneOut in sklearn:

from sklearn.cross_validation import LeaveOneOut  #(of the original poster)

and

from sklearn.model_selection import LeaveOneOut   #(which you can find easily online)

wich have a slightly different interface (cross_validation and model_selection). The latter can be run without parameters (as the original poster did), the former (which the original poster used) requires at least one parameter (n: Total number of elements):

  import glob
  import numpy as np
  import pandas as pd
  from sklearn.cross_validation import LeaveOneOut
  path=r'...................\Data\New 
  design process data'
  filelist=glob.glob(path + "/*.csv")
  loo=LeaveOneOut(n=52)
  for train,test in loo.split(filelist):
     print("%s %s" % (train, test))