regression model

Solutions on MaxInterview for regression model by the best coders in the world

showing results for - "regression model"
Alice
25 Oct 2019
1knn=KNeighborsRegressor()
2svr=SVR()
3lr=LinearRegression()
4dt=DecisionTreeRegressor()
5gbm=GradientBoostingRegressor()
6ada=AdaBoostRegressor()
7rfr=RandomForestRegressor()
8xgb=XGBRegressor()
9------------------------------------------------------------------------
10models=[]
11models.append(('KNeighborsRegressor',knn))
12models.append(('SVR',svr))
13models.append(('LinearRegression',lr))
14models.append(('DecisionTreeRegressor',dt))
15models.append(('GradientBoostingRegressor',gbm))
16models.append(('AdaBoostRegressor',ada))
17models.append(('RandomForestRegressor',rfr))
18models.append(('XGBRegressor',xgb))
19-------------------------------------------------------------------------
20from sklearn.metrics import r2_score,mean_squared_error
21from sklearn.model_selection import train_test_split,cross_val_score
22x_train,x_test,y_train,y_test=train_test_split(x,y,random_state=42)
23-------------------------------------------------------------------------
24Model=[]
25r2score=[]
26rmse=[]
27cv=[]
28
29for name,model in models:
30    print('*****************',name,'*******************')
31    print('\n')
32    Model.append(name)
33    model.fit(x_train,y_train)
34    print(model)
35    pre=model.predict(x_test)
36    print('\n')
37    score=r2_score(y_test,pre)
38    print('R2score  -',score)
39    r2score.append(score*100)
40    print('\n')
41    sc=cross_val_score(model,x,y,cv=5,scoring='r2').mean()
42    print('cross_val_score  -',sc)
43    cv.append(sc*100)
44    print('\n')
45    rmsescore=np.sqrt(mean_squared_error(y_test,pre))
46    print('rmse_score  -',rmsescore)
47    rmse.append(rmsescore)
48    print('\n')
49 ------------------------------------------------------------------------
50result=pd.DataFrame({'Model':Model,'R2_score':r2score,'RMSEscore':rmse,'Cross_val_score':cv})
51result
queries leading to this page
example of regression statisticslinear regression model summarymodels of regressionmodel 3d ogistic regression 28 29regression models meaningregression modelregression modellinlinear regression modelregression examplewhich are regression models 3fml regression modelswhat is a regression modelmethod used in regression model regression modelsregression modeslwhat regression model doesregression meaningregression models iregression moderegression dataregression analysis meaningregression mlin regression analysis 2c the variable that is being predicted is independent variable dependent variable controlled variable random variable what is regression in modelwhat is regession modelml regressiondefine regressionwhat is the regression modelregressions modelslinear regression analysisregression analysis islinear regression model machine learningregression definitionwhat regression model to useregressionregression model definitionregression meaning in statisticsregression moelsimple linear regression model pythonregression varaiblesthe goto model for regression modelusage of regression analysis in data scienceregression model for data analysislinear regression technique is used to predictregression in data sciencewhat 27s regressionwhat is regression model 3fwhat is a regression of datawhat is a regression analysisregression model programwhat is regression modelingregression model machineregression analysiswhat is regressiondata regressionregression model explainedregression for analysisgeneral 3b regression modelwhat is regression model used formodels for regressiongeneral regression modelregression modelsregression model meaningwhich regression model to usewhat is a regressionregression model mlwhat is regression problemregression anlaysisdefine linear regression modelregression modelingregression model exampleregression methodwhat is regression analysisthe regression modelhow to choose which regression model to usewhat is regression modelregression techniquesstatistical analysis of regressionregression model is mainly used for 3fregression model