# Import necessary libraries
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
# Generate some sample data
X = np.random.rand(100, 5)
y = 2*X[:,0] + 3*X[:,1] - 4*X[:,2] + np.random.randn(100)*0.5
# Create a pipeline with scaling and linear regression
pipeline = Pipeline([
    ('scaler', StandardScaler()),
    ('regressor', LinearRegression())])
# Fit the pipeline to the data
pipeline.fit(X, y) 

import yaml
from yaml.loader import BaseLoader
model=pipeline
# Convert the model to YAML format
model_yaml = yaml.dump(model)
# Save the YAML to a file
with open('model.yaml', 'w') as f:
    f.write(model_yaml)
# Load the YAML from the file and convert back to a model object
with open('model.yaml', 'r') as f:
    model_yaml = f.read()
model = yaml.load(model_yaml,Loader=BaseLoader)
X_testpred = np.random.rand(5)
y_testpred = pipeline.predict([X_testpred])
print("Predicted value:",y_testpred)