机器学习
YPL_ZML
这个作者很懒,什么都没留下…
展开
-
哑变量数据转换,稀疏矩阵
import pandas as pd import numpy as np # 类别数据转化 # 加载数据 detail = pd.read_excel('meal_order_detail.xlsx') # print(detail.columns) # 进行哑变量数据转换 --> 稀疏矩阵 # data = pd.get_dummies(detail['dishes_name']...原创 2019-06-26 22:54:23 · 675 阅读 · 0 评论 -
TfidfVectorizer统计词频
from sklearn.feature_extraction.text import TfidfVectorizer import jieba # text = ['This is the first document.', 'This is the second second document.', 'And the third one.', # 'Is this the f...原创 2019-06-27 20:08:54 · 1679 阅读 · 0 评论 -
CountVectorizer 词频统计
from sklearn.feature_extraction.text import CountVectorizer import jieba # 实例化一个con_vec对象 # con_vec = CountVectorizer(min_df=1) # 准备文本数据 # text = ['This is the first document.', 'This is the second...原创 2019-06-27 20:06:10 · 2328 阅读 · 1 评论 -
knn算法KNeighborsClassifier实现
import pandas as pd import numpy as np from sklearn.neighbors import KNeighborsClassifier # 加载数据 mov = pd.read_excel('电影分类数据.xlsx') # print(mov) train = mov.iloc[:, 1:6] train.loc[train.loc[:, '电影类...原创 2019-06-27 20:05:29 · 1123 阅读 · 0 评论 -
knn算法原理
import numpy as np import pandas as pd import os import matplotlib.pyplot as plt # 分析--》训练集里面 构建分类器模型 # ---在测试集里面进行应用,来评估分类器性能 # 加载数据 # def deal_data(dir_path): # """ # 处理数据 # :param di...原创 2019-06-26 23:02:23 · 246 阅读 · 0 评论 -
knn算法原理
import pandas as pd import numpy as np def distance(v1, v2): """ 自实现距离计算 :param v1: 点v1 :param v2: 点v2 :return: 距离 """ # 法一 # ndim = len(v1) # summary = 0 # f...原创 2019-06-26 22:59:51 · 563 阅读 · 0 评论 -
k-means算法模块实现
import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.cluster import KMeans def show_res(data, center, y_predict): """ 实现结果展示 :param data: 数据 :param cen...原创 2019-06-26 22:58:28 · 265 阅读 · 0 评论 -
k-means算法
import numpy as np import matplotlib.pyplot as plt # 要进行聚类, 得有样本 # 加载样本数据 data = [] with open('test.txt', 'r') as f: lines = f.readlines() # print(lines) for line in lines: line_...原创 2019-06-26 22:57:13 · 163 阅读 · 0 评论 -
线性逻辑回归以及稳健性测试
import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.linear_model.logistic import LogisticRegression from sklearn.preprocessing import StandardScale...原创 2019-06-27 20:10:51 · 1561 阅读 · 0 评论