how to draw a negative exponential plot of this situation with python
$begingroup$
I have a dataset with binary output ($Y$) and I have a column (Duration) contains the duration of each task that is stored by "days" and varied from 1day to 350 days.
when I think logically in our situation, I can deduce that the probability of getting a positive output value ($Y = 1$) require to have small duration task.
But I need to justify my opinion with some plots
I have tried the following source code but It doesn't represent correctly my assumption.
#LoadData
min_duration = plot_data['Duration'].min()
max_duration = plot_data['Duration'].max()
xr_ = list(range(min_duration, max_duration, 5))
y_ =
for i in range(0,(len(xr_)-1)):
a_ = np.logical_and(plot_data['Duration'].values >= xr_[i], plot_data['Duration'].values < xr_[i+1])
b_ = np.logical_and(np.logical_and(plot_data['Duration'].values >= xr_[i], plot_data['Duration'].values < xr_[i+1]), plot_data['output'].values==1)
y_.append(sum(b_)/sum(a_))
import matplotlib
matplotlib.pyplot.plot(xr_[1:len(xr_)], y_, 'o')
Based on my previous assumption I must get a plot which contains an exponential form like :
But I have got contrary the following plot:
I want to know where I have a mistake and If there is any other method to justify my assumption
python dataset matplotlib
$endgroup$
add a comment |
$begingroup$
I have a dataset with binary output ($Y$) and I have a column (Duration) contains the duration of each task that is stored by "days" and varied from 1day to 350 days.
when I think logically in our situation, I can deduce that the probability of getting a positive output value ($Y = 1$) require to have small duration task.
But I need to justify my opinion with some plots
I have tried the following source code but It doesn't represent correctly my assumption.
#LoadData
min_duration = plot_data['Duration'].min()
max_duration = plot_data['Duration'].max()
xr_ = list(range(min_duration, max_duration, 5))
y_ =
for i in range(0,(len(xr_)-1)):
a_ = np.logical_and(plot_data['Duration'].values >= xr_[i], plot_data['Duration'].values < xr_[i+1])
b_ = np.logical_and(np.logical_and(plot_data['Duration'].values >= xr_[i], plot_data['Duration'].values < xr_[i+1]), plot_data['output'].values==1)
y_.append(sum(b_)/sum(a_))
import matplotlib
matplotlib.pyplot.plot(xr_[1:len(xr_)], y_, 'o')
Based on my previous assumption I must get a plot which contains an exponential form like :
But I have got contrary the following plot:
I want to know where I have a mistake and If there is any other method to justify my assumption
python dataset matplotlib
$endgroup$
add a comment |
$begingroup$
I have a dataset with binary output ($Y$) and I have a column (Duration) contains the duration of each task that is stored by "days" and varied from 1day to 350 days.
when I think logically in our situation, I can deduce that the probability of getting a positive output value ($Y = 1$) require to have small duration task.
But I need to justify my opinion with some plots
I have tried the following source code but It doesn't represent correctly my assumption.
#LoadData
min_duration = plot_data['Duration'].min()
max_duration = plot_data['Duration'].max()
xr_ = list(range(min_duration, max_duration, 5))
y_ =
for i in range(0,(len(xr_)-1)):
a_ = np.logical_and(plot_data['Duration'].values >= xr_[i], plot_data['Duration'].values < xr_[i+1])
b_ = np.logical_and(np.logical_and(plot_data['Duration'].values >= xr_[i], plot_data['Duration'].values < xr_[i+1]), plot_data['output'].values==1)
y_.append(sum(b_)/sum(a_))
import matplotlib
matplotlib.pyplot.plot(xr_[1:len(xr_)], y_, 'o')
Based on my previous assumption I must get a plot which contains an exponential form like :
But I have got contrary the following plot:
I want to know where I have a mistake and If there is any other method to justify my assumption
python dataset matplotlib
$endgroup$
I have a dataset with binary output ($Y$) and I have a column (Duration) contains the duration of each task that is stored by "days" and varied from 1day to 350 days.
when I think logically in our situation, I can deduce that the probability of getting a positive output value ($Y = 1$) require to have small duration task.
But I need to justify my opinion with some plots
I have tried the following source code but It doesn't represent correctly my assumption.
#LoadData
min_duration = plot_data['Duration'].min()
max_duration = plot_data['Duration'].max()
xr_ = list(range(min_duration, max_duration, 5))
y_ =
for i in range(0,(len(xr_)-1)):
a_ = np.logical_and(plot_data['Duration'].values >= xr_[i], plot_data['Duration'].values < xr_[i+1])
b_ = np.logical_and(np.logical_and(plot_data['Duration'].values >= xr_[i], plot_data['Duration'].values < xr_[i+1]), plot_data['output'].values==1)
y_.append(sum(b_)/sum(a_))
import matplotlib
matplotlib.pyplot.plot(xr_[1:len(xr_)], y_, 'o')
Based on my previous assumption I must get a plot which contains an exponential form like :
But I have got contrary the following plot:
I want to know where I have a mistake and If there is any other method to justify my assumption
python dataset matplotlib
python dataset matplotlib
edited 5 mins ago
Siong Thye Goh
1,438620
1,438620
asked 7 hours ago
NirmineNirmine
537
537
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
The model you are looking for is this:
$Y=A e^{-Bx} + c$, I know the implementation in R, because I don't know of a nonlinear estimation in Python
This code in R might work:
R=data.frame(X=c(1,2,3,4,5,6,7,8,9),Y=c(1,2,3,3,3,3,3,3,3)) # Data in which X, Y are your data
model=nls(formula = Y~A*exp(-B*X)+C,data=R)
summary(model)
There is a limitation to take into account, is explained in this link, is summarized in the impossibility for all possible models to exist, the "most inside" model should be linear.
First steps with Non-Linear Regression in R
Singular Gradient Error in nls with correct starting values
$endgroup$
$begingroup$
Thank you juan, I will try to look for the equivalent function in python .
$endgroup$
– Nirmine
4 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "557"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2fdatascience.stackexchange.com%2fquestions%2f51038%2fhow-to-draw-a-negative-exponential-plot-of-this-situation-with-python%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
$begingroup$
The model you are looking for is this:
$Y=A e^{-Bx} + c$, I know the implementation in R, because I don't know of a nonlinear estimation in Python
This code in R might work:
R=data.frame(X=c(1,2,3,4,5,6,7,8,9),Y=c(1,2,3,3,3,3,3,3,3)) # Data in which X, Y are your data
model=nls(formula = Y~A*exp(-B*X)+C,data=R)
summary(model)
There is a limitation to take into account, is explained in this link, is summarized in the impossibility for all possible models to exist, the "most inside" model should be linear.
First steps with Non-Linear Regression in R
Singular Gradient Error in nls with correct starting values
$endgroup$
$begingroup$
Thank you juan, I will try to look for the equivalent function in python .
$endgroup$
– Nirmine
4 hours ago
add a comment |
$begingroup$
The model you are looking for is this:
$Y=A e^{-Bx} + c$, I know the implementation in R, because I don't know of a nonlinear estimation in Python
This code in R might work:
R=data.frame(X=c(1,2,3,4,5,6,7,8,9),Y=c(1,2,3,3,3,3,3,3,3)) # Data in which X, Y are your data
model=nls(formula = Y~A*exp(-B*X)+C,data=R)
summary(model)
There is a limitation to take into account, is explained in this link, is summarized in the impossibility for all possible models to exist, the "most inside" model should be linear.
First steps with Non-Linear Regression in R
Singular Gradient Error in nls with correct starting values
$endgroup$
$begingroup$
Thank you juan, I will try to look for the equivalent function in python .
$endgroup$
– Nirmine
4 hours ago
add a comment |
$begingroup$
The model you are looking for is this:
$Y=A e^{-Bx} + c$, I know the implementation in R, because I don't know of a nonlinear estimation in Python
This code in R might work:
R=data.frame(X=c(1,2,3,4,5,6,7,8,9),Y=c(1,2,3,3,3,3,3,3,3)) # Data in which X, Y are your data
model=nls(formula = Y~A*exp(-B*X)+C,data=R)
summary(model)
There is a limitation to take into account, is explained in this link, is summarized in the impossibility for all possible models to exist, the "most inside" model should be linear.
First steps with Non-Linear Regression in R
Singular Gradient Error in nls with correct starting values
$endgroup$
The model you are looking for is this:
$Y=A e^{-Bx} + c$, I know the implementation in R, because I don't know of a nonlinear estimation in Python
This code in R might work:
R=data.frame(X=c(1,2,3,4,5,6,7,8,9),Y=c(1,2,3,3,3,3,3,3,3)) # Data in which X, Y are your data
model=nls(formula = Y~A*exp(-B*X)+C,data=R)
summary(model)
There is a limitation to take into account, is explained in this link, is summarized in the impossibility for all possible models to exist, the "most inside" model should be linear.
First steps with Non-Linear Regression in R
Singular Gradient Error in nls with correct starting values
answered 4 hours ago
Juan Esteban de la CalleJuan Esteban de la Calle
76822
76822
$begingroup$
Thank you juan, I will try to look for the equivalent function in python .
$endgroup$
– Nirmine
4 hours ago
add a comment |
$begingroup$
Thank you juan, I will try to look for the equivalent function in python .
$endgroup$
– Nirmine
4 hours ago
$begingroup$
Thank you juan, I will try to look for the equivalent function in python .
$endgroup$
– Nirmine
4 hours ago
$begingroup$
Thank you juan, I will try to look for the equivalent function in python .
$endgroup$
– Nirmine
4 hours ago
add a comment |
Thanks for contributing an answer to Data Science Stack Exchange!
- 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.
Use MathJax to format equations. MathJax reference.
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%2fdatascience.stackexchange.com%2fquestions%2f51038%2fhow-to-draw-a-negative-exponential-plot-of-this-situation-with-python%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