Code

Prediction Error Plots

import plotly.express as px import plotly.graph_objects as go from sklearn.linear_model import LinearRegression df = px.data.iris() X = df[['sepal_width', 'sepal_length']] y = df['petal_width'] # Condition the model on sepal width and length, predict the petal width model = LinearRegression() model.fit(X, y) y_pred = model.predict(X) fig = px.scatter(x=y, y=y_pred, labels={'x': 'ground truth', 'y': 'prediction'}) fig.add_shape( type="line", line=dict(dash='dash'), x0=y.min(), y0=y.min(), x1=y.max(), y1=y.max() ) fig.show()
Image 0

0

1

Updated 2021-05-28

Tags

Python Programming Language

Data Science