- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我试图从 TestDome 回答这个 question 并得到 250877.19298245612 而不是建议的 250000。请告诉我出了什么问题。谢谢
import numpy as np
from sklearn import linear_model
class MarketingCosts:
# param marketing_expenditure list. Expenditure for each previous campaign.
# param units_sold list. The number of units sold for each previous campaign.
# param desired_units_sold int. Target number of units to sell in the new campaign.
# returns float. Required amount of money to be invested.
@staticmethod
def desired_marketing_expenditure(marketing_expenditure, units_sold, desired_units_sold):
X = [[i] for i in units_sold]
reg = linear_model.LinearRegression()
reg.fit(X, marketing_expenditure)
return float(reg.predict(desired_units_sold))
#For example, with the parameters below the function should return 250000.0.
print(MarketingCosts.desired_marketing_expenditure(
[300000, 200000, 400000, 300000, 100000],
[60000, 50000, 90000, 80000, 30000],
60000))
最佳答案
我认为这是解决方案,因为我们通过搜索从 y 预测 X,并且此问题中的标签是 units_sold。
import numpy as np
from sklearn import linear_model
class MarketingCosts:
# param marketing_expenditure list. Expenditure for each previous campaign.
# param units_sold list. The number of units sold for each previous campaign.
# param desired_units_sold int. Target number of units to sell in the new campaign.
# returns float. Required amount of money to be invested.
@staticmethod
def desired_marketing_expenditure(marketing_expenditure, units_sold, desired_units_sold):
marketing_expenditure = marketing_expenditure.reshape(-1, 1)
units_sold = units_sold.reshape(-1, 1)
reg = linear_model.LinearRegression()
reg.fit(marketing_expenditure , units_sold)
return (desired_units_sold - reg.intercept_)/reg.coef_
#For example, with the parameters below the function should return 250000.0.
print(MarketingCosts.desired_marketing_expenditure(
[300000, 200000, 400000, 300000, 100000],
[60000, 50000, 90000, 80000, 30000],
60000))
关于python - TestDome 数据科学 : Not getting correct answer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51106254/
Mockito 中这两个声明有什么区别? @Mock(answer = Answers.CALLS_REAL_METHODS) ArrayList mock; @Spy ArrayList spy;
我认为形成这个问题的最好方法是举一个例子......所以,我决定问这个问题的实际原因是因为 Problem 55 on Project Euler 。在该问题中,要求找到 10,000 以下的 Lyc
我编写了代码来计算 QuickSort 中完成的比较次数。 每当对长度为 m 的数组执行快速排序时,该算法都会将比较次数增加 m-1(因为主元将与除自身以外的所有内容进行比较)。 枢轴的选择始终是数组
菜鸟开发人员,对任何非常规代码表示歉意。 我正在做一个简单的测验。一次显示一个问题,单选按钮上有 3 个可能的答案。答案“key”存储在名为 allQuestions 的数组中。 我正在寻找正确的方法
我在使用 Java 的 Sphinx 语音识别库时遇到问题。我正在使用它来获取输入并处理它。我第一次获得输入时,它起作用了。第二次,它在我有机会说话之前立即回答了自己。在那之后,它只是继续回答自己。我
ruby 问题: 我可以缩短以下代码吗: total = Paper.where(available: true).count puts total if total > 0 我想象过这样的事情,但我
进程文件: answers or answers.exe 进程名称: 1-Click Answers 进程类别:存在安全风险的进程 英文描述: an
这question and its answers这里建议两者: 可以使用正则表达式匹配嵌套模式。 这是不可能的,因为嵌套模式不是常规语言,因此 DFA(正则表达式)无法识别它们。 在阅读上述问题的答
我正在尝试实现“算法简介”一书中所述的合并排序算法。尽管实现是按照书中指定的,但输出不正确。很有可能出现相差一的错误,但我无法指出它。有什么指点吗? #include #include #defi
我在我的应用程序中添加了一个新的首选项,以允许用户选择退出分析报告。我在我的应用程序 Crashlytics 和 Fabric Answers 中使用。 我在 onCreate 中有这段代码: if
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 10 年前。 Improve thi
这里是Python新手用户。 我有一个文件,last.txt,我正在从中提取信息,该信息显示美国最常见的姓氏,以及它们以整数/小数形式出现的百分比频率。我希望能够检索三个字母长的姓氏数量并将其分配给答
禁用 Crashlytics 错误报告相对 straight forward. .我还想禁用调试版本的答案。然而, new Crashlytics.Builder().answers(null); 不
我是游戏新手,所以可能是个简单的问题。我想做的是制作一个应用程序,其中包含一个问题和一个用于回答的文本文件。然后,我希望应用程序能够识别答案何时正确(在本例中为数字 25)以及何时错误(不是 25)。
http://piratepad.net/IY48xXzsys (由 Peter West 修改,原文来自此处:http://paulbutler.org/archives/a-simple-diff
我正在使用 Answers (Fabric) 以便在我的应用程序中进行一些分析,但我在 fabric.io 中的 Answers 仪表板遇到问题。当我收到从我的应用程序发送的事件时,我无法看到自定义属
我有一个使用 Crashlytics with Answers 的应用程序。两者都工作正常,我看到正在跟踪框架中内置的事件。 我正在尝试通过在我的 View Controller 中使用以下代码行来添
我正在为调查系统构建数据库。 We have employees that fill in a survey with categories that have questions. The empl
我是 Excel 2003 中的 VBA 新手。我编写了一个包含两个字符串的 UDF:一个过滤器和一个将作为单元格引用的字符串。当我在 VBA 编辑器中调试并连续调用该函数几次时,一切都按我的预期工作
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 3个月前关闭。 Improve th
我是一名优秀的程序员,十分优秀!