加载中
k-means算法(使用包)

import numpy as np import matplotlib.pyplot as plt from sklearn.cluster import KMeans from sklearn.datasets.samples_generator import make_blobs X为样本特征,Y为样本簇类别, 共1...

python map()

map()函数 map()是 Python 内置的高阶函数,它接收一个函数 f 和一个 list,并通过把函数 f 依次作用在 list 的每个元素上,得到一个新的 list 并返回。(利用生成器的原理,并不马上返回值,...

10/21 21:43
5
工厂模式

(从别人里copy的,方便自己查看) 意图:定义一个创建对象的接口,让其子类自己决定实例化哪一个工厂类,工厂模式使其创建过程延迟到子类进行。 主要解决:主要解决接口选择的问题。 何时使...

10/18 21:28
2
knn算法

import numpy as np def CreateDateSet(): group = np.array([[1.0, 2.0], [1.2, 0.1], [0.1, 1.4], [0.3, 3.5]]) labels = ['A','A','B','B'] return group,labels coding:utf-8 from numpy...

tf-idf的实现

#改变batch_size 和max_features的值影响图像的形状 import tensorflow as tf import matplotlib.pyplot as plt import csv import numpy as np import string import os from zipfile impor...

基本用法

import tensorflow as tf import numpy as np sess = tf.Session() data_size = 25 data_ld = np.random.normal(size=data_size) x_input_id = tf.placeholder(dtype=tf.float32,shape=[data...

简单神经网络

import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from sklearn import datasets from tensorflow.python.framework import ops ops.reset_default_graph() ses...

singmod 与relu损失函数的比较

import matplotlib.pyplot as plt import numpy as np import tensorflow as tf sess = tf.Session() tf.set_random_seed(5) np.random.seed(42) batch_size = 50 a1 = tf.Variable(tf.rando...

tensorflow 戴明线性回归

损失函数可以有两种 1.点到直线的竖直距离 2.点到直线的垂直距离 import tensorflow as tf import matplotlib.pyplot as plt import numpy as np from sklearn import datasets sess = tf.Se...

tensorflow使用逆矩阵实现线性回归

import matplotlib.pyplot as plt import numpy as np import tensorflow as tf sess = tf.Session() x_vals = np.linspace(0,10,100) y_vals = x_vals+np.random.normal(0,1,100) x_vals_co...

tensorflow实现线性回归

import tensorflow as tf import matplotlib.pyplot as plt import numpy as np from sklearn import datasets from tensorflow.python.framework import ops ops.reset_default_graph() ses...

python一些科学计算基础

import matplotlib.pyplot as plt import numpy as np import pandas as pd from mpl_toolkits.mplot3d import Axes3D t = np.arange(0,5,0.2) plt.plot(t,t**2,'g^') plt.ylabel('nubers') ...

简单的svm例子

数据来源:https://github.com/oumiga1314/Coursera-ML-AndrewNg-Notes/blob/master/code/ex6-SVM/data/ex6data1.mat import pandas as pd import numpy as np import scipy.io as sio impor...

pycharm中使用scrapy命命

这篇博客写的不错,亲测 https://blog.csdn.net/MAOZEXIJR/article/details/80678133

python装饰器的原理

原理:嵌套函数的使用,返回函数地址,闭包的原理 status_user = False def login(func): def inner(): global status_user _user = 'dong' _pwd = 'dong' if status_user == False: user = ...

08/27 15:59
6
Exception: HTTP 599: SSL certificate problem

在两个地方加validate_cert=False from pyspider.libs.base_handler import * class Handler(BaseHandler): crawl_config = { } @every(minutes=24 * 60) def on_start(self): self.crawl('h...

抓取微信文章部分信息

import requests from pyquery import PyQuery as pq from urllib.parse import urlencode basic_url ='http://weixin.sogou.com/weixin?' proxy_pool_url = 'http://127.0.0.1:5000/get' im...

获取http://www.89ip.cn/index_1.html网站的ip和端口的组合

import requests import re html = requests.get("http://www.89ip.cn/index_1.html") ok=html.text ok.replace(' ','') ok.replace('\t','') print(ok) pattern2 = re.compile('(\d+.\d+.\d...

08/24 21:25
7
抓取淘宝部分信息

from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expecte...

抓取今日头条部分信息

import requests import re from urllib.parse import urlencode from requests.exceptions import RequestException import json from bs4 import BeautifulSoup import codecs from conm i...

08/24 11:02
5

没有更多内容

加载失败,请刷新页面

返回顶部
顶部