0
Follow
0
View

How to achieve target change prediction estimation?

yiqiu1979 注册会员
2023-02-26 13:07

Train a regression model to map the classification of any smoke picture to the corresponding volume of traffic.
The steps are as follows:
1. Data preprocessing: The existing data set of smoke picture classification and traffic volume is divided into a training set and a test set. For each sample in the training set, its smoke classification label(1~5) is converted into the corresponding flow size(which can be defined by itself), which is used as the target value of the training data. For each sample in the test set, its smoke classification label also needs to be converted to the target value.

2. Feature extraction: VGG16 model is used to extract features from all smoke pictures in the training set and test set, and transform them into a feature vector. The output of some layers in the VGG16 model can be used as feature vectors, or the output of these layers can be spliced together to obtain higher-dimensional feature vectors.

3. Model training: A regression model is trained by using feature vectors and target values in the training set. You can choose linear regression, SVR, random forest regression and other models, or you can use neural network models.

4. Test and evaluation: The feature vectors and target values of the test set are used to test and evaluate the trained regression model. Mean square error(MSE), mean absolute error(MAE) and other indexes can be used to evaluate the performance of the model.

5. Prediction: For a new smoke picture, the VGG16 model is used to extract its feature vector and input it into the trained regression model to get the predicted flow size.

dgj123488 注册会员
2023-02-26 13:07

Part of the answer quotes GPT, GPT_Pro to better solve the problem
To achieve target change prediction estimation, deep learning techniques such as neural networks can be used, To analyze the characteristics of smoke at different flow rates and estimate the unknown smoke flow rates.

First, it is necessary to prepare a set of training data, which contains smoke images under various traffic flows. Different labels should be assigned to these images, so that the neural network can correctly learn the association between images and traffic. Then, the VGG16 neural network model is used to analyze these images, so that the neural network can extract the characteristics of corresponding traffic from the images and remember them. Finally, when a new image of unknown traffic is input, the neural network can estimate the volume of the image traffic based on the characteristics learned from the training data.

For example, the following code can be used to achieve a target change prediction estimate.

# 加载VGG16模型
model = keras.applications.vgg16.VGG16() 
# 创建一个新的神经网络
model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy']) 
# 训练模型
model.fit(X_train, y_train, epochs=20, batch_size=32) 
# 评估模型
predictions = model.predict(X_test) 
# 预测目标变化
predicted_flow = model.predict(image) 

If the answer is helpful, please accept it.

dazui9813 注册会员
2023-02-26 13:07

This answer quotes ChatGPT

To estimate the volume of traffic from an unfamiliar smoke picture based on its characteristics, you can use the following method:

1. Feature extraction: VGG16 model is used to extract the feature vector of each smoke picture. This feature vector is a lower dimensional representation that compresses the information of each smoke picture into a single vector.

2. Model building: Using the five groups of classified data, build a prediction model. A classification model, such as logistic regression and support vector machine, can be considered to take the five groups of classification data as the training set, feature vector as the input feature, and traffic size as the output label. By training the model, a mapping between the feature vector and the traffic volume is established.

3. Prediction: For new strange smoke pictures, VGG16 model is used to extract its feature vector, and then the prediction model established above is used to predict its flow size.

It should be noted that the performance of the prediction model is affected by the quality and quantity of training data. Therefore, you may need to collect more smoke picture data for training, and use techniques such as cross-validation to evaluate the performance of the model.

Sample code

import numpy as np
from keras.models import Sequential
from keras.layers import Dense
from keras.applications.vgg16 import VGG16
from keras.preprocessing import image
from keras.applications.vgg16 import preprocess_input

# 加载VGG16模型
model = VGG16(weights='imagenet', include_top=False)

# 定义一个函数,用于提取一张烟雾图片的特征向量
def extract_features(img_path):
    img = image.load_img(img_path, target_size=(224, 224))
    x = image.img_to_array(img)
    x = np.expand_dims(x, axis=0)
    x = preprocess_input(x)
    features = model.predict(x)
    return features.flatten()

# 构建训练数据
X_train = []
y_train = [0.2, 0.4, 0.6, 0.8, 1.0]
for i in range(1, 6):
    img_path = 'smoke{}.jpg'.format(i)
    features = extract_features(img_path)
    X_train.append(features)

# 建立预测模型
model = Sequential()
model.add(Dense(1, input_dim=25088))
model.compile(optimizer='adam', loss='mse')
model.fit(np.array(X_train), np.array(y_train), epochs=100, batch_size=1)

# 对于新的烟雾图片,提取其特征向量并预测流量大小
img_path = 'new_smoke.jpg'
features = extract_features(img_path)
prediction = model.predict(np.array([features]))
print('流量大小预测结果:', prediction[0][0])


liuyun5459 注册会员
2023-02-26 13:07

Modulation based on Monster Group and GPT:
To predict the volume of traffic in strange smoke images, regression models in deep learning can be used. The goal of a regression model is to predict the value of a continuous variable, unlike a classification model, which aims to predict a discrete label.

The following are the general steps to achieve prediction estimates of changes in goals:

  • Collection of training data: In order to train the regression model, a large number of labeled smoke image data is required, and each image needs its corresponding flow volume.
  • Prepare the data set: Divide the data set into training sets, validation sets, and test sets. It is generally recommended to use 80% of the data for training, 10% for validation, and 10% for testing.
  • Regression model: VGG16 network structure can be used as the base model, and then add some fully connected layers on top of it for regression. Mean square error(MSE) or mean absolute error(MAE) can be used as loss function of regression model.
  • Training model: Train the model with the training set, then use the verification set to adjust the hyperparameters of the model, such as learning rate and regularization coefficient, to avoid overfitting.
  • Test model: Test model performance with test sets and evaluate model prediction accuracy and error.
  • Model prediction: Use trained models to predict the flow of new smoke pictures.
  • In conclusion, to achieve the target change prediction estimation requires the establishment of a regression model, which can be trained to predict the volume of traffic in unfamiliar smoke pictures.
dongfeng19811020 注册会员
2023-02-26 13:07
< div class = "md_content_show e397 data - v - 3967" = "" >

in doubt reply online

About the Author

Question Info

Publish Time
2023-02-26 13:07
Update Time
2023-02-26 13:07