“Process finished with exit code 0” but desired output is not shown
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am new to python and have created this tiny class "myclass" which is inside a module called linear_regression_example.py. It prints out a regression summary and a density plot:
import statsmodels.api as sm
import sklearn.datasets as skld
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
class myclass:
def __init__(self, result=1):
self.result = result
def myregression(self):
y_X = skld.load_boston()
y = y_X['target']
X = y_X['data']
n = y_X['feature_names']
y = pd.DataFrame(y)
X = pd.DataFrame(X, columns=n)
X = sm.add_constant(X)
mod = sm.OLS(y, X)
result = mod.fit()
if self.result == 1:
print(result.summary())
pred = mod.predict(result.params)
pred = pd.DataFrame(pred)
errors = y - pred
sns.distplot(errors)
plt.show()
I also have another file, called test.py:
import linear_regression_example as lre
test = lre.myclass()
test.myregression()
Running test.py in pycharm results in the output "Process finished with exit code 0" but no summary or plot is shown. Maybe someone here knows where the problem lies.
Best regards
Dominik
python matplotlib
add a comment |
I am new to python and have created this tiny class "myclass" which is inside a module called linear_regression_example.py. It prints out a regression summary and a density plot:
import statsmodels.api as sm
import sklearn.datasets as skld
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
class myclass:
def __init__(self, result=1):
self.result = result
def myregression(self):
y_X = skld.load_boston()
y = y_X['target']
X = y_X['data']
n = y_X['feature_names']
y = pd.DataFrame(y)
X = pd.DataFrame(X, columns=n)
X = sm.add_constant(X)
mod = sm.OLS(y, X)
result = mod.fit()
if self.result == 1:
print(result.summary())
pred = mod.predict(result.params)
pred = pd.DataFrame(pred)
errors = y - pred
sns.distplot(errors)
plt.show()
I also have another file, called test.py:
import linear_regression_example as lre
test = lre.myclass()
test.myregression()
Running test.py in pycharm results in the output "Process finished with exit code 0" but no summary or plot is shown. Maybe someone here knows where the problem lies.
Best regards
Dominik
python matplotlib
I just tried this and it works fine!
– DirtyBit
Jan 3 at 10:10
add a comment |
I am new to python and have created this tiny class "myclass" which is inside a module called linear_regression_example.py. It prints out a regression summary and a density plot:
import statsmodels.api as sm
import sklearn.datasets as skld
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
class myclass:
def __init__(self, result=1):
self.result = result
def myregression(self):
y_X = skld.load_boston()
y = y_X['target']
X = y_X['data']
n = y_X['feature_names']
y = pd.DataFrame(y)
X = pd.DataFrame(X, columns=n)
X = sm.add_constant(X)
mod = sm.OLS(y, X)
result = mod.fit()
if self.result == 1:
print(result.summary())
pred = mod.predict(result.params)
pred = pd.DataFrame(pred)
errors = y - pred
sns.distplot(errors)
plt.show()
I also have another file, called test.py:
import linear_regression_example as lre
test = lre.myclass()
test.myregression()
Running test.py in pycharm results in the output "Process finished with exit code 0" but no summary or plot is shown. Maybe someone here knows where the problem lies.
Best regards
Dominik
python matplotlib
I am new to python and have created this tiny class "myclass" which is inside a module called linear_regression_example.py. It prints out a regression summary and a density plot:
import statsmodels.api as sm
import sklearn.datasets as skld
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
class myclass:
def __init__(self, result=1):
self.result = result
def myregression(self):
y_X = skld.load_boston()
y = y_X['target']
X = y_X['data']
n = y_X['feature_names']
y = pd.DataFrame(y)
X = pd.DataFrame(X, columns=n)
X = sm.add_constant(X)
mod = sm.OLS(y, X)
result = mod.fit()
if self.result == 1:
print(result.summary())
pred = mod.predict(result.params)
pred = pd.DataFrame(pred)
errors = y - pred
sns.distplot(errors)
plt.show()
I also have another file, called test.py:
import linear_regression_example as lre
test = lre.myclass()
test.myregression()
Running test.py in pycharm results in the output "Process finished with exit code 0" but no summary or plot is shown. Maybe someone here knows where the problem lies.
Best regards
Dominik
python matplotlib
python matplotlib
asked Jan 3 at 10:06
DominikDominik
31
31
I just tried this and it works fine!
– DirtyBit
Jan 3 at 10:10
add a comment |
I just tried this and it works fine!
– DirtyBit
Jan 3 at 10:10
I just tried this and it works fine!
– DirtyBit
Jan 3 at 10:10
I just tried this and it works fine!
– DirtyBit
Jan 3 at 10:10
add a comment |
1 Answer
1
active
oldest
votes
linear_regression_example.py
import statsmodels.api as sm
import sklearn.datasets as skld
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
class myclass:
def __init__(self, result=1):
self.result = result
def myregression(self):
y_X = skld.load_boston()
y = y_X['target']
X = y_X['data']
n = y_X['feature_names']
y = pd.DataFrame(y)
X = pd.DataFrame(X, columns=n)
X = sm.add_constant(X)
mod = sm.OLS(y, X)
result = mod.fit()
if self.result == 1:
print(result.summary())
pred = mod.predict(result.params)
pred = pd.DataFrame(pred)
errors = y - pred
sns.distplot(errors)
plt.show()
if __name__ == '__main__':
test = myclass()
test.myregression()
test.py
import linear_regression_example as lre
test = lre.myclass()
test.myregression()
OUTPUT (from test.py)
1
Thank you very much!
– Dominik
Jan 3 at 10:27
But I have to confess that I do not fully understand the structure here. What would I have to to if I wanted to change the parameter "result" to 0 when calling myclass from test.py?
– Dominik
Jan 3 at 10:44
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020070%2fprocess-finished-with-exit-code-0-but-desired-output-is-not-shown%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
linear_regression_example.py
import statsmodels.api as sm
import sklearn.datasets as skld
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
class myclass:
def __init__(self, result=1):
self.result = result
def myregression(self):
y_X = skld.load_boston()
y = y_X['target']
X = y_X['data']
n = y_X['feature_names']
y = pd.DataFrame(y)
X = pd.DataFrame(X, columns=n)
X = sm.add_constant(X)
mod = sm.OLS(y, X)
result = mod.fit()
if self.result == 1:
print(result.summary())
pred = mod.predict(result.params)
pred = pd.DataFrame(pred)
errors = y - pred
sns.distplot(errors)
plt.show()
if __name__ == '__main__':
test = myclass()
test.myregression()
test.py
import linear_regression_example as lre
test = lre.myclass()
test.myregression()
OUTPUT (from test.py)
1
Thank you very much!
– Dominik
Jan 3 at 10:27
But I have to confess that I do not fully understand the structure here. What would I have to to if I wanted to change the parameter "result" to 0 when calling myclass from test.py?
– Dominik
Jan 3 at 10:44
add a comment |
linear_regression_example.py
import statsmodels.api as sm
import sklearn.datasets as skld
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
class myclass:
def __init__(self, result=1):
self.result = result
def myregression(self):
y_X = skld.load_boston()
y = y_X['target']
X = y_X['data']
n = y_X['feature_names']
y = pd.DataFrame(y)
X = pd.DataFrame(X, columns=n)
X = sm.add_constant(X)
mod = sm.OLS(y, X)
result = mod.fit()
if self.result == 1:
print(result.summary())
pred = mod.predict(result.params)
pred = pd.DataFrame(pred)
errors = y - pred
sns.distplot(errors)
plt.show()
if __name__ == '__main__':
test = myclass()
test.myregression()
test.py
import linear_regression_example as lre
test = lre.myclass()
test.myregression()
OUTPUT (from test.py)
1
Thank you very much!
– Dominik
Jan 3 at 10:27
But I have to confess that I do not fully understand the structure here. What would I have to to if I wanted to change the parameter "result" to 0 when calling myclass from test.py?
– Dominik
Jan 3 at 10:44
add a comment |
linear_regression_example.py
import statsmodels.api as sm
import sklearn.datasets as skld
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
class myclass:
def __init__(self, result=1):
self.result = result
def myregression(self):
y_X = skld.load_boston()
y = y_X['target']
X = y_X['data']
n = y_X['feature_names']
y = pd.DataFrame(y)
X = pd.DataFrame(X, columns=n)
X = sm.add_constant(X)
mod = sm.OLS(y, X)
result = mod.fit()
if self.result == 1:
print(result.summary())
pred = mod.predict(result.params)
pred = pd.DataFrame(pred)
errors = y - pred
sns.distplot(errors)
plt.show()
if __name__ == '__main__':
test = myclass()
test.myregression()
test.py
import linear_regression_example as lre
test = lre.myclass()
test.myregression()
OUTPUT (from test.py)
linear_regression_example.py
import statsmodels.api as sm
import sklearn.datasets as skld
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
class myclass:
def __init__(self, result=1):
self.result = result
def myregression(self):
y_X = skld.load_boston()
y = y_X['target']
X = y_X['data']
n = y_X['feature_names']
y = pd.DataFrame(y)
X = pd.DataFrame(X, columns=n)
X = sm.add_constant(X)
mod = sm.OLS(y, X)
result = mod.fit()
if self.result == 1:
print(result.summary())
pred = mod.predict(result.params)
pred = pd.DataFrame(pred)
errors = y - pred
sns.distplot(errors)
plt.show()
if __name__ == '__main__':
test = myclass()
test.myregression()
test.py
import linear_regression_example as lre
test = lre.myclass()
test.myregression()
OUTPUT (from test.py)
answered Jan 3 at 10:13


DirtyBitDirtyBit
13.1k41943
13.1k41943
1
Thank you very much!
– Dominik
Jan 3 at 10:27
But I have to confess that I do not fully understand the structure here. What would I have to to if I wanted to change the parameter "result" to 0 when calling myclass from test.py?
– Dominik
Jan 3 at 10:44
add a comment |
1
Thank you very much!
– Dominik
Jan 3 at 10:27
But I have to confess that I do not fully understand the structure here. What would I have to to if I wanted to change the parameter "result" to 0 when calling myclass from test.py?
– Dominik
Jan 3 at 10:44
1
1
Thank you very much!
– Dominik
Jan 3 at 10:27
Thank you very much!
– Dominik
Jan 3 at 10:27
But I have to confess that I do not fully understand the structure here. What would I have to to if I wanted to change the parameter "result" to 0 when calling myclass from test.py?
– Dominik
Jan 3 at 10:44
But I have to confess that I do not fully understand the structure here. What would I have to to if I wanted to change the parameter "result" to 0 when calling myclass from test.py?
– Dominik
Jan 3 at 10:44
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020070%2fprocess-finished-with-exit-code-0-but-desired-output-is-not-shown%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I just tried this and it works fine!
– DirtyBit
Jan 3 at 10:10