Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pipelines = {
- 'lasso' : make_pipeline(StandardScaler(), Lasso(random_state=123))
- }
- for key, value in pipelines.items():
- print( key, type(value) )
- # Lasso hyperparameters
- lasso_hyperparameters = {
- 'lasso__alpha' : [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10]
- }
- hyperparameters = {
- 'lasso' : lasso_hyperparameters
- }
- # Create empty dictionary called fitted_models
- fitted_models = {}
- # Create cross-validation object from pipeline and hyperparameters
- model = GridSearchCV(pipeline, hyperparameters[name], cv=10, n_jobs=-1)
- def train(X_train, y_train):
- # Fit model on X_train, y_train
- model.fit(X_train, y_train)
- # Store model in fitted_models[name]
- fitted_models[name] = model
- # Print '{name} has been fitted'
- print(name, 'has been fitted.')
- print ("__________________________________")
- print (model.cv_results_)
- for df in pd.read_csv('train_V2.csv', chunksize=100000):
- df = df.dropna()
- df = pd.get_dummies(df, columns=['matchType'])
- df_train = df.drop(['Id', 'groupId', 'matchId'], axis = 1)
- y = df_train.winPlacePerc
- X = df_train.drop('winPlacePerc', axis=1)
- X_train, X_test, y_train, y_test = train_test_split(X, y,
- test_size=0.2,
- random_state=1234)
- X_train = np.asarray(X_train)
- X_test = np.asarray(X_test)
- y_train = np.asarray(y_train)
- y_test = np.asarray(y_test)
- train(X_train, y_train)
Add Comment
Please, Sign In to add comment