Skip to content

Instantly share code, notes, and snippets.

@Pawandeep-prog
Created June 1, 2021 12:59
Show Gist options
  • Save Pawandeep-prog/4b05937d17e827c2cec9871d8afafa85 to your computer and use it in GitHub Desktop.
Save Pawandeep-prog/4b05937d17e827c2cec9871d8afafa85 to your computer and use it in GitHub Desktop.
import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
df = np.load('archive/olivetti_faces.npy')
df = df.reshape(400, 64*64)
y = np.random.randn(40000).reshape(400,100)
reg = LinearRegression().fit(y, df)
reg.score(y, df)
plt.imshow(df[np.random.randint(1, 400)].reshape(64,64), cmap='gray')
plt.show()
inp = np.random.randn(100).reshape(1,-1)
pred = reg.predict(inp)
plt.imshow(pred.reshape(64,64), cmap='gray')
plt.show()
@Pawandeep-prog
Copy link
Author

face generation using linear Regression
just did for fun while learning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment