Python regressors library summary function returns ValueError for Logistic regression












1















I'm using python inbulit boston dataset from sklearn with CHAS as my target variable.



I built Logistic Regression model from sklearn pkg.I'm using regressors library to get the summary statistics of the model output but i'm facing the following error. pleasee help me on this and kindly let me know if you need further information



find more about regressors library in below link: [1]:
https://regressors.readthedocs.io/en/latest/usage.html



Please find the below python code which i used for model building:



import numpy as np
from sklearn import datasets
import pandas as pd

bostonn = datasets.load_boston()
boston = pd.DataFrame(bostonn.data , columns= bostonn['feature_names'])
print(boston.head())

X = boston.drop('CHAS' , axis =1)
y = boston.CHAS.astype('category')

from sklearn.linear_model import LogisticRegression
from regressors import stats
log_mod=LogisticRegression(random_state=123)
model=log_mod.fit(X,y)

stats.summary(model, X, y , xlabels=None)


I'm getting the following error:



ValueErrorTraceback (most recent call last)
in ()
1 #xlabels = boston.feature_names[which_betas]
----> 2 stats.summary(model, X, y ,xlabels=None)

251 )
252 coef_df['Estimate'] = np.concatenate(
--> 253 (np.round(np.array([clf.intercept_]), 6), np.round((clf.coef_), 6)))
254 coef_df['Std. Error'] = np.round(coef_se(clf, X, y), 6)
255 coef_df['t value'] = np.round(coef_tval(clf, X, y), 4)

ValueError: all the input array dimensions except for the concatenation axis must match exactly



ValueError: all the input array dimensions except for the concatenation axis must match exactly




There are other posts which has the similar error but those solution didn't help
my problem.The attached above link has the information about how the summary function actually works.kindly let me know if you need further information.










share|improve this question

























  • @James Z, can u help me on this

    – user10857548
    Jan 3 at 4:42













  • Sorry, don't know anything about this

    – James Z
    Jan 3 at 15:31











  • LogisticRegression is not a regressor. Its a classifier.

    – Vivek Kumar
    Jan 4 at 7:57











  • What is the output of print(X.shape, y.shape)?

    – BlackBear
    Jan 4 at 7:59











  • @BlackBear It has nothing to do with X, y, but the shape of coef_ and intercept_ that are learnt when the model is fit(). That is different in regressors and classifiers in scikit-learn and also depend on other factors. The library OP is using is about the regression models where as LogisticRegression (despite its name) is a classifier.

    – Vivek Kumar
    Jan 4 at 8:07
















1















I'm using python inbulit boston dataset from sklearn with CHAS as my target variable.



I built Logistic Regression model from sklearn pkg.I'm using regressors library to get the summary statistics of the model output but i'm facing the following error. pleasee help me on this and kindly let me know if you need further information



find more about regressors library in below link: [1]:
https://regressors.readthedocs.io/en/latest/usage.html



Please find the below python code which i used for model building:



import numpy as np
from sklearn import datasets
import pandas as pd

bostonn = datasets.load_boston()
boston = pd.DataFrame(bostonn.data , columns= bostonn['feature_names'])
print(boston.head())

X = boston.drop('CHAS' , axis =1)
y = boston.CHAS.astype('category')

from sklearn.linear_model import LogisticRegression
from regressors import stats
log_mod=LogisticRegression(random_state=123)
model=log_mod.fit(X,y)

stats.summary(model, X, y , xlabels=None)


I'm getting the following error:



ValueErrorTraceback (most recent call last)
in ()
1 #xlabels = boston.feature_names[which_betas]
----> 2 stats.summary(model, X, y ,xlabels=None)

251 )
252 coef_df['Estimate'] = np.concatenate(
--> 253 (np.round(np.array([clf.intercept_]), 6), np.round((clf.coef_), 6)))
254 coef_df['Std. Error'] = np.round(coef_se(clf, X, y), 6)
255 coef_df['t value'] = np.round(coef_tval(clf, X, y), 4)

ValueError: all the input array dimensions except for the concatenation axis must match exactly



ValueError: all the input array dimensions except for the concatenation axis must match exactly




There are other posts which has the similar error but those solution didn't help
my problem.The attached above link has the information about how the summary function actually works.kindly let me know if you need further information.










share|improve this question

























  • @James Z, can u help me on this

    – user10857548
    Jan 3 at 4:42













  • Sorry, don't know anything about this

    – James Z
    Jan 3 at 15:31











  • LogisticRegression is not a regressor. Its a classifier.

    – Vivek Kumar
    Jan 4 at 7:57











  • What is the output of print(X.shape, y.shape)?

    – BlackBear
    Jan 4 at 7:59











  • @BlackBear It has nothing to do with X, y, but the shape of coef_ and intercept_ that are learnt when the model is fit(). That is different in regressors and classifiers in scikit-learn and also depend on other factors. The library OP is using is about the regression models where as LogisticRegression (despite its name) is a classifier.

    – Vivek Kumar
    Jan 4 at 8:07














1












1








1








I'm using python inbulit boston dataset from sklearn with CHAS as my target variable.



I built Logistic Regression model from sklearn pkg.I'm using regressors library to get the summary statistics of the model output but i'm facing the following error. pleasee help me on this and kindly let me know if you need further information



find more about regressors library in below link: [1]:
https://regressors.readthedocs.io/en/latest/usage.html



Please find the below python code which i used for model building:



import numpy as np
from sklearn import datasets
import pandas as pd

bostonn = datasets.load_boston()
boston = pd.DataFrame(bostonn.data , columns= bostonn['feature_names'])
print(boston.head())

X = boston.drop('CHAS' , axis =1)
y = boston.CHAS.astype('category')

from sklearn.linear_model import LogisticRegression
from regressors import stats
log_mod=LogisticRegression(random_state=123)
model=log_mod.fit(X,y)

stats.summary(model, X, y , xlabels=None)


I'm getting the following error:



ValueErrorTraceback (most recent call last)
in ()
1 #xlabels = boston.feature_names[which_betas]
----> 2 stats.summary(model, X, y ,xlabels=None)

251 )
252 coef_df['Estimate'] = np.concatenate(
--> 253 (np.round(np.array([clf.intercept_]), 6), np.round((clf.coef_), 6)))
254 coef_df['Std. Error'] = np.round(coef_se(clf, X, y), 6)
255 coef_df['t value'] = np.round(coef_tval(clf, X, y), 4)

ValueError: all the input array dimensions except for the concatenation axis must match exactly



ValueError: all the input array dimensions except for the concatenation axis must match exactly




There are other posts which has the similar error but those solution didn't help
my problem.The attached above link has the information about how the summary function actually works.kindly let me know if you need further information.










share|improve this question
















I'm using python inbulit boston dataset from sklearn with CHAS as my target variable.



I built Logistic Regression model from sklearn pkg.I'm using regressors library to get the summary statistics of the model output but i'm facing the following error. pleasee help me on this and kindly let me know if you need further information



find more about regressors library in below link: [1]:
https://regressors.readthedocs.io/en/latest/usage.html



Please find the below python code which i used for model building:



import numpy as np
from sklearn import datasets
import pandas as pd

bostonn = datasets.load_boston()
boston = pd.DataFrame(bostonn.data , columns= bostonn['feature_names'])
print(boston.head())

X = boston.drop('CHAS' , axis =1)
y = boston.CHAS.astype('category')

from sklearn.linear_model import LogisticRegression
from regressors import stats
log_mod=LogisticRegression(random_state=123)
model=log_mod.fit(X,y)

stats.summary(model, X, y , xlabels=None)


I'm getting the following error:



ValueErrorTraceback (most recent call last)
in ()
1 #xlabels = boston.feature_names[which_betas]
----> 2 stats.summary(model, X, y ,xlabels=None)

251 )
252 coef_df['Estimate'] = np.concatenate(
--> 253 (np.round(np.array([clf.intercept_]), 6), np.round((clf.coef_), 6)))
254 coef_df['Std. Error'] = np.round(coef_se(clf, X, y), 6)
255 coef_df['t value'] = np.round(coef_tval(clf, X, y), 4)

ValueError: all the input array dimensions except for the concatenation axis must match exactly



ValueError: all the input array dimensions except for the concatenation axis must match exactly




There are other posts which has the similar error but those solution didn't help
my problem.The attached above link has the information about how the summary function actually works.kindly let me know if you need further information.







python scikit-learn logistic-regression statsmodels valueerror






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 4 at 7:57









Vivek Kumar

16.8k42156




16.8k42156










asked Jan 2 at 17:56







user10857548




















  • @James Z, can u help me on this

    – user10857548
    Jan 3 at 4:42













  • Sorry, don't know anything about this

    – James Z
    Jan 3 at 15:31











  • LogisticRegression is not a regressor. Its a classifier.

    – Vivek Kumar
    Jan 4 at 7:57











  • What is the output of print(X.shape, y.shape)?

    – BlackBear
    Jan 4 at 7:59











  • @BlackBear It has nothing to do with X, y, but the shape of coef_ and intercept_ that are learnt when the model is fit(). That is different in regressors and classifiers in scikit-learn and also depend on other factors. The library OP is using is about the regression models where as LogisticRegression (despite its name) is a classifier.

    – Vivek Kumar
    Jan 4 at 8:07



















  • @James Z, can u help me on this

    – user10857548
    Jan 3 at 4:42













  • Sorry, don't know anything about this

    – James Z
    Jan 3 at 15:31











  • LogisticRegression is not a regressor. Its a classifier.

    – Vivek Kumar
    Jan 4 at 7:57











  • What is the output of print(X.shape, y.shape)?

    – BlackBear
    Jan 4 at 7:59











  • @BlackBear It has nothing to do with X, y, but the shape of coef_ and intercept_ that are learnt when the model is fit(). That is different in regressors and classifiers in scikit-learn and also depend on other factors. The library OP is using is about the regression models where as LogisticRegression (despite its name) is a classifier.

    – Vivek Kumar
    Jan 4 at 8:07

















@James Z, can u help me on this

– user10857548
Jan 3 at 4:42







@James Z, can u help me on this

– user10857548
Jan 3 at 4:42















Sorry, don't know anything about this

– James Z
Jan 3 at 15:31





Sorry, don't know anything about this

– James Z
Jan 3 at 15:31













LogisticRegression is not a regressor. Its a classifier.

– Vivek Kumar
Jan 4 at 7:57





LogisticRegression is not a regressor. Its a classifier.

– Vivek Kumar
Jan 4 at 7:57













What is the output of print(X.shape, y.shape)?

– BlackBear
Jan 4 at 7:59





What is the output of print(X.shape, y.shape)?

– BlackBear
Jan 4 at 7:59













@BlackBear It has nothing to do with X, y, but the shape of coef_ and intercept_ that are learnt when the model is fit(). That is different in regressors and classifiers in scikit-learn and also depend on other factors. The library OP is using is about the regression models where as LogisticRegression (despite its name) is a classifier.

– Vivek Kumar
Jan 4 at 8:07





@BlackBear It has nothing to do with X, y, but the shape of coef_ and intercept_ that are learnt when the model is fit(). That is different in regressors and classifiers in scikit-learn and also depend on other factors. The library OP is using is about the regression models where as LogisticRegression (despite its name) is a classifier.

– Vivek Kumar
Jan 4 at 8:07












0






active

oldest

votes












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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54010980%2fpython-regressors-library-summary-function-returns-valueerror-for-logistic-regre%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown
























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54010980%2fpython-regressors-library-summary-function-returns-valueerror-for-logistic-regre%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith