skip to Main Content

I run my python code in visual studio code but it has a problem with the teminal.

Here the error:
enter image description here

I trying to run Machine Learning and have a result program

here the code:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import pickle
from sklearn.preprocessing import OneHotEncoder
from sklearn.compose import ColumnTransformer

data = pd.read_csv("D:DayroiML LearnTestcar-sales-extended.csv")

x = data.drop("Price",axis=1)
y = data["Price"]

f = ["Make","Colour","Doors"]
one_hot = OneHotEncoder()
tran = ColumnTransformer([("one_hot",one_hot,f)],remainder= "passthrough")
taX = tran.fit_transform(x)
neu = False

from sklearn.neural_network import MLPClassifier
from sklearn.ensemble import RandomForestRegressor
clf = MLPClassifier(solver='lbfgs', alpha=1e-5,
                    hidden_layer_sizes=(5, 2), random_state=1)
if(neu != True):
    clf = RandomForestRegressor()
from sklearn.model_selection import train_test_split
scoreH = 1
scoreT = 0
while(scoreT < 0.9):
    Xh, Xt, Yh, Yt = train_test_split(taX,y,test_size=0.2)
    clf.fit(Xh,Yh)
    y_prede = clf.predict(Xt)
    scoreH = clf.score(Xh,Yh)
    scoreT = clf.score(Xt,Yt)
    print(scoreT)
    
pickle.dump(clf,open("heart-disease.nn","wb"))

load = pickle.load(open("heart-disease.nn","rb"))
print(load.score(Xt,Yt))

Each good answer is highly appreciated

2

Answers


  1. From https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes–0-499- :

    ERROR_FILE_NOT_FOUND 2 (0x2) The system cannot find the file
    specified.

    Maybe some file can not be found?
    According to your screenshot "heart-disease.nn" is not in the same directory as "Learn.py". However you are making a relative import. Try to use an absolute path to make sure the file can be found.

    Login or Signup to reply.
  2. You need to check whether there’s something wrong with your PowerShell.

    If you don’t mind use command Prompt, you can add the following codes to your
    User Uettings (Ctrl+Shift+P and search for Open User Settings) to change the default terminal:

    "terminal.integrated.defaultProfile.windows": "Command Prompt",
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search