This is a tutorial of how to use *args and **kwargs

For defining the default value of arguments that is not assigned in key words when calling the function:

def func(**keywargs):
if 'my_word' not in keywargs:
word = 'default_msg'
print(word)
else:
word = keywargs['my_word']
print(word)

call this by:

func()
func(my_word='love')

you'll get:

default_msg
love

read more about *args and **kwargs in python: https://www.digitalocean.com/community/tutorials/how-to-use-args-and-kwargs-in-python-3

Add more about default value if arg key is not assigned:

def make_hastie_10_2(n_samples=12000, random_state=None):
"""Generates data for binary classification used in
Hastie et al. 2009, Example 10.2. The ten features are standard independent Gaussian and
the target ``y`` is defined by:: y[i] = 1 if np.sum(X[i] ** 2) > 9.34 else -1 Read more in the :ref:`User Guide <sample_generators>`. Parameters
----------
n_samples : int, optional (default=12000)
The number of samples. random_state : int, RandomState instance or None (default)
Determines random number generation for dataset creation. Pass an int
for reproducible output across multiple function calls.
See :term:`Glossary <random_state>`. Returns
-------
X : array of shape [n_samples, 10]
The input samples. y : array of shape [n_samples]
The output values. References
----------
.. [1] T. Hastie, R. Tibshirani and J. Friedman, "Elements of Statistical
Learning Ed. 2", Springer, 2009. See also
--------
make_gaussian_quantiles: a generalization of this dataset approach
"""
rs = check_random_state(random_state) shape = (n_samples, 10)
X = rs.normal(size=shape).reshape(shape)
y = ((X ** 2.0).sum(axis=1) > 9.34).astype(np.float64, copy=False)
y[y == 0.0] = -1.0 return X, y

最新文章

  1. 安卓开发 想要获取某个View的高度(我是在做滚动浮层的时候用到的)
  2. windows phpstudy 本地添加自定义域名
  3. redis 配置应用(摘)
  4. Positive-definite matrix
  5. ListView中的item的按照和item点击事件并存
  6. Node.js 创建HTTP服务器(经过测试,这篇文章是靠谱的T_T)
  7. smtp邮件营销吧
  8. POJ 1151 Atlantis(离散化)
  9. [转] HDU 题目分类
  10. PHP MySQL Select 之Select
  11. Javascript基础学习笔记
  12. MVC之文件上传1
  13. Android中自定义veiw使用Java中的回调方法
  14. js X年X周 转成 具体日期
  15. 【Teradata SQL】从中文数字字母混合字符串中只提取数字regexp_substr
  16. Mysql JSON字段提取某一个属性值的函数
  17. Jupyter Notebook 快捷键使用指南
  18. 本地连接虚拟机 Oracle数据库 报ORA-12541:TNS:no listener
  19. Spring Boot 解决方案 - 配置
  20. kafka 基础知识梳理

热门文章

  1. grep匹配单词, 匹配单词开始, 匹配^ 的区别
  2. awk调用系统命令
  3. 设计模式-Runoob:设计模式
  4. Vue --》 如何在vue中调用百度地图
  5. 前端 CSS的选择器 伪元素选择器
  6. win10系统Mysql5.7服务启动报:&quot;1053错误:服务没有及时响应启动或控制请求&quot;
  7. HDFS中DataNode工作机制
  8. jsp对象 指令 动作
  9. Oracle数据库的发展历程
  10. BZOJ 1085(IDA*)