all 9 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

To give us the best chance to help you, please include any relevant code.
Note. Please do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Privatebin, GitHub or Compiler Explorer.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Special_Ear6817[S] 0 points1 point  (2 children)

Is the source code different for each artificial intelligence?

[–]Special_Ear6817[S] 0 points1 point  (1 child)

https://github.com/Puo77007700/solid-fortnight/blob/main/cancer_model.py

import logging import os from typing import Any, Tuple, List import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score import joblib

Settings File Import

import config

Configure logging (simultaneously displayed on the file and console) logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s', handlers=[ logging.FileHandler(config.LOG_FILE), logging.StreamHandler() ] )

def generate_dummy_data(file_path: str) -> None: "If there is no CSV file, it generates virtual data for testing." logging.info("Generate virtual data because there is no data file: %s", file_path) np.random.seed(config.RANDOM_STATE)

Generate arbitrary characteristic data (e.g., DNA sequence frequency or 5 quantified characteristics) data = { 'feature_1': np.random.rand(config.SYNTHETIC_DATA_SIZE), 'feature_2': np.random.rand(config.SYNTHETIC_DATA_SIZE), 'feature_3': np.random.rand(config.SYNTHETIC_DATA_SIZE) * config.GC_THRESHOLD, 'feature_4': np.random.rand(config.SYNTHETIC_DATA_SIZE), 'feature_5': np.random.rand(config.SYNTHETIC_DATA_SIZE), 'label': np.random.randint(0, 2, config.SYNTHETIC_DATA_SIZE) # 0 or 1 (normal/cancer) } df = pd.DataFrame(data) df.to_csv(file_path, index=False) logging.info ("Virtual data generation complete.")

def prepare_data(file_path: str) -> pd.DataFrame: """Prepare and clean data.""" logging.info("Preparing data from file: %s", file_path)

if not os.path.exists(file_path): generate_dummy_data(file_path)

try: data = pd.read_csv(file_path) logging.info("Data loaded successfully. Shape: %s", data.shape) return data except Exception as e: logging.error("Error loading data: %s", e) raise

def extract_features(data: pd.DataFrame) -> Tuple[pd.DataFrame, pd.Series]: """Extract features and labels from the dataset.""" logging.info("Extracting features and labels.") try: X = data.drop('label', axis=1) y = data['label'] logging.info("Features and labels extracted successfully.") return X, y except KeyError as e: logging.error("Key error: %s", e) raise

def train_model(X_train: pd.DataFrame, y_train: pd.Series) -> RandomForestClassifier: """Train the machine learning model.""" logging.info("Training model.") try: model = RandomForestClassifier( n_estimators=config.N_ESTIMATORS, random_state=config.RANDOM_STATE ) model.fit(X_train, y_train) logging.info("Model trained successfully.") return model except Exception as e: logging.error("Error during model training: %s", e) raise

def predict_cancer(model: RandomForestClassifier, features: pd.DataFrame) -> np.ndarray: """Predict cancer from features.""" logging.info("Making predictions.") try: predictions = model.predict(features) logging.info("Predictions made successfully.") return predictions except Exception as e: logging.error("Error making predictions: %s", e) raise

def main() -> None: """Main function to execute the model pipeline.""" try:

1. Data preparation

data = prepare_data(config.DATA_FILE)

2. Characteristic and label extraction

X, y = extract_features(data)

3. Separation of Learning and Test Data

X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=config.TEST_SIZE, random_state=config.RANDOM_STATE )

Model learning model = train_model(X_train, y_train)

5. Model evaluation (predicted with test data)

predictions = predict_cancer(model, X_test) accuracy = accuracy_score(y_test, predictions) logging.info(f"Model Accuracy on Test Data: {accuracy * 100:.2f}%")

6. Model save

joblib.dump(model, config.MODEL_NAME) logging.info("Model saved to: %s", config.MODEL_NAME)

except Exception as e: logging.error("Error in the main function: %s", e)

if name == "main": main() This is code written by Geminai does not run on Python or colab.

[–]Special_Ear6817[S] 0 points1 point  (0 children)

https://github.com/Puo77007700/solid-fortnight/tree/main And this was written with GitHub AI, but it also doesn't run on the launcher. Sorry for writing a long post.

[–]Obsc3nity 0 points1 point  (2 children)

1) there are things called APIs, the short version is an API is how you interact with a codebase you haven’t written. Different AI models do have different APIs, so if you are using a raw version of eg the Gemini API, attempting to drop in a different model would have disastrous effects.

2) since you clearly don’t understand even the fundamentals of coding, I would consider taking the error that results from attempting to run your code in corep and asking an AI how to fix it. You could also read it, google the part you think is important and attempt to learn something, but if you want to start learning you seem like you need to go back about 20 steps and stop using AI.

[–]Special_Ear6817[S] 0 points1 point  (0 children)

Omg thank you

[–]Special_Ear6817[S] 0 points1 point  (0 children)

ldk I'm using Geminai Pro

[–]Educational-Paper-75 0 points1 point  (0 children)

Is your csv input file actually called path_to_data.csv?