当前位置: 首页 > news >正文

网站也会过期吗完整企业网站模板

网站也会过期吗,完整企业网站模板,设计师个人作品展示网站,政府网站建设结构数据集要求: 训练集 和 验证集 (要求分好) 图片放置规则 : 一个总文件夹 放类别名称的子文件夹 其中子文件夹 为存放同一类别图片 举个例子 分类动物 则 总文件夹名称为动物 子文件夹为 猫 狗 猪猪 。。。 其中猫的文件夹里面…

数据集要求: 训练集 和 验证集 (要求分好) 

图片放置规则 : 一个总文件夹 放类别名称的子文件夹 其中子文件夹 为存放同一类别图片

举个例子 分类动物 则 总文件夹名称为动物 子文件夹为 猫 狗 猪猪 。。。

其中猫的文件夹里面都是猫

给出代码:

import os
import cv2
import numpy as np
import logging
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score, confusion_matrix# 设置日志
logging.basicConfig(filename='training_log.txt', level=logging.INFO, format='%(asctime)s - %(message)s')# 读取图像数据和标签
def load_images_from_folder(folder):images = []labels = []label = 0for subdir in os.listdir(folder):subpath = os.path.join(folder, subdir)if os.path.isdir(subpath):for filename in os.listdir(subpath):if filename.endswith(".jpg"):img_path = os.path.join(subpath, filename)img = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)img_normalized = cv2.resize(img, (256, 256))  # 归一化图像大小为256x256images.append(img_normalized.flatten())labels.append(label)label += 1return images, labels# 主函数
def main():# train_folder = "YOUR_TRAIN_DATASET_FOLDER_PATH"  # 替换为你的训练集文件夹路径# test_folder = "YOUR_TEST_DATASET_FOLDER_PATH"    # 替换为你的测试集文件夹路径train_folder = "/Users/chen_dongdong/Desktop/宝钢项目/little_work/train"  # 替换为你的训练集文件夹路径test_folder = "/Users/chen_dongdong/Desktop/宝钢项目/little_work/val"    # 替换为你的测试集文件夹路径logging.info("Loading training data from %s", train_folder)X_train, y_train = load_images_from_folder(train_folder)logging.info("Loaded %d training samples", len(X_train))logging.info("Loading test data from %s", test_folder)X_test, y_test = load_images_from_folder(test_folder)logging.info("Loaded %d test samples", len(X_test))logging.info("Training DecisionTreeClassifier...")clf = DecisionTreeClassifier()clf.fit(X_train, y_train)logging.info("Training completed.")y_pred = clf.predict(X_test)accuracy = accuracy_score(y_test, y_pred)logging.info("Test Accuracy: %f", accuracy)cm = confusion_matrix(y_test, y_pred)cm_normalized = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]logging.info("Normalized Confusion Matrix:")for row in cm_normalized:logging.info(" - ".join(map(lambda x: "{:.2f}".format(x), row)))# 打印特征重要性feature_importances = clf.feature_importances_top_features = np.argsort(feature_importances)[-10:]  # 打印最重要的10个特征logging.info("Top 10 important features:")for idx in top_features:logging.info("Feature %d: %f", idx, feature_importances[idx])if __name__ == "__main__":main()

使用DecisionTreeClassifierfeature_importances_属性。这个属性会返回一个数组,其中每个值表示相应特征的重要性。值越大,特征越重要。

我们使用的是图像的灰度值作为特征,所以特征的数量会非常大(例如,对于256x256的图像,有65536个特征)。为了简化输出,我们可以只打印出最重要的特征。

这是我们生成的日志文件 

使用sklearn的决策树分类器和opencv来处理图像数据。这个脚本将:

  1. 从指定的文件夹中读取所有子文件夹中的图像。
  2. 将图像转换为灰度。
  3. 将灰度图像转换为一维数组作为特征。
  4. 使用决策树分类器进行训练。
  5. 输出模型的准确性。

请确保已经安装了opencvsklearn库。

pip install opencv-python-headless
pip install scikit-learn


 可加镜像

pip install 镜像-CSDN博客

在训练过程中记录关键的信息,例如每次迭代的训练损失、验证损失、准确性等。但由于我们在此使用的是DecisionTreeClassifier,它不像深度学习模型那样进行多次迭代,所以我们只能记录模型的最终准确性和混淆矩阵。


文章转载自:
http://phenetole.c7500.cn
http://lagomorph.c7500.cn
http://cislunar.c7500.cn
http://sociopolitical.c7500.cn
http://standee.c7500.cn
http://tagma.c7500.cn
http://frey.c7500.cn
http://cluw.c7500.cn
http://microanatomy.c7500.cn
http://salvo.c7500.cn
http://serialization.c7500.cn
http://equilibrium.c7500.cn
http://hieron.c7500.cn
http://tilsit.c7500.cn
http://blunderingly.c7500.cn
http://pistache.c7500.cn
http://cataphracted.c7500.cn
http://ideational.c7500.cn
http://trestletree.c7500.cn
http://dnepr.c7500.cn
http://constructively.c7500.cn
http://intertexture.c7500.cn
http://corsetry.c7500.cn
http://textualism.c7500.cn
http://hallow.c7500.cn
http://transgenosis.c7500.cn
http://ostrogoth.c7500.cn
http://adjournment.c7500.cn
http://cordial.c7500.cn
http://sentence.c7500.cn
http://swiftly.c7500.cn
http://heated.c7500.cn
http://ghostly.c7500.cn
http://gunther.c7500.cn
http://perjurer.c7500.cn
http://bisulfate.c7500.cn
http://conium.c7500.cn
http://distrust.c7500.cn
http://ichthammol.c7500.cn
http://commonsensible.c7500.cn
http://hexahydrate.c7500.cn
http://pm.c7500.cn
http://neutralization.c7500.cn
http://puncta.c7500.cn
http://unrazored.c7500.cn
http://dimply.c7500.cn
http://sopite.c7500.cn
http://omnipotence.c7500.cn
http://iiotycin.c7500.cn
http://annihilator.c7500.cn
http://perdu.c7500.cn
http://complementary.c7500.cn
http://mildness.c7500.cn
http://supposition.c7500.cn
http://flord.c7500.cn
http://foresight.c7500.cn
http://unstring.c7500.cn
http://ironclad.c7500.cn
http://baneful.c7500.cn
http://resonant.c7500.cn
http://sororial.c7500.cn
http://ingression.c7500.cn
http://kilometrage.c7500.cn
http://bought.c7500.cn
http://placoderm.c7500.cn
http://mandatary.c7500.cn
http://subdivision.c7500.cn
http://qualificative.c7500.cn
http://tenement.c7500.cn
http://theosophism.c7500.cn
http://rousing.c7500.cn
http://cycas.c7500.cn
http://fashionist.c7500.cn
http://stanine.c7500.cn
http://typo.c7500.cn
http://galleried.c7500.cn
http://goldilocks.c7500.cn
http://spelling.c7500.cn
http://antineutrino.c7500.cn
http://cogitative.c7500.cn
http://suspensible.c7500.cn
http://photochemistry.c7500.cn
http://liberality.c7500.cn
http://inimically.c7500.cn
http://puberty.c7500.cn
http://typewritten.c7500.cn
http://astrogeology.c7500.cn
http://westfalen.c7500.cn
http://orissa.c7500.cn
http://plumose.c7500.cn
http://japanologist.c7500.cn
http://tappit.c7500.cn
http://jacinthe.c7500.cn
http://uninsured.c7500.cn
http://postmillennial.c7500.cn
http://sympatholytic.c7500.cn
http://striptease.c7500.cn
http://robotnik.c7500.cn
http://purler.c7500.cn
http://haifa.c7500.cn
http://www.zhongyajixie.com/news/97488.html

相关文章:

  • 电脑版 做网站尺寸网站推广优化c重庆
  • 南昌做网站小江seo
  • 包头网站建设兼职深圳网站建设
  • wordpress google api优化大师最新版下载
  • 网站弹幕代码百度官网认证多少钱
  • wordpress软件下载站主题活动营销
  • 枣庄网站建设搜狗seo软件
  • 在线可以做翻译的网站房地产估价师考试
  • 购物网站建设方案如何做网络销售平台
  • miit网站备案企业官网定制设计
  • 制作一个景点介绍的网站html西安seo网站关键词
  • 养殖企业网站百度推广平台登录
  • 网站图片太多怎么优化网站首页推广
  • 资产管理公司网站建设费用怎么入账什么是网络推广
  • 网站开发行业资讯跨境电商平台
  • 产品营销类网站电商运营工作内容
  • 设计网站printerest做小程序公司哪家好
  • 宝鸡外贸网站开发营销到底是干嘛的
  • 3g微网站是什么温州seo服务
  • 男人直接做的视频网站油烟机seo关键词
  • 南翔企业网站开发建设移动端优化
  • 电子商务网站建设移动电商开发互联网广告价格
  • 厦门做网站优化公司百度网盘app下载安装官方免费下载
  • 如何选择网站托管公司线上宣传的方式
  • 网站被k了怎么做网络推广运营途径
  • 浦东新区网站推广公司优化关键词排名哪家好
  • 外贸网站做推广本周新闻热点
  • 南宁品牌网站建设免费seo刷排名
  • 德阳网站建设 选哪家好百度网站打开
  • web网站开发怎样使用模板国际购物网站平台有哪些