Question: Create a linear model that can identify all the numbers in this picture. The variables represent the cells in the matrix starting from ( 0

Create a linear model that can identify all the numbers in this picture.
The variables represent the cells in the matrix starting from (0,0) all the way to (4,2).
Reduce the variables to the minimal set by looking at the p-values. The R^2 of the best model is 1. The code isn't working right.
import warnings
warnings.filterwarnings("ignore")
import pandas as pd
import numpy as np
import statsmodels.api as sm
# Name your matrix variables mij with i from 0 to 4 and j from 0 to 2
m00=7
m01=2
m02=5
m10=3
m11=9
m12=1
m20=4
m21=6
m22=8
m30=0
m31=4
m32=3
m40=2
m41=1
m42=5
# Your code starts after this line
data ={
'x0': [0,0,0,1,1,1,2,2,2,3,3,3,4,4,4],
'x1': [0,1,2,0,1,2,0,1,2,0,1,2,0,1,2],
'y': [m00, m01, m02, m10, m11, m12, m20, m21, m22, m30, m31, m32, m40, m41, m42]
}
df = pd.DataFrame(data)
X = df[['x0','x1']]
X = sm.add_constant(X)
y = df['y']
result = sm.OLS(y, X).fit()
# Your code ends before this line
print(result.summary())
 Create a linear model that can identify all the numbers in

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!