✒️ Modules & Settings
xxxxxxxxxx
import sklearn as sl,pandas as pd,numpy as np,pylab as pl
from sklearn.datasets import make_regression
from sklearn.multioutput import MultiOutputRegressor
from sklearn.ensemble import GradientBoostingRegressor
Multioutput Toy Regression
xxxxxxxxxx
X,y=make_regression(
n_samples=1000,n_features=7,n_targets=3,random_state=1)
pl.figure(figsize=(6,4))
colors=['darkred','darkorchid','darkblue']
markers=['h','v','s']
m=100
py=MultiOutputRegressor(
GradientBoostingRegressor(random_state=0))\
.fit(X,y).predict(X)
for i in range(3):
pl.plot(X[:m,0],y[:m,i],'o',c=colors[i],
ms=7,marker=markers[i],alpha=.3,
label='y%d'%i)
pl.plot(X[:m,0],py[:m,i],'o',c=colors[i],
ms=3,marker=markers[i],alpha=.8,
label='py%d'%i)
pl.grid(); pl.legend()
pl.tight_layout(); pl.show()
No comments:
Post a Comment