Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

scaling, cross validation and fitting a model through a pipline

# Build the steps
steps = [("scaler", StandardScaler()),
         ("logreg", LogisticRegression())]
pipeline = Pipeline(steps)

# Create the parameter space
parameters = {"logreg__C": np.linspace(0.001, 1.0, 20)}
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, 
                                                    random_state=21)

# Instantiate the grid search object
cv = GridSearchCV(pipeline, param_grid=parameters)

# Fit to the training data
cv.fit(X_train, y_train)
print(cv.best_score_, "
", cv.best_params_)
Comment

PREVIOUS NEXT
Code Example
Python :: django error column last_login cannot be null 
Python :: egt id of current object django 
Python :: tkinder 
Python :: ERROR: Target path exists but is not a directory, will not continue. 
Python :: create empty dataframe and concat 
Python :: Insert datframe column at specific place 
Python :: Horizontal stacked percent bar chart - with dataframe, seaborn colormap 
Python :: Python 0 evaluates to False 
Python :: How to Merge QuerySets in Django Rest Framework 
Python :: Creaing your own functions 
Python :: asdfghjkl 
Python :: python nc group variables 
Python :: tkinter centre a button on 1920x1080 
Python :: calculate speed with time in datetime python 
Python :: copy data with tensroflow io 
Python :: finns = False 
Python :: python lxml get parent 
Python :: couchbase python 
Python :: aggregation with f() in django rest api 
Python :: python sort by value first then key lexicography 
Python :: mk virtual env 
Python :: ios iterate through dictionary 
Python :: if function error grepper 
Python :: extract first word from string in column into a list in python 
Python :: how to create a custom function in python 
Python :: dynamic frame latest record 
Python :: cv2.puttext 
Python :: pysft connection drop issue 
Python :: can i save additional information with png file 
Python :: matplotlib csv-datei anpassen und verwenden 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =