包含标签 python 的文章

jupyter使用xgboost服务挂掉

发生错误 OMP: Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized. 1 import os os.environ['KMP_DUPLICATE_LIB_OK']='True' 2 安装nomkl conda install nomkl 参考https://github.com/dmlc/xgboost/issues/1715……

阅读全文

使用ibmcloud

创建资源 安装使用 IBM Cloud CLI https://console.bluemix.net/docs/cli/index.html#overview ibmcloud api https://api.ng.bluemix.net ibmcloud login -u [email protected] -o [email protected] -s dev //上传 bluemix app push pythondjangotest 创建项目 django-admin startproject mysite cd mysite //上传程序要在这个目录执行上传命令 python3 manage.py startapp helloworld 解决依赖 pip3 freeze > requirements.txt chardet==2.3.0 Django==2.1.7 gunicorn==19.9.0 httplib2==0.9.2 pycurl==7.43.0 pytz==2018.9 reportbug==7.1.7 requests==2.12.4 six==1.10.0 urllib3==1.19.1 uWSGI==2.0.18 在目录下新建runtime.txt,并添加python版本 例如: python-3.6.4 遇到错误 bluemix cf set-env pythondjangotest DISABLE_COLLECTSTATIC 1 bluemix cf restage pythondjangotest Procfile文件 web: gunicorn mysite.……

阅读全文

线性回归

Linear Regression_Intro page 10 生成数据 NumberObservations=100 minVal=1 maxVal=20 X = np.random.uniform(minVal,maxVal,(NumberObservations,1)) print(X.shape) #Add you code below to define error and Y based on the information above def generateY(x): Y = np.array(100) Y = 10 + 5*x #print(Y) gaussian_noise = np.random.normal(0, 1, 100).reshape(100,1) #print(gaussian_noise) Y = Y + gaussian_noise return Y Y = generateY(X) print(Y) 线性回归 def calculate_RSS(B0, B1, testX, testY): testX = np.array(testX) testY = np.array(testY) predictY = testX*B1+B0 RSS = sum((testY-predictY)*(testY-predictY)) return RSS def linear_regression(B0, B1, trainX, trainY, iteration=10000, learning_rate=0.……

阅读全文

python相关

numpy #正态分布 import numpy as np np.random.normal(0, 1, 100) #μ=0,σ=1 DataFrame增加一列 df['new_column'] = data df.insert(index, 'flag', array) DataFrame选择两列 df[['a','b']] pd.DataFrame(df,columns = ['s','b']) python plot plt.plot(df['a'], df['b'], 'o') plt.show() 保存文件时索引 https://blog.csdn.net/sinat_29957455/article/details/79059436 fluent python 相关 列表推导和生成器表达式 symbols = '$%x' codes = [ord(symbol) for symbol in symbols] #以下效果相同 beyond_ascii = [ord(s) for s in symbols if ord(s)>127] beyond_ascii = list(filter(lambda c: c>127, map(ord,symbols))) 文件读写 try: f = open('file', 'r') print(f.……

阅读全文