Код: Выделить всё
private void Button_Click(object sender, RoutedEventArgs e)
{
string scriptPath = @"E:\TrainedModels\inversetest.py";
var result = RunPythonScript(scriptPath);
}
public static string RunPythonScript(string scriptPath)
{
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "\"C:\\Users\\PC 4\\AppData\\Local\\Programs\\Python\\Python312\\python.exe\"",
Arguments = scriptPath,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
//WorkingDirectory = @"E:\TrainedModels"
};
using (Process process = new()
{
StartInfo = startInfo
})
{
process.Start();
var output = process.StandardOutput.ReadToEnd();
var error = process.StandardError.ReadToEnd();
process.WaitForExit();
if (!string.IsNullOrEmpty(error))
{
return $"Error: {error}";
}
return output;
}
Код: Выделить всё
Traceback (most recent call last):
File "E:\TrainedModels\inversetest.py", line 32, in
pre_Down=valve_model_Down.predict(X)
Код: Выделить всё
Temp_data=pandas.read_csv("invtest.csv")
## Import Dataset
x = Temp_data[['thickness','Percu1','Percu2','Percu3','Percu4','Percu5','Percu6','Percu7','Percu8','Percu9'
,'Percu10','Percu11','Percu12','Percu13','Percu14','Percu15','Percu16','Percu17'
,'Percu18','Percu19']]
X = x / 95
L_mid = np.linspace(0, 68, 68)
## Load ANN model
valve_model_Down = pickle.load(open('inverse_Quant_Down.sav','rb'))
valve_model_Middle = pickle.load(open('inverse_Quant_Mid.sav','rb'))
valve_model_Up = pickle.load(open('inverse_Quant_Up.sav','rb'))
#prediction
pre_Down=valve_model_Down.predict(X)
pre_Middle=valve_model_Middle.predict(X)
pre_Up=valve_model_Up.predict(X)
Подробнее здесь: https://stackoverflow.com/questions/790 ... dict-model