what is regression analysis code example
Example 1: regression model
knn=KNeighborsRegressor()
svr=SVR()
lr=LinearRegression()
dt=DecisionTreeRegressor()
gbm=GradientBoostingRegressor()
ada=AdaBoostRegressor()
rfr=RandomForestRegressor()
xgb=XGBRegressor()
------------------------------------------------------------------------
models=[]
models.append(('KNeighborsRegressor',knn))
models.append(('SVR',svr))
models.append(('LinearRegression',lr))
models.append(('DecisionTreeRegressor',dt))
models.append(('GradientBoostingRegressor',gbm))
models.append(('AdaBoostRegressor',ada))
models.append(('RandomForestRegressor',rfr))
models.append(('XGBRegressor',xgb))
-------------------------------------------------------------------------
from sklearn.metrics import r2_score,mean_squared_error
from sklearn.model_selection import train_test_split,cross_val_score
x_train,x_test,y_train,y_test=train_test_split(x,y,random_state=42)
-------------------------------------------------------------------------
Model=[]
r2score=[]
rmse=[]
cv=[]
for name,model in models:
print('*****************',name,'*******************')
print('\n')
Model.append(name)
model.fit(x_train,y_train)
print(model)
pre=model.predict(x_test)
print('\n')
score=r2_score(y_test,pre)
print('R2score -',score)
r2score.append(score*100)
print('\n')
sc=cross_val_score(model,x,y,cv=5,scoring='r2').mean()
print('cross_val_score -',sc)
cv.append(sc*100)
print('\n')
rmsescore=np.sqrt(mean_squared_error(y_test,pre))
print('rmse_score -',rmsescore)
rmse.append(rmsescore)
print('\n')
------------------------------------------------------------------------
result=pd.DataFrame({'Model':Model,'R2_score':r2score,'RMSEscore':rmse,'Cross_val_score':cv})
result
Example 2: what is risk analysis
Risk analysis is the process of identifying
risk in the application and prioritizing
them to test. Following are some of the
risks:
1.New Hardware.
2. New Technology.
3. New Automation Tool.
4. Sequence of code delivery.
5. Availability of application
test resources.
o High magnitude: Impact of the bug on
the other functionality of the application.
o Medium: it can be tolerable in the
application but not desirable.
o Low: it can be tolerable. This type
of risk has no impact on the company business.