Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python xgboost

#pip install xgboost
from xgboost import XGBClassifier,XGBRegressor
#Use classifier or regressor according to your problem
model = XGBClassifier()
model.fit(X_train, y_train)
Comment

xgboost algorithm in python

xg_reg = xgb.XGBRegressor(objective ='reg:linear', colsample_bytree = 0.3, learning_rate = 0.1,
                max_depth = 5, alpha = 10, n_estimators = 10)
Comment

xgboost algorithm in python

params = {"objective":"reg:linear",'colsample_bytree': 0.3,'learning_rate': 0.1,
                'max_depth': 5, 'alpha': 10}

cv_results = xgb.cv(dtrain=data_dmatrix, params=params, nfold=3,
                    num_boost_round=50,early_stopping_rounds=10,metrics="rmse", as_pandas=True, seed=123)
Comment

python XGBoost

# Create a placeholder to store the stock data
stock_data_dictionary = {}
for stock_name in stock_list:
# Get the data
df = data.get_data_yahoo(stock_name, start_date, end_date)
# Calculate the daily percent change
df['daily_pct_change'] = df['Adj Close'].pct_change()
# create the predictors
predictor_list = []
for r in range(10, 60, 5):
df['pct_change_'+str(r)] = df.daily_pct_change.rolling(r).sum()
df['std_'+str(r)] = df.daily_pct_change.rolling(r).std()
predictor_list.append('pct_change_'+str(r))
predictor_list.append('std_'+str(r))
# Target Variable
df['return_next_day'] = df.daily_pct_change.shift(-1)
df['actual_signal'] = np.where(df.return_next_day > 0, 1, -1)
df = df.dropna()
# Add the data to dictionary
stock_data_dictionary.update({stock_name: df})
Comment

PREVIOUS NEXT
Code Example
Python :: how to join two tuples in python 
Python :: python true and false 
Python :: text detection from image using opencv python 
Python :: user passes test django 
Python :: import turtle 
Python :: do i need do some set when i use GPU to train tensorflow model 
Python :: python string: immutable string 
Python :: python loop 3 times 
Python :: Numpy split array into chunks of equal size 
Python :: calendar module in python 
Python :: run flask in background 
Python :: python type checking boolean 
Python :: how to check if a list is empty in python 
Python :: pythagore 
Python :: 2d array python initialize 
Python :: python 3.5 release date 
Python :: three different randomn numbers python 
Python :: python left string 
Python :: numpy nditer 
Python :: pandas mask multiple condition 
Python :: propositional logic python 
Python :: python split large xml file by tag 
Python :: stackoverflow - import data on colabs 
Python :: how to use self.list.setCurrentRow() in pyqt5 
Python :: jupyter notebook morse code francais 
Python :: taggablemanager serializer django 
Shell :: install git on amazon linux 
Shell :: woeusb ubuntu install 
Shell :: how to remove mysql workbench in ubuntu 
Shell :: ps not found 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =