0
I’m starting in the area of machine Learning, following a website that suggested the following initial model:
import pandas as pd
from sklearn import linear_model
import matplotlib.pyplot as plt
dataframe = pd.read_fwf('brain_body.txt')
x_values = dataframe[['Brain']]
y_values = dataframe[['Body']]
body_reg = linear_model.LinearRegression()
body_reg.fit(x_values,y_values)
plt.scatter(x_values,y_values)
plt.plot(x_values,body_reg.predict(x_values))
plt.show()
But I’m having the following result:
FileNotFoundError: [Errno 2] No such file or directory: 'brain_body.txt'
the txt file is in the same folder as the . py main file.
An easier solution is to use the full file path. The error may occur because the python executable program was not added to the PATH (another solution is to add).
– AlexCiuffa
I tested it here and it worked. How is the file . txt? Try to use
pd.read_csv
instead ofpd.read_fwf
or the complete file path.– Pedro Costa
The file is in rows and columns, as if it were a table
– Jorge Dorio
I’m using through the anaconda, maybe it’s an incompatibility
– Jorge Dorio