自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(164)
  • 资源 (3)
  • 收藏
  • 关注

原创 slake数据集数据预处理

* coding: utf-8 *“”"@Time : 2021/9/23 9:29@Author : smile 笑@File : datasets_text.py@desc :“”"import picklefrom torch.utils.data import DataLoader, Datasetfrom word_sequence import Word2Sequence, SaveWord2Vecimport torchvision.transforms as tfsim

2021-10-24 14:45:03 361

原创 实现word2sequence

coding=utf-8“”"author:leifunction: 实现的是构建词典,实现方法把句子转换为数字序列并将其翻转“”"class Word2Sequence(object):UNK_TAG = “UNK”PAD_TAG = “PAD”UNK = 0PAD = 1def __init__(self): self.dict = { self.UNK_TAG: self.UNK, self.PAD_TAG: self.PAD }

2021-08-05 10:18:17 530

原创 pytorch实现手写数字识别

coding=utf-8“”"author:leifunction: 使用pytorch完成手写数字的识别“”"import numpy as npfrom torch.utils.data import DataLoaderfrom torchvision.datasets import MNISTfrom torchvision.transforms import Compose, ToTensor, Normalizeimport torch.nn as nnimport torc

2021-08-05 10:16:40 511

原创 pytorch自实现线性回归和反向传播并画图

coding=utf-8“”"author:leifunction:“”"import torchimport matplotlib.pyplot as pltlearning_rate = 0.011、准备数据y = 3x + 0.8x = torch.rand((500, 1))y_true = x*0.3 + 0.82、通过模型计算y_predictw = torch.rand((1, 1), requires_grad=True)b = torch.empty((1, 1

2021-08-05 10:15:41 271

原创 numpy的使用

1、数据的属性¶import numpy as np​创建ndarrayscore = np.array([[80, 89, 86, 67, 79],[78, 97, 89, 67, 81],[90, 94, 78, 67, 74],[91, 91, 90, 67, 69],[76, 87, 75, 67, 86],[70, 79, 84, 67, 84],[94, 92, 93, 67, 64],[86, 85, 83, 67, 80]])​scorearray([[80,

2021-05-11 21:05:45 418

原创 svm支持向量机实现mnist数据集的训练和测试(准确率可达98%)

coding=utf-8“”"author:leifunction: 对mnist数据集进行模型训练,预测“”"from sklearn.svm import SVCfrom sklearn.decomposition import PCAfrom sklearn.model_selection import train_test_splitimport pandas as pdimport joblibimport matplotlib.pyplot as pltimport ran

2021-04-23 16:28:58 2536

原创 手动实现逻辑回归的整个过程及原理

from sklearn.datasets import load_iris, make_classificationfrom sklearn.model_selection import train_test_splitimport tensorflow as tfimport numpy as npX, Y = make_classification(n_samples=500, n_features=5, n_classes=2)x_train, x_test, y_train, y_tes

2021-04-23 15:49:24 448

原创 支持向量机训练mnist数据集并得到最佳参数

coding=utf-8“”"author:leifunction: 使用svm识别mnist“”"import timeimport numpy as npimport pandas as pdimport matplotlib.pyplot as pltfrom sklearn import svmfrom sklearn.model_selection import train_test_splitfrom sklearn.decomposition import PCAdef

2021-04-21 21:03:23 703 2

原创 特征降维和聚类的使用

coding=utf-8“”"author:leifunction:“”"from sklearn.cluster import KMeansimport pandas as pdfrom sklearn.decomposition import PCAfrom sklearn.metrics import silhouette_scoreorder_product = pd.read_csv("./data/instacart/order_products__prior.csv")pr

2021-04-19 17:59:35 168

原创 matplotlib百分百解决字体显示异常

from pylab import mpl设置显示中文字体mpl.rcParams[“font.sans-serif”] = [“SimHei”]设置正常显示符号mpl.rcParams[“axes.unicode_minus”] = False如果没有pylab,记得先pip install pylab 哦!

2021-04-13 21:19:42 162

原创 matplotlib多个坐标系显示图像

from pylab import mpl设置显示中文字体mpl.rcParams[“font.sans-serif”] = [“SimHei”]设置正常显示符号mpl.rcParams[“axes.unicode_minus”] = Falsex = range(60)y_beijing = [random.uniform(10, 15) for i in x]y_shanghai = [random.uniform(15, 25) for i in x]创建1行两列的画布fig, ax

2021-04-13 21:17:49 244 1

原创 matplotlib画图的简单使用

import randomfrom pylab import mpl设置显示中文字体mpl.rcParams[“font.sans-serif”] = [“SimHei”]设置正常显示符号mpl.rcParams[“axes.unicode_minus”] = False0.生成数据x = range(60)y_beijing = [random.uniform(10, 15) for i in x]y_shanghai = [random.uniform(15, 25) for i in

2021-04-13 21:16:46 127

原创 mongoDB在python中的使用(pymongo的简单操作)

coding=utf-8“”"author:leifunction:“”"from pymongo import MongoClient创建数据库链接对象client = MongoClient()client = MongoClient(“172.16.123.223”, 27017)print(client)权限认证,选择一个数据库。如果没有开权限认证,则不需要进行权限认真db = client[“admin”]账号密码进行验证db.authenticate(“python”,

2021-04-07 18:12:21 134

原创 python爬虫,嗅事百科(段子爬取)

coding=utf-8“”"author:leifunction:“”"import requestsfrom lxml import etreeimport jsonclass QiuShi(object):def __init__(self): self.url = "https://www.qiushibaike.com/text/" self.headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64

2021-04-07 18:09:17 524 7

原创 python爬虫,58汽车信息爬取(selenium)

coding=utf-8“”"author:leifunction:“”"import timefrom selenium import webdriverimport jsonclass Car(object):def init(self):self.url = “https://sanhe.58.com/ershouche/”options = webdriver.ChromeOptions()options.binary_location = r"D:\文件2\Google\C

2021-04-05 18:05:00 581 3

原创 python爬虫,虎牙房间爬取(selenium)

coding=utf-8“”"author:leifunction: 虎牙直播爬取“”"import timefrom selenium import webdriverclass HuYa(object):def init(self):self.url = “https://www.huya.com/l”options = webdriver.ChromeOptions()options.binary_location = r"D:\文件2\Google\Chrome\Applica

2021-04-05 18:04:11 311

原创 python爬虫,斗鱼房间爬取(selenium)

coding=utf-8“”"author:leifunction:斗鱼网站的爬取“”"import timefrom selenium import webdriverclass DouYu(object):def __init__(self): self.url = "https://www.douyu.com/directory/all" options = webdriver.ChromeOptions() options.binary_location =

2021-04-05 18:02:52 289

原创 python爬虫,qq空间登录(selenium在frame的切换)

coding=utf-8“”"author:leifunction:“”"from selenium import webdriverurl = “https://qzone.qq.com/”options = webdriver.ChromeOptions()options.binary_location = r"D:\文件2\Google\Chrome\Application\chrome.exe"driver = webdriver.Chrome(r"D:\文件\软件\chromed

2021-04-05 18:01:52 238

原创 python爬虫,人人网登录

coding=utf-8“”"author:leifunction:“”"import requestsimport js2pyimport jsondef login():# 创建session对象session = requests.session()# 设置请求头session.headers = {“User-Agent”: “Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.

2021-04-05 18:00:29 167

原创 python爬虫,百度贴吧(巴塞罗那)

coding=utf-8“”"author:leifunction:“”"import requestsfrom lxml import etreeimport jsonclass TieBaBaSa(object):def __init__(self, name): self.url = "https://tieba.baidu.com/f?ie=utf-8&kw={}".format(name) self.headers = {"User-Agent": "Mo

2021-04-05 17:59:33 330

原创 python爬虫,百度贴吧

coding=utf-8“”"author:leifunction:“”"import requestsfrom lxml import etreeclass TieBa(object):def __init__(self, name): self.url = "https://tieba.baidu.com/f?kw={}&ie=utf-8&pn=0".format(name) self.headers = { "User-Agent": "

2021-04-05 17:58:33 130

原创 python爬虫,百度翻译

coding=utf-8“”"author:leifunction:百度翻译“”"import jsonimport requestsclass Baidu(object):def __init__(self, word): self.url = "https://fanyi.baidu.com/sug" self.headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Appl

2021-04-05 17:57:22 151

原创 chrome和webdriver(selenium)的使用,解决selenium.common.exceptions.WebDriverException: Message: unknown ...

解决chrome+selenium使用时出现:selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary。有时候可能是我们的selenium和chrome对应版本有问题,或者未将chrome和selenium加入到环境变量。但有时当我们这些都解决后还是未能自动打开chrome,还会报这样错误,那我们就可以用如下的方式进行修改。其地址:是对应于你们的chrome_webdri

2021-04-03 13:52:44 468 1

原创 python学生管理系统的实现(面向对象,含注释,保存)

coding=utf-8“”"author:leifunction:“”"定义学生类class Student(object):def init(self, name, gender, tel):self.name = nameself.gender = genderself.tel = teldef __str__(self): return "{}, {}, {}".format(self.name, self.gender, self.tel)定义学生管理类clas

2021-03-31 14:50:55 434

原创 岭回归(加入正则化的线性回归)的使用

coding=utf-8“”"author:leifunction: L2正则化 解决过拟合,使得w的每个元素都很小,都接近于0越小的参数说明模型越简单,越简单的模型则越不容易产生过拟合现象线性回归:容易出现过拟合,为了把训练集数据表现的更好,可使用L2正则化:Ridge:岭回归,带有正则化的线性回归,解决过拟合。回归解决过拟合“”"岭回归from sklearn.linear_model import Ridgefrom sklearn.preprocessing import Sta

2021-03-20 17:40:25 385

原创 逻辑回归之癌症预测

coding=utf-8“”"author:leifunction: 逻辑回归做二分类“”"import pandas as pdfrom sklearn.linear_model import LogisticRegressionimport numpy as npfrom sklearn.model_selection import train_test_splitfrom sklearn.preprocessing import StandardScalerfrom sklearn

2021-03-19 19:36:47 352

原创 sklearn中梯度下降法和正规方程在神经网络中的应用

coding=utf-8“”"author:leifunction:“”"from sklearn.datasets import load_bostonfrom sklearn.linear_model import LinearRegression, SGDRegressorfrom sklearn.model_selection import train_test_splitfrom sklearn.preprocessing import StandardScalerfrom sk

2021-03-19 19:35:54 140

原创 聚类中K-Means和DBscan的使用

coding=utf-8“”"author:leifunction:“”"import pandas as pdfrom sklearn.cluster import KMeansbeer = pd.read_csv(“data.txt”, sep="")X = beer[[“calories”, “sodium”, “alcohol”, “cost”]]km = KMeans(n_clusters=3).fit(X)km2 = KMeans(n_clusters=2).fit(X)b

2021-03-19 19:34:50 164

原创 K近邻和朴素贝叶斯算法的使用

coding=utf-8“”"author:leifunction: k近邻算法,欧式距离,两点之间的距离公式需要进行标准化处理“”"from sklearn.neighbors import KNeighborsClassifierfrom sklearn.model_selection import train_test_splitfrom sklearn.preprocessing import StandardScalerfrom sklearn.datasets import f

2021-03-19 19:33:31 148

原创 机器学习泰坦尼克号获救预测

coding=utf-8“”"author:leifunction: 决策树“”"from sklearn.tree import DecisionTreeClassifierfrom sklearn.feature_extraction import DictVectorizerfrom sklearn.model_selection import train_test_splitfrom sklearn.tree import export_graphvizfrom sklearn.d

2021-03-19 19:32:07 231 1

原创 输入一个长方形的长和宽(整数),输出该长方形的周长C和面积S,要求格式如例(请注意打印“C:”、“S:”,使用半角冒号,参考样例输出)。

1952:输入一个长方形的长和宽(整数),输出该长方形的周长C和面积S,要求格式如例(请注意打印“C:”、“S:”,使用半角冒号,参考样例输出)。#include<stdio.h>int main(){int a,b;scanf("%d %d", &a, &b);printf("C:%d\nS:%d\n", 2*(a+b), a*b);return 0;}...

2021-03-19 19:30:19 3251

原创 pytorch实现mnist数据集的训练和预测

coding=utf-8“”"author:leifunction:“”"import osimport torchfrom torch.optim import Adamfrom torch.nn import functional as Ffrom torch import nnfrom torch.utils.data import DataLoaderfrom torchvision.datasets import MNISTfrom torchvision.transfor

2021-03-19 19:30:07 603

原创 sklearn的特征选择

coding=utf-8“”"author:lei 5function: 特征选择“”"from sklearn.feature_selection import VarianceThreshold # 特征选择from sklearn.decomposition import PCAnum_list = [[0, 2, 0, 3], [0, 1, 4, 3], [0, 1, 1, 3]]def var():“”"特征选择-删除低方差特征:return:“”"var = Va

2021-03-19 19:29:24 146

原创 sklearn特征抽取及tfidf的使用

coding=utf-8“”"author:leifunction: 特征抽取“”"from sklearn.feature_extraction import DictVectorizerfrom sklearn.feature_extraction.text import CountVectorizerfrom sklearn.feature_extraction.text import TfidfVectorizerimport jiebatext_list = [“life is

2021-03-19 19:28:34 328

原创 sklearn的特征处理

coding=utf-8“”"author:leifunction:“”"from sklearn.preprocessing import MinMaxScaler # 归一化from sklearn.preprocessing import StandardScaler # 标准化from sklearn.preprocessing import Imputer # 数据预处理import randomimport numpy as npnum_list = [[random.

2021-03-19 19:26:19 124

原创 pytorch的数据加载

coding=utf-8“”"author:leifunction:“”"import torchfrom torch.utils.data import Dataset, DataLoaderimport mathdata_path = “./data/SMSSpamCollection”完成数据集类class MyDataset(Dataset):def init(self):self.lines = open(data_path, encoding=“utf8”).readli

2021-03-18 08:35:36 183 2

原创 pytorch实现线性回归

coding=utf-8“”"author:leifunction:“”"from torch.optim import SGDimport torchfrom torch import nn定义一个device对象 如果要转换为gpu上运行device = torch.device(“cuda” if torch.cuda.is_available() else “cpu”)准备数据x = torch.rand([500, 1]).to(device)y_true = 3 * x

2021-03-18 08:34:25 114

原创 卷积神经网络完成mnist数据集的训练和测试

coding=utf-8“”"author:leifunction:“”"import numpy as npimport tensorflow as tf下载并载入Mnist 手写数字库(55000 * 28 * 28)from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets(‘mnist_data’, one_hot=True)one_hot 独热码(enco

2021-03-18 08:31:22 1261

原创 手动搭建神经网络实现mnist数据集的训练

import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data载入数据集mnist = input_data.read_data_sets(“mnist_data”, one_hot=True)每个批次的大小batch_size = 100计算一共多少个批次n_batch = mnist.train.num_examples // batch_size定义两个placeholder 一张图片

2021-03-18 08:30:14 382

原创 tensorflow完成mnist数据集训练和验证

coding=utf-8“”"author:leifunction:“”"import tensorflow as tfimport numpy as npimport matplotlib.pyplot as pltfrom tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets("./mnist_data/", one_hot=True)trainimgs, trai

2021-03-18 08:28:17 249

movie_data.csv

内容包括每个人的电影评论和对应情感

2021-03-18

datasets.zip

深度学习实现松鼠分类任务(h5文件),包括训练集和测试集

2021-03-18

cifar10数据集,人工智能学习必备数据集 (tfrecord格式)

cifar10数据集,包括训练集合验证集

2021-03-18

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除