INNER CODE UNIT · Python

preprocess_data

bansalkanav/Ultimate-Data-Science-Toolkit---From-Python-Basics-to-GenerativeAI · Module 5 - MLOPs/4. Orchestrate ML Pipeline/my_workflow_script.py:38

def preprocess_data(X_train, X_test, y_train, y_test):
    """
    Rescale the data.
    """
    scaler = MinMaxScaler()
    X_train_scaled = scaler.fit_transform(X_train)
    X_test_scaled = scaler.transform(X_test)
    return X_train_scaled, X_test_scaled, y_train, y_test
	

@task
def train_model(X_train_scaled, y_train, hyperparameters):
    """
    Training the machine learning model.
    """
    clf = KNeighborsClassifier(**hyperparameters)
    clf.fit(X_train_scaled, y_train)
    return clf

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…