# librerias from numpy import mean from numpy import std from pandas import read_csv from sklearn.model_selection import LeaveOneOut from sklearn.model_selection import StratifiedKFold from sklearn.model_selection import cross_val_score from sklearn.ensemble import RandomForestClassifier # librerias from pandas import read_csv # cargar datos url = 'https://raw.githubusercontent.com/jbrownlee/Datasets/master/housing.csv' dataframe = read_csv(url, header=None) # shape print(dataframe.shape) dataframe dataframe.dtypes dataframe.isnull().sum() # separar en X y y data= dataframe.values X, y = data[:, :-1], data[:, -1] print(X.shape, y.shape) from sklearn.model_selection import cross_val_score from sklearn.ensemble import RandomForestRegressor # crear el modelo model = RandomForestRegressor(random_state=42, n_estimators=10,max_depth=4) scores = cross_val_score(model, X, y, cv=7, verbose=1,scoring='r2') print("%0.2f de r2 promedio con una desviacion estandar de %0.2f" % (scores.mean(), scores.std()))